diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d2293a4e33..ef5ef3dfe1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,16 +1,2 @@ -# Modifications to the source code should be handled by the code review team -*.java @Slimefun/code-reviewers - -# Modifications to sensitive files should be reviewed by maintainers -/.github/ @Slimefun/slimefun4-maintainers -pom.xml @Slimefun/slimefun4-maintainers -CONTRIBUTING.md @Slimefun/slimefun4-maintainers - -# Changes to the Issue templates need to be checked by the triage team -/.github/ISSUE_TEMPLATE/ @Slimefun/bug-testers - -# Our wiki lookup file will be reviewed by the wiki staff team -/src/main/resources/wiki.json @Slimefun/wiki-staff - -# This file is handled by TheBusyBiscuit (admins have overwrite access anyway) -/.github/CODEOWNERS @TheBusyBiscuit +# All changes are reviewed by the maintainers +* @Slimefun5/maintainers diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 0a2e285211..a6e04fc4ac 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -1,4 +1,4 @@ -# Slimefun4 - Code of Conduct +# Slimefun5 - Code of Conduct ### What is a Code of Conduct? > A code of conduct is a document that establishes expectations for behavior for your project’s participants. > Adopting, and enforcing, a code of conduct can help create a positive social atmosphere for your community. @@ -7,8 +7,7 @@ This document should serve the purpose of outlining the behaviour we expect from any participant of the project. ## :mag_right: Scope -This Code of Conduct applies to all sections of the [Slimefun4 GitHub repository](https://github.com/Slimefun/Slimefun4), our [Slimefun GitHub organization](https://github.com/Slimefun) and all repositories owned by said organization.
-For our official Discord server, please refer to our article on [Discord Rules](https://github.com/Slimefun/Slimefun4/wiki/Discord-Rules). +This Code of Conduct applies to all sections of the [Slimefun5 GitHub repository](https://github.com/Slimefun5/Slimefun5) and our [Slimefun5 GitHub organization](https://github.com/Slimefun5). Everyone who engages with this project on any of these repositories is expected to follow the Code of Conduct.
This includes maintainers, contributors, sponsors and anyone who engages in the "Issues" section on GitHub. @@ -18,8 +17,7 @@ This is an Open-Source project, anyone is welcome to engage and contribute!
We generally expect users to engage in the Issues section by reporting bugs or commenting on bug reports to give additional context, help, guidance or to propose possible solutions and fixes. Pull Requests are very much welcome and encouraged! They keep the project alive, so if you see an Issue and know how to fix it, feel free to create a Pull Request! -Issues that are considered "good first issues", indicated by the [good first issue](https://github.com/Slimefun/Slimefun4/labels/good%20first%20issue) label, are generally expected to be beginner-friendly. -And even if you shouldn't know where to start or how to proceed, our [Discord Server](https://discord.gg/slimefun) and its community will be there for you! +Issues that are considered "good first issues", indicated by the [good first issue](https://github.com/Slimefun5/Slimefun5/labels/good%20first%20issue) label, are generally expected to be beginner-friendly. When commenting, please keep in mind that this software is offered for **free**. Don't expect to receive lightning-fast replies 24 hours a day. Everyone here works on this project in their free time and usually has work, school, university or family to take care of, so we appreciate patience and understanding. @@ -54,13 +52,12 @@ comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. -You can see a list of people who are recognized as "project maintainers" for Slimefun on the Slimefun GitHub organization:
-https://github.com/orgs/Slimefun/people +You can see a list of people who are recognized as "project maintainers" for Slimefun on the Slimefun5 GitHub organization:
+https://github.com/orgs/Slimefun5/people ## :wrench: Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders (labelled on Discord as "Admins" or "Moderators") responsible for enforcement on our [Discord Server](discord.gg/slimefun). -If you want your issue to be handled discreetly, message `TheBusyBiscuit#2610` or `Walshy#9709` privately on Discord and state your concerns. +reported to the project maintainers via [GitHub Issues](https://github.com/Slimefun5/Slimefun5/issues). All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 08c508502f..96c9f3ba09 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,3 +1,3 @@ THIS ISSUE IS INVALID. -TO REPORT A BUG, GO HERE -> https://github.com/Slimefun/Slimefun4/issues/new/choose +TO REPORT A BUG, GO HERE -> https://github.com/Slimefun5/Slimefun5/issues/new/choose diff --git a/.github/ISSUE_TEMPLATE/bug-report.yaml b/.github/ISSUE_TEMPLATE/bug-report.yaml index fcc3435e70..3e14809431 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yaml +++ b/.github/ISSUE_TEMPLATE/bug-report.yaml @@ -1,28 +1,25 @@ name: Bug Report -description: Report a Bug or an Issue with Slimefun 4. +description: Report a Bug or an Issue with Slimefun. labels: ['🎯 Needs testing', '🐞 Bug Report'] body: - type: markdown attributes: value: | - ## 👋 Welcome to the Slimefun Bug Tracker - If you need any help to identify the problem, visit our [Discord server](https://discord.gg/slimefun) and see if others experience a similar issue. - Also take a look at our [Troubleshooting Guide](https://github.com/Slimefun/Slimefun4/wiki/How-to-report-bugs) and the list of [existing Issues](https://github.com/Slimefun/Slimefun4/issues). + ## Bug Tracker + Take a look at our [Troubleshooting Guide](https://github.com/Slimefun/Slimefun4/wiki/How-to-report-bugs) and the list of [existing Issues](https://github.com/Slimefun5/Slimefun5/issues).
Fields marked with an asterisk (*) are required.
- id: checklist type: checkboxes attributes: - label: '❗ Checklist' + label: 'Checklist' description: Please go through this checklist before creating the issue. options: - label: I am using the official english version of Slimefun and did not modify the jar. required: true - - label: I downloaded the official version from the new build site [Blob Builds](https://blob.build/). - required: true - - label: I am using an up to date "DEV" (not "RC") version of Slimefun. + - label: I downloaded the latest release from [GitHub Releases](https://github.com/Slimefun5/Slimefun5/releases). required: true - label: I am aware that issues related to Slimefun addons need to be reported on their bug trackers and not here. required: true @@ -34,7 +31,7 @@ body: validations: required: true attributes: - label: '📍 Description' + label: 'Description' description: | A clear and detailed description of what went wrong. The more information you can provide, the easier we can handle this problem. @@ -46,7 +43,7 @@ body: validations: required: true attributes: - label: '📑 Reproduction Steps' + label: 'Reproduction Steps' description: | Tell us the exact steps to reproduce this issue, the more detailed the easier we can reproduce it. placeholder: | @@ -59,7 +56,7 @@ body: validations: required: true attributes: - label: '💡 Expected Behavior' + label: 'Expected Behavior' description: | What were you expecting to happen? What do you think would have been the correct behaviour? @@ -69,7 +66,7 @@ body: - id: media type: textarea attributes: - label: '📷 Screenshots / Videos' + label: 'Screenshots / Videos' description: | The best way to illustrate in an issue is by recording a Video or taking a Screenshot. If you can capture any footage of the bug happening, it would help us out a lot! @@ -79,7 +76,7 @@ body: - id: server-log type: input attributes: - label: '📜 Server Log' + label: 'Server Log' description: | Take a look at your Server Log and upload any error messages from Slimefun to a pasting site (e.g. https://pastebin.com/). If you are unsure about it, post your full log, you can find it under /logs/latest.log @@ -88,7 +85,7 @@ body: - id: error-reports type: input attributes: - label: '📂 `/error-reports/` folder' + label: '`/error-reports/` folder' description: | Check the folder `/plugins/Slimefun/error-reports/` and upload any files inside that folder to a pasting site (e.g. https://pastebin.com/). placeholder: https://pastebin.com/... @@ -98,13 +95,12 @@ body: validations: required: true attributes: - label: '💻 Server Software' + label: 'Server Software' description: 'Please select the software your Server is running on' options: - Spigot - Paper - Purpur - - Airplane - Other (please specify in your description) - id: minecraft-version @@ -112,9 +108,10 @@ body: validations: required: true attributes: - label: '🎮 Minecraft Version' + label: 'Minecraft Version' description: 'Please select the Minecraft version of the server' options: + - 1.21.x - 1.20.x - 1.19.x - 1.18.x @@ -127,7 +124,7 @@ body: validations: required: true attributes: - label: '⭐ Slimefun version' + label: 'Slimefun version' description: | **"latest" is not a version number, we need the exact version.** We recommend running "/sf versions" and uploading a screenshot of that. @@ -137,7 +134,7 @@ body: - id: other-versions type: textarea attributes: - label: '🧭 Other plugins' + label: 'Other plugins' description: | If your issue is related to another plugin, make sure to include this here! placeholder: The issue is related to plugin [...], version [...] @@ -145,8 +142,6 @@ body: - type: markdown attributes: value: | - ## ❤️ Thank you for submitting your bug report! + ## Thank you for submitting your bug report! If you find any additional info that can help to identify this problem, don't hesitate to comment on your issue! Any additional info can help us fix this bug faster. - In the meantime, try visiting our [Discord server](https://discord.gg/slimefun). - Perhaps someone else has experienced a similar issue. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index b14ef722f3..4a69e7cfd6 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,8 @@ blank_issues_enabled: false contact_links: - name: Code of Conduct - url: https://github.com/Slimefun/Slimefun4/blob/master/.github/CODE_OF_CONDUCT.md + url: https://github.com/Slimefun5/Slimefun5/blob/stable/.github/CODE_OF_CONDUCT.md about: Please read this before posting - name: Bug Report Guidelines url: https://github.com/Slimefun/Slimefun4/wiki/How-to-report-bugs about: Guidelines on how to make good Bug reports - - name: Discord Server (for Questions and Suggestions) - url: https://discord.gg/slimefun - about: Please ask and answer questions here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0ebdee6426..7b2f4c2386 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -17,7 +17,7 @@ - [ ] I have fully tested the proposed changes and promise that they will not break everything into chaos. - [ ] I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them. -- [ ] I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.20.*). +- [ ] I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.21.*). - [ ] I followed the existing code standards and didn't mess up the formatting. - [ ] I did my best to add documentation to any public classes or methods I added. - [ ] I have added `Nonnull` and `Nullable` annotations to my methods to indicate their behaviour for null values diff --git a/.github/docs-config.yml b/.github/docs-config.yml new file mode 100644 index 0000000000..552b077c7b --- /dev/null +++ b/.github/docs-config.yml @@ -0,0 +1,7 @@ +description: "Slimefun is a Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items and recipes to your Minecraft Server." +java: "25" +paper: "26.1.2" +gradle_plugin: "1.8.2.1" + +bstats: 31272 +bstats_name: Slimefun 5 diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml deleted file mode 100644 index 8f3836fad9..0000000000 --- a/.github/workflows/auto-approve.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Auto approve - -on: pull_request - -permissions: - contents: read - -jobs: - auto-approve: - - name: Auto approve Pull Request - runs-on: ubuntu-latest - - # for hmarr/auto-approve-action to approve PRs - permissions: - pull-requests: write - - # Only run this on the main repo - if: github.event.pull_request.head.repo.full_name == 'Slimefun/Slimefun4' - - steps: - - name: Approve via actions - uses: hmarr/auto-approve-action@v4.0.0 - if: github.actor == 'TheBusyBot' || github.actor == 'renovate[bot]' - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/auto-squash.yml b/.github/workflows/auto-squash.yml deleted file mode 100644 index 8b8ef1f434..0000000000 --- a/.github/workflows/auto-squash.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Auto squash pull requests - -on: - pull_request_review: - types: - - submitted - - check_suite: - types: - - completed - - status: {} - -jobs: - autosquash-crowdin: - - name: Auto squash (Crowdin) - runs-on: ubuntu-latest - - ## Only run this on the main repo - if: github.event.pull_request.head.repo.full_name == 'Slimefun/Slimefun4' - - steps: - - name: Auto squash - uses: pascalgn/automerge-action@v0.16.4 - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - UPDATE_RETRIES: 0 - MERGE_METHOD: squash - MERGE_FORKS: false - MERGE_DELETE_BRANCH: true - MERGE_LABELS: '📄 Translations Update' - MERGE_COMMIT_MESSAGE: '[CI skip] New locale updates from Crowdin' - - autosquash-renovate: - - name: Auto squash (Renovate) - runs-on: ubuntu-latest - - ## Only run this on the main repo - if: github.event.pull_request.head.repo.full_name == 'Slimefun/Slimefun4' - - steps: - - name: Auto squash - uses: pascalgn/automerge-action@v0.16.4 - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - UPDATE_RETRIES: 0 - MERGE_METHOD: squash - MERGE_FORKS: false - MERGE_DELETE_BRANCH: true - MERGE_LABELS: '🚨 Dependency Update' - MERGE_COMMIT_MESSAGE: '[CI skip] ${{ github.event.pull_request.title }}' diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000000..1c069d3a70 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,7 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + uses: Slimefun5/workflows/.github/workflows/ci.yaml@stable diff --git a/.github/workflows/close-invalid-issues.yml b/.github/workflows/close-invalid-issues.yml deleted file mode 100644 index 705f6ab9a5..0000000000 --- a/.github/workflows/close-invalid-issues.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Close invalid Issue - -on: - issues: - types: [opened] - -jobs: - comment: - - name: Invalid Issues - runs-on: ubuntu-latest - - if: contains(github.event.issue.labels.*.name, '🐞 Bug Report') == false && contains(github.event.issue.labels.*.name, 'Hacktoberfest') == false - steps: - - name: Close Issue - uses: maxkomarychev/octions/octions/issues/update@master - with: - token: ${{ secrets.ACCESS_TOKEN }} - issue_number: ${{ github.event.issue.number }} - state: closed - - name: Add invalid label - uses: maxkomarychev/octions/octions/issues/add-labels@master - with: - token: ${{ secrets.ACCESS_TOKEN }} - issue_number: ${{ github.event.issue.number }} - labels: 'invalid' - - name: Create a comment - uses: maxkomarychev/octions/octions/issues/create-comment@master - with: - token: ${{ secrets.ACCESS_TOKEN }} - issue_number: ${{ github.event.issue.number }} - body: |- - Your issue seems to be missing our template. - [Click here to create a bug report](https://github.com/Slimefun/Slimefun4/issues/new/choose) - - Please remember that this Bug Tracker is exclusively reserved for Bug reports, any other form - of discussion, like suggestions or questions should be posted on our discord server (You can find a link [on our main page](https://github.com/Slimefun/Slimefun4#discord)). diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml deleted file mode 100644 index 6735d5d642..0000000000 --- a/.github/workflows/discord-webhook.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Discord Webhook - -on: - push: - paths: - - 'src/**' - - '!src/main/resources/languages/**' - - 'pom.xml' - -permissions: - contents: read - -jobs: - report: - - name: Discord Webhook - runs-on: ubuntu-latest - - ## Only run this on the main repo - if: github.repository == 'Slimefun/Slimefun4' - - steps: - - name: Checkout repository - uses: actions/checkout@v4.2.2 - - - name: Set up Java JDK 21 - uses: actions/setup-java@v4.6.0 - with: - distribution: 'adopt' - java-version: '21' - java-package: jdk - architecture: x64 - - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Run Discord Webhook - uses: baked-libs/discord-webhook@1.5.1 - with: - id: ${{ secrets.DISCORD_WEBHOOK_ID }} - token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} diff --git a/.github/workflows/duplicates.yml b/.github/workflows/duplicates.yml deleted file mode 100644 index 7cb94d0dcb..0000000000 --- a/.github/workflows/duplicates.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Mark Issue as duplicate - -on: - issue_comment: - types: [created] - -permissions: - contents: read - issues: write - -jobs: - comment: - - name: Mark Issue as duplicate - runs-on: ubuntu-latest - - if: contains(github.event.comment.body, 'Duplicate of ') - - steps: - - name: Add label to the Issue - uses: maxkomarychev/octions/octions/issues/add-labels@master - with: - token: ${{ secrets.ACCESS_TOKEN }} - issue_number: ${{ github.event.issue.number }} - labels: '🚩 Duplicate' diff --git a/.github/workflows/e2e-testing.yml b/.github/workflows/e2e-testing.yml deleted file mode 100644 index e6be9ca39a..0000000000 --- a/.github/workflows/e2e-testing.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: End to End Testing - -on: - workflow_call: - inputs: - artifact-name: - description: 'Slimefun artifact name' - required: true - type: string - -jobs: - e2e-testing: - name: End to End Testing - runs-on: ubuntu-latest - timeout-minutes: 5 - - strategy: - matrix: - include: - - mcVersion: '1.16.5' - javaVersion: '16' - - mcVersion: '1.17.1' - javaVersion: '17' - - mcVersion: '1.18.2' - javaVersion: '18' - - mcVersion: '1.19.4' - javaVersion: '19' - - mcVersion: '1.20.4' - javaVersion: '20' - - mcVersion: '1.20.6' - javaVersion: '21' - #- mcVersion: 'latest' - # javaVersion: '21' - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up JDK - uses: actions/setup-java@v4.6.0 - with: - distribution: temurin - java-version: ${{ matrix.javaVersion }} - java-package: jdk - architecture: x64 - - - name: Setup server - run: | - echo 'eula=true' > eula.txt - mkdir plugins - - - name: Download ${{ matrix.mcVersion }} Paper - run: | - VERSION="${{ matrix.mcVersion }}" - if [ "$VERSION" == "latest" ]; then - VERSION=$(curl https://api.papermc.io/v2/projects/paper/ -s | jq -r '.versions[-1]') - fi - - BUILD_JAR=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/$VERSION/builds" \ - | jq '.builds[-1] | "\(.build) \(.downloads.application.name)"' -r) - BUILD=$(echo "$BUILD_JAR" | awk '{print $1}') - JAR_FILE=$(echo "$BUILD_JAR" | awk '{print $2}') - - echo "Downloading... https://api.papermc.io/v2/projects/paper/versions/$VERSION/builds/$BUILD/downloads/$JAR_FILE" - curl -o paper.jar \ - "https://api.papermc.io/v2/projects/paper/versions/$VERSION/builds/$BUILD/downloads/$JAR_FILE" - - - name: Download Slimefun - uses: actions/download-artifact@v4 - with: - name: ${{ inputs.artifact-name }} - path: plugins/ - - - name: Download e2e-tester - run: | - curl -o e2e-tester.jar https://preview-builds.walshy.dev/download/e2e-tester/main/latest - mv e2e-tester.jar plugins/e2e-tester.jar - - - name: Run server - run: | - java -jar paper.jar --nogui diff --git a/.github/workflows/javadocs.yml b/.github/workflows/javadocs.yml deleted file mode 100644 index f628c2a692..0000000000 --- a/.github/workflows/javadocs.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Javadocs - -on: - push: - paths: - - 'src/**' - - 'pom.xml' - -permissions: - contents: read - -jobs: - build: - name: Maven build - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4.6.0 - with: - distribution: 'adopt' - java-version: '21' - java-package: jdk - architecture: x64 - - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Build Javadocs - run: mvn javadoc:javadoc diff --git a/.github/workflows/json-validator.yml b/.github/workflows/json-validator.yml deleted file mode 100644 index 512a484828..0000000000 --- a/.github/workflows/json-validator.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Validate JSON - -on: - push: - paths: - - 'src/main/resources/wiki.json' - pull_request: - paths: - - 'src/main/resources/wiki.json' - -permissions: - contents: read - -jobs: - validate: - - name: Validate JSON - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - name: Validate wiki.json - uses: docker://orrosenblatt/validate-json-action:latest@sha256:02370758b8b199e0477da11ecfdd498c75c561685056b5c31b925a4ab95df7f4 - env: - INPUT_SCHEMA: '.github/configs/wiki-schema.json' - INPUT_JSONS: 'src/main/resources/wiki.json' diff --git a/.github/workflows/label-resolved-issues.yml b/.github/workflows/label-resolved-issues.yml deleted file mode 100644 index 5a54fb3144..0000000000 --- a/.github/workflows/label-resolved-issues.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Label resolved issues - -on: - issues: - types: [closed] - -permissions: - contents: read - issues: write - -jobs: - label: - - name: Label Issue - runs-on: ubuntu-latest - if: contains(github.event.issue.labels.*.name, '🐞 Bug Report') - - steps: - - name: Query recent commits - uses: TheBusyBiscuit/recently-closed-issues@1.1.0 - id: resolved - with: - token: ${{ secrets.ACCESS_TOKEN }} - max_commits: 20 - - - name: Add label - if: contains(steps.resolved.outputs.issues, github.event.issue.number) - uses: maxkomarychev/octions/octions/issues/add-labels@master - with: - token: ${{ secrets.ACCESS_TOKEN }} - issue_number: ${{ github.event.issue.number }} - labels: '✔ Resolved' diff --git a/.github/workflows/maven-compiler.yml b/.github/workflows/maven-compiler.yml deleted file mode 100644 index fa79dc66ca..0000000000 --- a/.github/workflows/maven-compiler.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Java CI - -on: - push: - branches: - - master - paths: - - 'src/**' - - 'pom.xml' - pull_request: - paths: - - '.github/workflows/**' - - 'src/**' - - 'pom.xml' - - 'CHANGELOG.md' - -permissions: - contents: read - -jobs: - build: - - name: Maven build - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4.6.0 - with: - distribution: 'adopt' - java-version: '21' - java-package: jdk - architecture: x64 - - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Build with Maven - run: mvn package --file pom.xml diff --git a/.github/workflows/merge-conflicts.yml b/.github/workflows/merge-conflicts.yml deleted file mode 100644 index 5ac09a0a50..0000000000 --- a/.github/workflows/merge-conflicts.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Merge Conflicts - -on: - push: - branches: - - master - -permissions: - contents: read - pull-requests: write - -jobs: - validate: - if: github.repository == 'Slimefun/Slimefun4' - name: Check for merge conflicts - runs-on: ubuntu-latest - - steps: - - uses: mschilde/auto-label-merge-conflicts@master - with: - CONFLICT_LABEL_NAME: '⚡ Merge Conflicts' - GITHUB_TOKEN: "${{ secrets.ACCESS_TOKEN }}" diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml deleted file mode 100644 index b857b2faa6..0000000000 --- a/.github/workflows/pr-labels.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Pull Request Labels - -on: - pull_request_target: - types: - - opened - -permissions: - contents: read - pull-requests: write - -jobs: - pr-labeler: - - name: Pull Request Labels - runs-on: ubuntu-latest - if: github.repository == 'Slimefun/Slimefun4' - - steps: - - uses: baked-libs/pull-request-labels@v1.1 - id: labeller - name: Apply labels based on branch - with: - token: "${{ secrets.GITHUB_TOKEN }}" - renovate: '🚨 Dependency Update' - crowdin: '📄 Translations Update' - feature: '🎈 Feature' - fix: '✨ Fix' - chore: '🧹 Chores' - performance: '💡 Performance Optimization' - api: '🔧 API' - compatibility: '🤝 Compatibility' - - - uses: thollander/actions-comment-pull-request@v2.5.0 - name: Leave a comment about the applied label - if: ${{ steps.labeller.outputs.applied != 0 }} - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - message: | - Your Pull Request was automatically labelled as: "${{ steps.labeller.outputs.applied }}" - Thank you for contributing to this project! ❤️ - - - uses: thollander/actions-comment-pull-request@v2.5.0 - name: Leave a comment about our branch naming convention - if: ${{ steps.labeller.outputs.applied == 0 }} - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - message: | - **Pro Tip!** - You can help us label your Pull Requests by using the following branch naming convention next time you create a pull request. ❤️ - Branch naming convention | Label - ------------------------ | ------ - `feature/**` | 🎈 Feature - `fix/**` | ✨ Fix - `chore/**` | 🧹 Chores - `api/**` | 🔧 API - `performance/**` | 💡 Performance Optimization - `compatibility/**` | 🤝 Compatibility -
- If your changes do not fall into any of these categories, don't worry. - You can just ignore this message in that case! 👀 diff --git a/.github/workflows/preview-builds.yml b/.github/workflows/preview-builds.yml deleted file mode 100644 index b9e7b5d26a..0000000000 --- a/.github/workflows/preview-builds.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Preview builds - -on: - workflow_run: - workflows: ["Pull Request"] - types: - - completed - -permissions: - contents: read - pull-requests: write - -jobs: - preview: - if: ${{ github.repository_owner == 'Slimefun' && github.event.workflow_run.conclusion == 'success' }} - name: Build and Publish the jar - runs-on: ubuntu-latest - - steps: - # Kinda jank way to grab the PR and commit hash and then download the artifact - # TODO: Move this code to our own mini-action - - name: Grab PR & run ID and download the artifact - uses: actions/github-script@v7 - with: - script: | - const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - - for (const artifact of allArtifacts.data.artifacts) { - // Extract the PR number and commit hash from the artifact name - const match = /^slimefun-(\d+)-([a-f0-9]{8})$/.exec(artifact.name); - if (match) { - require("fs").appendFileSync( - process.env.GITHUB_ENV, - `\nPR_NUMBER=${match[1]}` + - `\nCOMMIT_HASH=${match[2]}` - ); - - const download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: artifact.id, - archive_format: 'zip', - }); - require('fs').writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview.zip`, Buffer.from(download.data)) - - break; - } - } - - # Unzip the artifact - - name: Unzip - run: | - unzip preview.zip - rm preview.zip - mv 'Slimefun vPreview Build #${{ env.PR_NUMBER }}-${{ env.COMMIT_HASH }}.jar' preview.jar - - - name: Upload to preview service - run: | - curl -X POST \ - -H 'Authorization: ${{ secrets.PUBLISH_TOKEN }}' \ - -H "X-Checksum: $(sha256sum 'preview.jar' | awk '{print $1}')" \ - --data-binary '@preview.jar' \ - https://preview-builds.walshy.dev/upload/Slimefun/${{ env.PR_NUMBER }}/${{ env.COMMIT_HASH }} - - - name: Post comment - uses: marocchino/sticky-pull-request-comment@v2 - with: - number: ${{ env.PR_NUMBER }} - message: | - ### Slimefun preview build - - A Slimefun preview build is available for testing! - Commit: ${{ env.COMMIT_HASH }} - - https://preview-builds.walshy.dev/download/Slimefun/${{ env.PR_NUMBER }}/${{ env.COMMIT_HASH }} - - > **Note**: This is not a supported build and is only here for the purposes of testing. - > Do not run this on a live server and do not report bugs anywhere but this PR! diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml new file mode 100644 index 0000000000..009afe63ee --- /dev/null +++ b/.github/workflows/promote.yml @@ -0,0 +1,55 @@ +name: Promote experimental to stable + +# Updates stable ONLY through CI (never a direct push). Fires on a release tag (v*) or an +# explicit promote-* tag / manual run. +# +# experimental holds the universal-jar rewrite, divergent from the old stable. The first run +# cannot fast-forward: it records a merge whose tree EQUALS experimental (old stable history is +# preserved via the merge parent). Later runs fast-forward. experimental has no README.md (it is +# generated only on stable), so this workflow regenerates it after the merge — a GITHUB_TOKEN push +# does NOT trigger readme.yaml, so promotion must regenerate the README itself. + +on: + push: + tags: + - "v*" + - "promote-*" + workflow_dispatch: + +jobs: + promote: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout stable + uses: actions/checkout@v4 + with: + ref: stable + fetch-depth: 0 + + - name: Promote experimental into stable + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git fetch origin experimental + if git merge --ff-only origin/experimental; then + echo "Fast-forwarded stable to experimental." + else + echo "Divergent: recording a merge whose tree equals experimental." + git merge -s ours --no-commit origin/experimental + git read-tree --reset -u origin/experimental + git commit --no-edit -m "release: promote experimental (universal-jar) to stable" + fi + + - name: Regenerate README on stable + run: | + curl -sL https://raw.githubusercontent.com/Slimefun5/workflows/stable/.github/scripts/generate-readme.py -o /tmp/generate-readme.py + python3 /tmp/generate-readme.py --repository "${{ github.repository }}" + if ! git diff --quiet README.md 2>/dev/null || [ -n "$(git status --porcelain README.md)" ]; then + git add README.md + git commit -m "docs: auto-generate README.md [skip ci]" + fi + + - name: Push stable + run: git push origin stable diff --git a/.github/workflows/publish-build.yml b/.github/workflows/publish-build.yml deleted file mode 100644 index 31e94e16a2..0000000000 --- a/.github/workflows/publish-build.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Publish build - -on: - push: - branches: - - master - - stable - - experimental - -jobs: - publish: - name: Upload build - runs-on: ubuntu-latest - if: contains(github.event.head_commit.message, '[ci skip]') == false - - steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4.6.0 - with: - distribution: 'adopt' - java-version: '21' - java-package: jdk - architecture: x64 - - - name: Build with Maven - run: mvn clean package - - - name: Upload Dev build - uses: WalshyDev/blob-builds/gh-action@ea9ecd9266c902c6627f884e657560d0fa6b61dd - if: github.ref == 'refs/heads/master' - with: - project: Slimefun4 - releaseChannel: Dev - apiToken: ${{ secrets.BLOB_BUILDS_API_TOKEN }} - file: './target/Slimefun v4.9-UNOFFICIAL.jar' - releaseNotes: ${{ github.event.head_commit.message }} - - - name: Upload RC build - uses: WalshyDev/blob-builds/gh-action@ea9ecd9266c902c6627f884e657560d0fa6b61dd - if: github.ref == 'refs/heads/stable' - with: - project: Slimefun4 - releaseChannel: 'RC' - apiToken: ${{ secrets.BLOB_BUILDS_API_TOKEN }} - file: './target/Slimefun v4.9-UNOFFICIAL.jar' - releaseNotes: ${{ github.event.head_commit.message }} - - - name: Upload Experimental build - uses: WalshyDev/blob-builds/gh-action@ea9ecd9266c902c6627f884e657560d0fa6b61dd - if: github.ref == 'refs/heads/experimental' - with: - project: Slimefun4 - releaseChannel: 'Experimental' - apiToken: ${{ secrets.BLOB_BUILDS_API_TOKEN }} - file: './target/Slimefun v4.9-UNOFFICIAL.jar' - releaseNotes: ${{ github.event.head_commit.message }} diff --git a/.github/workflows/publish-platforms.yml b/.github/workflows/publish-platforms.yml new file mode 100644 index 0000000000..14aa6c3530 --- /dev/null +++ b/.github/workflows/publish-platforms.yml @@ -0,0 +1,17 @@ +name: Publish to platforms + +on: + push: + tags: + - "v*" + +jobs: + publish: + permissions: + contents: write + uses: Slimefun5/workflows/.github/workflows/publish-platforms.yml@stable + with: + project_name: Slimefun + gradle_task: ":core:shadowJar" + jar_dir: "core/build/libs" + secrets: inherit diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml deleted file mode 100644 index 28e0d47a98..0000000000 --- a/.github/workflows/pull-request.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Pull Request - -on: - pull_request: - paths: - - '.github/workflows/**' - - 'src/**' - - 'pom.xml' - -permissions: - contents: read - -jobs: - setup-preview-build: - name: Preview build - runs-on: ubuntu-latest - outputs: - short-commit-hash: ${{ steps.env-setup.outputs.SHORT_COMMIT_HASH }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4.6.0 - with: - distribution: 'adopt' - java-version: '21' - java-package: jdk - architecture: x64 - - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - # Setup for the preview build - - id: env-setup - run: | - SHORT_COMMIT_HASH=$(git rev-parse --short=8 ${{ github.sha }}) - JAR_VERSION="Preview Build #${{ github.event.number }}-$SHORT_COMMIT_HASH" - echo "SHORT_COMMIT_HASH=$SHORT_COMMIT_HASH" >> "$GITHUB_ENV" - echo "SHORT_COMMIT_HASH=$SHORT_COMMIT_HASH" >> "$GITHUB_OUTPUT" - echo "JAR_VERSION=$JAR_VERSION" >> "$GITHUB_ENV" - sed -i "s/4.9-UNOFFICIAL<\/version>/$JAR_VERSION<\/version>/g" pom.xml - - - name: Build with Maven - run: mvn package - - - name: Upload the artifact - uses: actions/upload-artifact@v4 - with: - name: slimefun-${{ github.event.number }}-${{ env.SHORT_COMMIT_HASH }} - path: 'target/Slimefun v${{ env.JAR_VERSION }}.jar' - - call-workflows: - needs: [setup-preview-build] - uses: ./.github/workflows/e2e-testing.yml - with: - artifact-name: slimefun-${{ github.event.number }}-${{ needs.setup-preview-build.outputs.short-commit-hash }} diff --git a/.github/workflows/readme.yaml b/.github/workflows/readme.yaml new file mode 100644 index 0000000000..c277ff3bfd --- /dev/null +++ b/.github/workflows/readme.yaml @@ -0,0 +1,15 @@ +name: Generate README + +on: + workflow_dispatch: + push: + branches: + - stable + +jobs: + readme: + permissions: + contents: write + uses: Slimefun5/workflows/.github/workflows/readme-addon.yaml@stable + with: + repository: ${{ github.repository }} diff --git a/.github/workflows/release-candidates.yml b/.github/workflows/release-candidates.yml deleted file mode 100644 index e330af4b09..0000000000 --- a/.github/workflows/release-candidates.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Create new Release Candidate - -on: - workflow_dispatch: - inputs: - number: - description: 'RC number (e.g. 15)' - required: true - release_date: - description: 'Date of release (e.g. 12-apr-2021)' - required: true - -jobs: - release: - - name: Create new release - runs-on: ubuntu-latest - - steps: - - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: 'stable' - - - name: Merge latest commits into 'stable' - uses: devmasx/merge-branch@1.4.0 - with: - type: now - from_branch: 'master' - target_branch: 'stable' - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Get the latest commit sha - id: latest - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - - name: Create Release - id: create_release - uses: actions/create-release@v1.1.4 - env: - GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - with: - tag_name: RC-${{ github.event.inputs.number }} - release_name: Release Candidate ${{ github.event.inputs.number }} (git ${{ steps.latest.outputs.sha_short }}) - draft: false - prerelease: false - body: | - ## 💾 Download link - This release candidate of Slimefun4 can be downloaded here: - https://blob.build/project/Slimefun4/RC - - ### ❓ How to install Slimefun - Simply drag & drop the Slimefun4 jar file into the `/plugins/` directory of your server. - If you need any help installing Slimefun, feel free to check out our wiki article on [How to install Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Installing-Slimefun). - - ## 📝 Change log - You can find a short summary of all the changes that are included in this release right here: - https://github.com/Slimefun/Slimefun4/blob/master/CHANGELOG.md#release-candidate-${{ github.event.inputs.number }}-${{ github.event.inputs.release_date }} - - ## 📦 Maven dependency reference - If you want to develop an addon for Slimefun ([Developer Reference](https://github.com/Slimefun/Slimefun4/wiki/Developer-Guide)), then you can build your project against this specific version of Slimefun using the following `pom.xml` dependency: - ```xml - - - jitpack.io - https://jitpack.io - - - - - - com.github.Slimefun - Slimefun4 - RC-${{ github.event.inputs.number }} - - - ``` diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml deleted file mode 100644 index 2702fbb6c8..0000000000 --- a/.github/workflows/sonarcloud.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: SonarCloud Scanner - -on: - pull_request: - types: [opened, synchronize, reopened] - -permissions: - contents: read - -jobs: - scan: - - name: SonarCloud Scanner - runs-on: ubuntu-latest - - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4.2.2 - with: - fetch-depth: 0 - - - name: Set up JDK 21 - uses: actions/setup-java@v4.6.0 - with: - distribution: 'adopt' - java-version: '21' - java-package: jdk - architecture: x64 - - - name: Cache SonarCloud packages - uses: actions/cache@v4 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - - name: Cache Maven packages - uses: actions/cache@v4 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: SonarCloud analysis - run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar - if: ${{ env.SONAR_TOKEN != 0 }} diff --git a/.github/workflows/translator-webhook.yml b/.github/workflows/translator-webhook.yml deleted file mode 100644 index ec8328f899..0000000000 --- a/.github/workflows/translator-webhook.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Translation Notifier - -on: - push: - branches: - - master - paths: - - 'src/main/resources/languages/en/**.yml' - -permissions: - contents: read - -jobs: - notify: - - name: Translation-Notifier - runs-on: ubuntu-latest - if: github.repository == 'Slimefun/Slimefun4' - - steps: - - name: Discord Notification - uses: Ilshidur/action-discord@master - with: - args: '<@&665202905271369776> New strings have been added to Slimefun4''s language files. You can translate them at https://crowdin.com/project/slimefun' - env: - DISCORD_WEBHOOK: ${{ secrets.TRANSLATOR_WEBHOOK }} diff --git a/.github/workflows/yaml-linter.yml b/.github/workflows/yaml-linter.yml deleted file mode 100644 index a1e22c99c5..0000000000 --- a/.github/workflows/yaml-linter.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: YAML Linter - -on: - push: - paths: - - '**.yml' - pull_request: - branches: - - master - -permissions: - contents: read - -jobs: - linter: - - name: YAML Linter - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: YAML Linter - uses: ibiqlik/action-yamllint@v3.1.1 - with: - config_file: '.github/configs/yaml-linter.yml' diff --git a/.gitignore b/.gitignore index a6d46cc670..67feadf855 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,25 @@ -/bin/ -/target/ -/plugins/ -/sonar/ -/.settings/ -/.idea/ -/.vscode/ -/data-storage/ -/javadocs/ +# Gradle +.gradle/ +build/ +out/ +bin/ +.idea/ +*.iml +*.iws -dependency-reduced-pom.xml +# MacOS +.DS_Store -.classpath -.factorypath -.project -*.iml -*.bak -.DS_Store \ No newline at end of file +# Temporary files +*.tmp +*.log + +# Server runtime (test server) +run/ + +# JVM crash artifacts +*.hprof +*.stackdump + +# Accidentally-committed server runtime data +/plugins/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 453eb54984..71cd21ba3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -130,7 +130,7 @@ * Fixed backpack dupe within cargo (#3379) ## Release Candidate 34 (20 Jun 2023) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#34 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#34 #### Additions * Added "Cobbled Deepslate -> Gravel" recipe to the Grind Stone @@ -171,7 +171,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#34 * Fixed #3414 ## Release Candidate 33 (07 Jan 2023) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#33 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#33 #### Additions * (API) Added Tinted Glass to "GLASS_BLOCKS" tag @@ -205,7 +205,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#33 * Fixed BlockPlacer being able to place disabled items ## Release Candidate 32 (26 Jun 2022) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#32 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#32 #### Additions * Added Organic Food for Seagrass @@ -224,7 +224,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#32 * Fixed an issue with machines being placed below y=0 ## Release Candidate 31 (14 Mar 2022) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#31 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#31 #### Additions * Added Armored Jetpack @@ -267,7 +267,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#31 * Fixed #3336 (again) ## Release Candidate 30 (31 Dec 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#30 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#30 #### Additions * Added a ton of wiki links to the guide @@ -289,7 +289,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#30 * Fixed (Easter) Apple Pie recipe yielding (Christmas) Apple Pies ## Release Candidate 29 (07 Nov 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#29 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#29 #### Additions * Added support for deepslate ores and copper with the Hercules' Pickaxe @@ -318,25 +318,25 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#29 * Fixed smithing table issue on 1.15 and lower ## Release Candidate 28 (06 Sep 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#28 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#28 #### Fixes * Fixed Metrics * Fixed some naming conventions and localization keys for RC-27 ## Release Candidate 27 (03 Sep 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#27 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#27 ### **Breaking Changes (API)** -This RC brings a lot of breaking changes to the API. For more info on why we did this and what happened [please refer to our PSA](https://github.com/Slimefun/Slimefun4/pull/3139) +This RC brings a lot of breaking changes to the API. For more info on why we did this and what happened [please refer to our PSA](https://github.com/Slimefun5/Slimefun5/pull/3139) * Category has been renamed to ItemGroup. -* All Category / ItemGroup variants have been relocated to `io.github.thebusybiscuit.slimefun4.api.items.groups` -* The SlimefunItem class has been relocated to `io.github.thebusybiscuit.slimefun4.api.items` -* The SlimefunItemStack class has been relocated to `io.github.thebusybiscuit.slimefun4.api.items` -* The ItemHandler class has been relocated to `io.github.thebusybiscuit.slimefun4.api.items` -* The RecipeType class has been relocated to `io.github.thebusybiscuit.slimefun4.api.recipes` -* Research classes have been moved from `io.github.thebusybiscuit.slimefun4.core.researching` to `io.github.thebusybiscuit.slimefun4.api.researches` +* All Category / ItemGroup variants have been relocated to `io.github.thebusybiscuit.slimefun5.api.items.groups` +* The SlimefunItem class has been relocated to `io.github.thebusybiscuit.slimefun5.api.items` +* The SlimefunItemStack class has been relocated to `io.github.thebusybiscuit.slimefun5.api.items` +* The ItemHandler class has been relocated to `io.github.thebusybiscuit.slimefun5.api.items` +* The RecipeType class has been relocated to `io.github.thebusybiscuit.slimefun5.api.recipes` +* Research classes have been moved from `io.github.thebusybiscuit.slimefun5.core.researching` to `io.github.thebusybiscuit.slimefun5.api.researches` * The main class `SlimefunPlugin` was renamed to `Slimefun` * CS-CoreLib2 was removed and replaced by dough @@ -373,7 +373,7 @@ This RC brings a lot of breaking changes to the API. For more info on why we did * Fixed Ender Lumps showing an incorrect recipe in the guide ## Release Candidate 26 (20 Jul 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#26 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#26 #### Additions * Diamonds can now be ground into Carbon using a Grind Stone @@ -395,7 +395,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#26 * Fixed #3136 ## Release Candidate 25 (20 Jun 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#25 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#25 #### Additions * Added "4 Charcoal -> 1 Coal" recipe to the Compressor @@ -424,7 +424,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#25 * Fixed #3116 ## Release Candidate 24 (03 Jun 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#24 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#24 #### Additions * (API) Added AsyncMachineOperationFinishEvent @@ -457,7 +457,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#24 * Fixed #3095 ## Release Candidate 23 (19 May 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#23 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#23 #### Additions * Added "Quartz Block -> 4 Quartz" recipe to Grind Stone @@ -505,7 +505,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#23 * Fixed #3060 ## Release Candidate 22 (18 Apr 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#22 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#22 #### Additions * Added Vanilla Auto-Crafter @@ -557,7 +557,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#22 * Fixed #2942 ## Release Candidate 21 (14 Mar 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#21 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#21 #### Additions * Nether Wart Blocks can now be turned into Nether Warts using a Grind Stone @@ -601,7 +601,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#21 * Fixed #2883 ## Release Candidate 20 (30 Jan 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#20 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#20 #### Additions * Added a new language: Bulgarian @@ -640,7 +640,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#20 * Fixed #2679 ## Release Candidate 19 (11 Jan 2021) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#19 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#19 #### Additions * Added Bee Armor (1.15+ only) @@ -667,7 +667,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#19 * Fixed #2675 ## Release Candidate 18 (03 Dec 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#18 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#18 #### Additions * The Smelters Pick now also works on Ancient Debris @@ -733,7 +733,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#18 * Fixed #2583 ## Release Candidate 17 (17 Oct 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#17 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#17 #### Additions * Added /sf charge @@ -806,7 +806,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#17 * Fixed a dupe bug with mcMMO ## Release Candidate 16 (07 Sep 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#16 #### Additions * Added an option for Industrial Miners to mine Ancient Debris @@ -894,7 +894,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 * Fixed Teleports getting stuck sometimes ## Release Candidate 15 (01 Aug 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#15 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#15 #### Additions * Added "Bone Block -> Bone meal" recipe to the Grind Stone @@ -949,7 +949,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#15 * Fixed #2166 ## Release Candidate 14 (12 Jul 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#14 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#14 #### Additions * Added support for Minecraft 1.16 @@ -1028,7 +1028,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#14 * Fixed a NullPointerException when Generators throw an Error Report ## Release Candidate 13 (16 Jun 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#13 #### Additions * Added Dried Kelp Blocks recipe to the Electric Press @@ -1079,7 +1079,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13 * Fixed research fireworks still dealing damage sometimes ## Release Candidate 12 (27 May 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#12 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#12 #### Additions * Added Ukrainian translations @@ -1124,7 +1124,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#12 * Fixed #1935 ## Release Candidate 11 (25 Apr 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#11 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#11 #### Additions * Added GEOResourceGenerationEvent @@ -1182,7 +1182,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#11 * Fixed GPS Emergency Transmitters not working ## Release Candidate 10 (28 Mar 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#10 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#10 #### Additions * Added some new charts to bStats @@ -1229,19 +1229,19 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#10 * Fixed #1768 ## Release Candidate 9 (07 Mar 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#9 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#9 #### Fixes * Fixed Solar Generators not working ## Release Candidate 8 (06 Mar 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#8 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#8 #### Fixes * Fixed bStats Metrics not sending properly ## Release Candidate 7 (06 Mar 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#7 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#7 #### Additions * Added translations for Recipe Types @@ -1265,7 +1265,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#7 * Fixed #1613 ## Release Candidate 6 (16 Feb 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#6 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#6 #### Additions * Added a new language: Japanese @@ -1284,7 +1284,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#6 * Fixed magician talisman not being able to enchant books ## Release Candidate 5 (09 Feb 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#5 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#5 #### Additions * Added preset messages.yml files @@ -1338,7 +1338,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#5 * Fixed Android Script Component textures ## Release Candidate 4 (06 Jan 2020) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#4 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#4 #### Additions * Added 1.15 support (1.14 and 1.15 are both supported) @@ -1414,7 +1414,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#4 * Fixed #1354 ## Release Candidate 3 (21 Nov 2019) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#3 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#3 #### Additions * Smeltery now shows some recipes in the guide @@ -1465,7 +1465,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#3 * Fixed Ancient Altar allowing you to craft locked items ## Release Candidate 2 (29 Sep 2019) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#2 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#2 #### Additions * Added GEO - Miner @@ -1482,6 +1482,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#2 * Fixed Auto-Updater for stable builds ## Release Candidate 1 (26 Sep 2019) -https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#1 +https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/#1 * First "stable" release since over a year. Stable builds will NOT receive support for bug reports since they are technically outdated. + diff --git a/CONTENT.md b/CONTENT.md new file mode 100644 index 0000000000..a209ee7d46 --- /dev/null +++ b/CONTENT.md @@ -0,0 +1,22 @@ +It offers everything you could possibly imagine, from Backpacks to Jetpacks! Slimefun lets every player decide on their own how much they want to dive into Magic or Tech. +We got everything from magical wands to nuclear reactors. +We feature a magical altar, an electric power grid and even item transport systems. + +## Features + +* Over 500+ New Items and Recipes +* Magic, Tech, and Utility features +* Extensive Addon Support (expand Slimefun with dozens of community addons) +* Multiblock Machines and Automated Crafting +* Energy Networks and Cargo Transport Systems + +## Addons + +Slimefun has a rich ecosystem of Addons developed by the community. You can find addons that add new dimensions, new machines, custom crops, and much more. + +## Compiling + +To build Slimefun from source, simply clone the repository and run: +```bash +./gradlew build +``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6e6d01d2e8..721ef0ae54 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,15 @@ # Contributing to Slimefun This document outlines various ways how you can help contribute to Slimefun and make this a bigger and better project.
-All contributions must be inline with our [Code of Conduct](https://github.com/Slimefun/Slimefun4/blob/master/.github/CODE_OF_CONDUCT.md) and [License](https://github.com/Slimefun/Slimefun4/blob/master/LICENSE). +All contributions must be inline with our [Code of Conduct](https://github.com/Slimefun5/Slimefun5/blob/master/.github/CODE_OF_CONDUCT.md) and [License](https://github.com/Slimefun5/Slimefun5/blob/master/LICENSE). Please also follow the templates for Issues and Pull Requests we provide. ## :beetle: 1. Issues: Bug Reports One of the foundations for good software is reliability. To facilitate this reliability, our community must work together to crush bugs that arise. This of course requires good information and knowledge about ongoing bugs and issues though. -You can help this project by reporting a bug on our [Issues Tracker](https://github.com/Slimefun/Slimefun4/issues).
+You can help this project by reporting a bug on our [Issues Tracker](https://github.com/Slimefun5/Slimefun5/issues).
Please adhere to the provided template and provide as much information as possible. -For more info on how to make good and helpful bug reports, check out our article on [How to report bugs](https://github.com/Slimefun/Slimefun4/wiki/How-to-report-bugs). +For more info on how to make good and helpful bug reports, check out our article on [How to report bugs](https://github.com/Slimefun5/Slimefun5/wiki/How-to-report-bugs). If you encounter an issue which has already been reported, please don't open a new one.
It would be awesome though if you could post a comment on the existing issue which explains how you were able to reproduce this yourself. @@ -17,10 +17,10 @@ The more context and information we get, the easier we can fix it. ## :hammer_and_wrench: 2. Pull Requests: Bug Fixes Bugs that have been reported need to be fixed of course.
-Any open Issue on our [Issues Tracker](https://github.com/Slimefun/Slimefun4/issues) is waiting to be fixed. +Any open Issue on our [Issues Tracker](https://github.com/Slimefun5/Slimefun5/issues) is waiting to be fixed. This is an Open-Source project and we love Pull Requests. -So if you have an idea on how to approach a known issue, feel free to make a [Pull Request](https://github.com/Slimefun/Slimefun4/pulls) which fixes this bug. +So if you have an idea on how to approach a known issue, feel free to make a [Pull Request](https://github.com/Slimefun5/Slimefun5/pulls) which fixes this bug. You can also comment on the existing Issue, proposing your idea or communicating that you wanna work on this. ## :wrench: 3. Pull Requests: Additions/Changes @@ -34,7 +34,7 @@ Suggestions which gotten enough votes will be moved to `#approved`. Therefore our `#approved` is a great place to start looking for ideas on what to add or change, since it will definitely be something a large number of people agree with. Also consider making an addon for your additions when they get too large, too abstract or too "niche". -You can check out our [Developer Guide](https://github.com/Slimefun/Slimefun4/wiki/Developer-Guide) for a guide on how to create a Slimefun addon.. +You can check out our [Developer Guide](https://github.com/Slimefun5/Slimefun5/wiki/Developer-Guide) for a guide on how to create a Slimefun addon.. ## :earth_africa: 4. Pull Requests: Translations Another great way to contribute to Slimefun is by working on translations for the project. @@ -46,7 +46,7 @@ One of our Language Moderators will review the changes and submit a Pull Request Very active community translators will have the option to become a "Language Moderator". Language Moderators are responsible for proof-reading any new translations for their designated language and correct it when they see a mistake. -For more info on how or what to translate, check out our article on [How to translate Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun). +For more info on how or what to translate, check out our article on [How to translate Slimefun](https://github.com/Slimefun5/Slimefun5/wiki/Translating-Slimefun). ## :scroll: 5. Pull Requests: Wiki contributions Slimefun is a very large project and might be quite intimidating for new players. @@ -55,12 +55,12 @@ If you have played with Slimefun for a while and gotten yourself familiar with h It would help out a lot :heart: You can find a tutorial on how to contribute to our wiki right here:
-https://github.com/Slimefun/Slimefun4/wiki/Expanding-the-Wiki +https://github.com/Slimefun5/Slimefun5/wiki/Expanding-the-Wiki ## :star: 6. Pull Requests: Code Quality -Slimefun uses [sonarcloud.io](https://sonarcloud.io/dashboard?id=Slimefun_Slimefun4) to monitor Code Quality. +Slimefun uses [sonarcloud.io](https://sonarcloud.io/dashboard?id=Slimefun_Slimefun5) to monitor Code Quality. -We always welcome quality improvements to the code and the "Code Smells" section on [sonarcloud.io](https://sonarcloud.io/dashboard?id=Slimefun_Slimefun4) is a great place to start. +We always welcome quality improvements to the code and the "Code Smells" section on [sonarcloud.io](https://sonarcloud.io/dashboard?id=Slimefun_Slimefun5) is a great place to start. But please keep in mind that some design patterns may not be changed too abruptly if an addon depends on them. To prevent any accidents from happening, please contact us on our [Discord Server](https://discord.gg/slimefun) before-hand and state your intended changes. @@ -70,21 +70,21 @@ Code documentation is also a great way to improve the maintainability of the pro 2. Classes should also include an `@author` tag to indicate who worked on that class. 3. Methods and parameters should be annotated with `@Nullable` or `@Nonnull` to indicate whether or not null values are accepted. -Feel free to visit our [Javadocs](https://slimefun.github.io/javadocs/Slimefun4/docs/overview-summary.html) +Feel free to visit our [Javadocs](https://slimefun.github.io/javadocs/Slimefun5/docs/overview-summary.html) #### Unit Tests Unit Tests help us test the project to work as intended in an automated manner.
-More or better Unit Tests are always good to have, so feel free to submit a Test and place it in our [src/test/java](https://github.com/Slimefun/Slimefun4/tree/master/src/test/java/io/github/thebusybiscuit/slimefun4/testing) directory +More or better Unit Tests are always good to have, so feel free to submit a Test and place it in our [src/test/java](https://github.com/Slimefun5/Slimefun5/tree/master/src/test/java/io/github/thebusybiscuit/slimefun5/testing) directory We are using [Junit 5 - Jupiter](https://github.com/junit-team/junit5/) and [MockBukkit](https://github.com/seeseemelk/MockBukkit) as our testing environment.
Every new Unit Test should have a `@DisplayName` annotation with a plain text description on what the Unit Test tests. -## :toolbox: How to compile Slimefun4 +## :toolbox: How to compile Slimefun5 Slimefun is written in Java and uses [Maven](https://maven.apache.org/) for compilation.
To compile Slimefun yourself, follow these steps: 1. Clone the project via git
-`$ git clone https://github.com/Slimefun/Slimefun4/` +`$ git clone https://github.com/Slimefun5/Slimefun5/` 2. Compile the project using Maven
`$ mvn clean package` 3. Extract the compiled `Slimefun-v4.X-UNOFFICIAL.jar` from your `/target/` directory. @@ -144,7 +144,7 @@ But do try to follow our code style as best as you can.* * Constants (`static final` fields) should be in *SCREAMING_SNAKE_CASE* (e.g. `MY_CONSTANT_FIELD`) * Variables, parameters and fields should be in *camelCase* (e.g. `myVariableOrField`) * All methods should be in *camelCase* (e.g. `myMethod`) -* Packages must be all lowercase, consecutive words should generally be avoided. (e.g. `io.github.thebusybiscuit.slimefun4.core.something`) +* Packages must be all lowercase, consecutive words should generally be avoided. (e.g. `io.github.thebusybiscuit.slimefun5.core.something`) #### 7. Style preferences * Use **Spaces**, not Tabs! * One class per file! Please don't put multiple classes into one file, this also applies to enums, make a seperate file for new classes or enums. @@ -200,3 +200,4 @@ private void example(int x) { } } ``` + diff --git a/README.md b/README.md deleted file mode 100644 index affc3ed96c..0000000000 --- a/README.md +++ /dev/null @@ -1,165 +0,0 @@ -# Slimefun 4 -*Looking for the download link? [**Click here**](https://github.com/Slimefun/Slimefun4/blob/master/README.md#floppy_disk-download-slimefun-4)* - -Slimefun is a plugin which aims to turn your Spigot Server into a modpack without ever installing a single mod. It offers everything you could possibly imagine. From Backpacks to Jetpacks! Slimefun lets every player decide on their own how much they want to dive into Magic or Tech.
-We got everything from magical wands to nuclear reactors.
-We feature a magical altar, an electric power grid and even item transport systems. - -This project originally started back **in 2013** and has grown ever since.
-From one single person working on this plugin back then, we grew to a community of thousands of players and hundreds of contributors to this project.
-It currently adds over **500 new items and recipes** to Minecraft ([Read more about the history of this project](https://github.com/Slimefun/Slimefun4/wiki/Slimefun-in-a-nutshell)). - -But it also comes with a lot of addons! Check out our [addons](https://github.com/Slimefun/Slimefun4/wiki/Addons), you may find exactly what you were looking for. - -### Quick navigation -* **[:floppy_disk: Download Slimefun4](#floppy_disk-download-slimefun-4)** -* **[:framed_picture: Screenshots](#framed_picture-screenshots)** -* **[:headphones: Discord Support Server](#headphones-discord)** -* **[:beetle: Bug Tracker](https://github.com/Slimefun/Slimefun4/issues)** -* **[:open_book: Wiki](https://github.com/Slimefun/Slimefun4/wiki)** -* **[:interrobang: FAQ](https://github.com/Slimefun/Slimefun4/wiki/FAQ)** -* **[:handshake: How to contribute](https://github.com/Slimefun/Slimefun4/blob/master/CONTRIBUTING.md)** - -## :floppy_disk: Download Slimefun 4 -Slimefun requires your Minecraft Server to be running on [Spigot](https://spigotmc.org/), [Paper](https://papermc.io/) or on any fork of these.
-(See also: [How to install Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Installing-Slimefun)) - -Slimefun 4 can be downloaded **for free** on our builds page.
-We currently provide two distinct versions of Slimefun, development builds and "stable" builds.
-Here is a full summary of the differences between the two different versions of Slimefun. - -| | development (latest) | "stable" | -| ------------------ | -------- | -------- | -| **Minecraft version(s)** | :video_game: **1.16.\* - 1.20.\*** | :video_game: **1.16.\* - 1.20.\*** | -| **Java version** | :computer: **Java 16 (or higher)** | :computer: **Java 16 (or higher)** | -| **automatic updates** | :heavy_check_mark: | :heavy_check_mark: | -| **frequent updates** | :heavy_check_mark: | :x: | -| **latest content** | :heavy_check_mark: | :x: | -| **Discord support** | :heavy_check_mark: | :x: | -| **Bug Reports** | :heavy_check_mark: | :x: | -| **testing before release** | :x: | :heavy_check_mark: | -| **change logs** | :x: | :memo: **[change log](https://github.com/Slimefun/Slimefun4/blob/master/CHANGELOG.md)** | -| **Download links** | :floppy_disk: **[download latest](https://blob.build/project/Slimefun4/Dev)** | :floppy_disk: **[download "stable"](https://blob.build/project/Slimefun4/RC)** | - -**:exclamation: We wholeheartedly recommend you to use _development builds_, they are the most recent version of Slimefun and also receive the most frequent updates! In fact, "stable" builds are so outdated that we won't accept bug reports from them at all.** -
- Here's why... - -"Stable" builds do not receive frequent updates or fast patches. As time goes on, bugs are fixed but it will take some time until these fixes make it into a "stable" build. We will also not accept or review any bug reports from "stable" builds. They are in fact just old development builds that seemed to run fine without any __major__ issues. - -**:question: Why use a "stable" build then?**
-While "stable" builds most definitely contain more bugs than development builds due to their very slow update schedule. you can be sure that they will not include __game-breaking__ issues, but rest assured that development builds almost never contain such issues either. If your server or business however heavily depends on a version of Slimefun that does not change/update a lot, you are forgiven if you choose the "stable" branch. But development builds will bring you the best experience, both in terms of features and bug fixes. - -**:question: What exactly are these "stable" builds then and why do you put them in quotes?**
-"Stable" builds are literally just outdated development builds that seemed to run fine without any __major__ issues. But they are far from bug-free hence why actually calling them stable would be hypocritical. However these builds can only really stay "stable" if there are enough people using development builds and report any bugs they come across. Otherwise potential issues may go unnoticed and slip into a "stable" build. Again, we really recommend you to choose the development builds. But since a few people really wanted "stable" builds, they are now an option too. - -
- -## :framed_picture: Screenshots -So what does Slimefun look like?
-Well, we asked some users on our [Discord server](#headphones-discord) to send us some screenshots, so see for yourself: -| Reactors and electricity | Awesome factories | Magic and Altars | -| :-------------------------------------------: | :--------------------------------------: | :----------------------------------------: | -| ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase1.png) | ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase6.png) | ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase5.png) | -| *Screenshot provided by HamtaBot#0001* | *Screenshot provided by Piͭxͪeͤl (mnb)#5049* | *Screenshot provided by Kilaruna#4981* | -| ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase4.png) | ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase3.png) | ![](https://raw.githubusercontent.com/Slimefun/Slimefun-Wiki/master/images/showcase2.png) | -| *Screenshot provided by GalaxyKat11#3816* | *Screenshot provided by TamThan#7987* | *Screenshot provided by Kilaruna#4981* | - -## :headphones: Discord -You can find Slimefun's community on Discord and connect with **over 7000** users of this plugin from all over the world.
-Click the badge down below to join the server for suggestions/questions or other discussions about this plugin.
-We are also hosting a community event every so often, join us to find out more.
-**Important: We don't accept bug reports on discord, please use our [Issue Tracker](https://github.com/Slimefun/Slimefun4/issues) to submit bug reports!** - -Due to the sheer size of this discord server, we need to enforce some [important rules](https://github.com/Slimefun/Slimefun4/wiki/Discord-Rules).
-Not following these rules can lead to a kick or even a ban from the server. - -

- - Discord Invite - -

- -## :open_book: Wiki -Slimefun has a (detailed and well-maintained - *cough*) Wiki for new players, maybe also consider -expanding the wiki to help grow our community and help out new users of this plugin. -https://github.com/Slimefun/Slimefun4/wiki - -#### :star: Highlighted Articles -* [What is Slimefun?](https://github.com/Slimefun/Slimefun4/wiki/Slimefun-in-a-nutshell) -* [How to install Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Installing-Slimefun) -* [Addons for Slimefun 4](https://github.com/Slimefun/Slimefun4/wiki/Addons) -* [How to create an Addon for Slimefun 4](https://github.com/Slimefun/Slimefun4/wiki/Developer-Guide) -* [Getting Started](https://github.com/Slimefun/Slimefun4/wiki/Getting-Started) -* [Frequently Asked Questions](https://github.com/Slimefun/Slimefun4/wiki/FAQ) -* [Common issues](https://github.com/Slimefun/Slimefun4/wiki/Common-Issues) -* [Help us expand the Wiki!](https://github.com/Slimefun/Slimefun4/wiki/Expanding-the-Wiki) -* [Help us translate Slimefun!](https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun) - -The wiki is entirely community-run, so if you find an article missing, feel free to write one and share it with others. - -## :handshake: Contributing to this project -Slimefun 4 is an Open-Source project and licensed under -[GNU GPLv3](https://github.com/Slimefun/Slimefun4/blob/master/LICENSE).
-**Over 200 people have already contributed to this amazing project. You guys are awesome! :heart:**
-Please consider helping us maintain this project too, your engagement keeps the project alive! - -You can find more info on how to contribute to this project in our [CONTRIBUTING.md](https://github.com/Slimefun/Slimefun4/blob/master/CONTRIBUTING.md). - -## :exclamation: Disclaimers -Slimefun4 uses various systems that collect usage information or download automatic updates as well as the latest information about the project. -We do not collect any personal information from you but there are some services that may gather or download some form of data. - -You can opt-out of the Auto-Updater and stats collection at any time! - -
- Automatic updates - -Slimefun4 uses an Auto-Updater which connects to https://thebusybiscuit.github.io/builds/ to check for and download updates.
-This behaviour is enabled by default but can be turned off under `/plugins/Slimefun/config.yml`.
-We highly recommend you to keep this on at any time though, as you could be missing out on important patches. -
- -
- Metrics and Statistics - -Slimefun4 uses [bStats](https://bstats.org/plugin/bukkit/Slimefun/4574) to collect anonymous information about the usage of this plugin.
-This is solely for statistical purposes, as we are interested in how Servers/Players use this plugin.
-All available data is anonymous and aggregated, at no point can we see individual server or player information.
-All of the collected data is publicly accessible: https://bstats.org/plugin/bukkit/Slimefun/4574 - -You can also disable this behaviour under `/plugins/bStats/config.yml`.
-For more info see [bStats' Privacy Policy](https://bstats.org/privacy-policy) - -Our [bStats Module](https://github.com/Slimefun/MetricsModule) is downloaded automatically when installing this Plugin, this module will automatically update on server starts independently from the main plugin. This way we can automatically roll out updates to the bStats module, in cases of severe performance issues for example where live data and insight into what is impacting performance can be crucial. -These updates can of course be disabled under `/plugins/Slimefun/config.yml`. To disable metrics collection as a whole, see the paragraph above. - ---- - -Slimefun also uses its own analytics system to collect anonymous information about the performance of this plugin.
-This is solely for statistical purposes, as we are interested in how it's performing for all servers.
-All available data is anonymous and aggregated, at no point can we see individual server information.
- -You can also disable this behaviour under `/plugins/Slimefun/config.yml`.
- -
- -
- GitHub Integration - -Lastly, Slimefun4 connects to https://api.github.com/ to gather information about this open-source project.
-No information about you or your Minecraft Server is sent to GitHub. - -This information includes (but is not limited to) -* list of contributors, their username and profile link (from the repositories `Slimefun/Slimefun4`, `Slimefun/Slimefun-Wiki` and `Slimefun/Resourcepack`) -* amount of open issues in this repository -* amount of pending pull requests in this repository -* amount of stars in this repository -* amount of forks of this repository -* amount of code-bytes in this repository -* date of the last commit to this repository -
- -Additionally the plugin connects to [textures.minecraft.net](https://www.minecraft.net/en-us) to retrieve the Minecraft skins of our contributors (if possible).
- -*Note that Slimefun is not associated with `Mojang Studios` or `Minecraft`.* diff --git a/compat-api/build.gradle.kts b/compat-api/build.gradle.kts new file mode 100644 index 0000000000..f66d13c155 --- /dev/null +++ b/compat-api/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + java +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + +repositories { + mavenCentral() + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") + maven("https://oss.sonatype.org/content/repositories/snapshots") +} + +dependencies { + compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT") { + isTransitive = false + } +} diff --git a/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFBlock.java b/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFBlock.java new file mode 100644 index 0000000000..8ba2dc581a --- /dev/null +++ b/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFBlock.java @@ -0,0 +1,103 @@ +package io.github.thebusybiscuit.slimefun5.compat; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; +import org.bukkit.material.Directional; + +import java.lang.reflect.Method; + +public class SFBlock { + + private final Block block; + + private static Method getBlockDataMethod; + private static Method setBlockDataMethod; + private static Class blockDataClass; + private static Class directionalClass; + private static Method getFacingMethod; + private static Method setFacingMethod; + + private static boolean isModern; + + static { + try { + blockDataClass = Class.forName("org.bukkit.block.data.BlockData"); + directionalClass = Class.forName("org.bukkit.block.data.Directional"); + getBlockDataMethod = Block.class.getMethod("getBlockData"); + setBlockDataMethod = Block.class.getMethod("setBlockData", blockDataClass); + getFacingMethod = directionalClass.getMethod("getFacing"); + setFacingMethod = directionalClass.getMethod("setFacing", BlockFace.class); + isModern = true; + } catch (Exception e) { + isModern = false; + } + } + + public SFBlock(Block block) { + this.block = block; + } + + public Block getBlock() { + return block; + } + + @SuppressWarnings("deprecation") + public void setType(SFMaterial material) { + Material mat = material.toMaterial(); + if (mat == null) return; + + block.setType(mat); + + if (!isModern) { + byte legacyData = material.getLegacyData(); + if (legacyData != 0) { + block.setData(legacyData); + } + } + } + + @SuppressWarnings("deprecation") + public BlockFace getFacing() { + if (isModern) { + try { + Object blockData = getBlockDataMethod.invoke(block); + if (directionalClass.isInstance(blockData)) { + return (BlockFace) getFacingMethod.invoke(blockData); + } + } catch (Exception e) { + // Ignore + } + } else { + BlockState state = block.getState(); + if (state.getData() instanceof Directional) { + return ((Directional) state.getData()).getFacing(); + } + } + return BlockFace.SELF; + } + + @SuppressWarnings("deprecation") + public void setFacing(BlockFace face) { + if (isModern) { + try { + Object blockData = getBlockDataMethod.invoke(block); + if (directionalClass.isInstance(blockData)) { + setFacingMethod.invoke(blockData, face); + setBlockDataMethod.invoke(block, blockData); + } + } catch (Exception e) { + // Ignore + } + } else { + BlockState state = block.getState(); + if (state.getData() instanceof Directional) { + Directional dir = (Directional) state.getData(); + dir.setFacingDirection(face); + state.setData((org.bukkit.material.MaterialData) dir); + state.update(true); + } + } + } +} diff --git a/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFItemStack.java b/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFItemStack.java new file mode 100644 index 0000000000..f837120b49 --- /dev/null +++ b/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFItemStack.java @@ -0,0 +1,75 @@ +package io.github.thebusybiscuit.slimefun5.compat; + +import java.lang.reflect.Method; +import java.util.List; + +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class SFItemStack { + + private final ItemStack item; + + private static Method setCustomModelDataMethod; + private static Method setLocalizedNameMethod; + + static { + try { + setCustomModelDataMethod = ItemMeta.class.getMethod("setCustomModelData", Integer.class); + } catch (NoSuchMethodException | SecurityException e) { + // Ignore + } + try { + setLocalizedNameMethod = ItemMeta.class.getMethod("setLocalizedName", String.class); + } catch (NoSuchMethodException | SecurityException e) { + // Ignore + } + } + + public SFItemStack(ItemStack item) { + this.item = item; + } + + public ItemStack getItem() { + return item; + } + + public SFItemStack setLocalizedName(String name) { + if (item != null && item.getItemMeta() != null) { + ItemMeta meta = item.getItemMeta(); + if (setLocalizedNameMethod != null) { + try { + setLocalizedNameMethod.invoke(meta, name); + item.setItemMeta(meta); + } catch (Exception e) { + // Ignore + } + } + } + return this; + } + + public SFItemStack setLore(List lore) { + if (item != null && item.getItemMeta() != null) { + ItemMeta meta = item.getItemMeta(); + meta.setLore(lore); + item.setItemMeta(meta); + } + return this; + } + + public SFItemStack setCustomModelData(Integer data) { + if (item != null && item.getItemMeta() != null) { + ItemMeta meta = item.getItemMeta(); + if (setCustomModelDataMethod != null) { + try { + setCustomModelDataMethod.invoke(meta, data); + item.setItemMeta(meta); + } catch (Exception e) { + // Ignore + } + } + } + return this; + } +} diff --git a/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFMaterial.java b/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFMaterial.java new file mode 100644 index 0000000000..e05ba68a93 --- /dev/null +++ b/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SFMaterial.java @@ -0,0 +1,147 @@ +package io.github.thebusybiscuit.slimefun5.compat; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * An abstraction to bridge legacy 1.8 data values (e.g., WOOL:14) + * to modern 1.13+ flattened materials (e.g., RED_WOOL). + */ +public enum SFMaterial { + + // Wools + WHITE_WOOL("WOOL", 0, "WHITE_WOOL"), + ORANGE_WOOL("WOOL", 1, "ORANGE_WOOL"), + MAGENTA_WOOL("WOOL", 2, "MAGENTA_WOOL"), + LIGHT_BLUE_WOOL("WOOL", 3, "LIGHT_BLUE_WOOL"), + YELLOW_WOOL("WOOL", 4, "YELLOW_WOOL"), + LIME_WOOL("WOOL", 5, "LIME_WOOL"), + PINK_WOOL("WOOL", 6, "PINK_WOOL"), + GRAY_WOOL("WOOL", 7, "GRAY_WOOL"), + LIGHT_GRAY_WOOL("WOOL", 8, "LIGHT_GRAY_WOOL"), + CYAN_WOOL("WOOL", 9, "CYAN_WOOL"), + PURPLE_WOOL("WOOL", 10, "PURPLE_WOOL"), + BLUE_WOOL("WOOL", 11, "BLUE_WOOL"), + BROWN_WOOL("WOOL", 12, "BROWN_WOOL"), + GREEN_WOOL("WOOL", 13, "GREEN_WOOL"), + RED_WOOL("WOOL", 14, "RED_WOOL"), + BLACK_WOOL("WOOL", 15, "BLACK_WOOL"), + + // Wood + OAK_LOG("LOG", 0, "OAK_LOG"), + SPRUCE_LOG("LOG", 1, "SPRUCE_LOG"), + BIRCH_LOG("LOG", 2, "BIRCH_LOG"), + JUNGLE_LOG("LOG", 3, "JUNGLE_LOG"), + ACACIA_LOG("LOG_2", 0, "ACACIA_LOG"), + DARK_OAK_LOG("LOG_2", 1, "DARK_OAK_LOG"), + + // Ores + IRON_ORE("IRON_ORE", 0, "IRON_ORE"), + GOLD_ORE("GOLD_ORE", 0, "GOLD_ORE"), + DIAMOND_ORE("DIAMOND_ORE", 0, "DIAMOND_ORE"), + EMERALD_ORE("EMERALD_ORE", 0, "EMERALD_ORE"), + COAL_ORE("COAL_ORE", 0, "COAL_ORE"), + + // Dyes + INK_SAC("INK_SACK", 0, "INK_SAC"), + ROSE_RED("INK_SACK", 1, "ROSE_RED"), + CACTUS_GREEN("INK_SACK", 2, "CACTUS_GREEN"), + COCOA_BEANS("INK_SACK", 3, "COCOA_BEANS"), + LAPIS_LAZULI("INK_SACK", 4, "LAPIS_LAZULI"), + PURPLE_DYE("INK_SACK", 5, "PURPLE_DYE"), + CYAN_DYE("INK_SACK", 6, "CYAN_DYE"), + LIGHT_GRAY_DYE("INK_SACK", 7, "LIGHT_GRAY_DYE"), + GRAY_DYE("INK_SACK", 8, "GRAY_DYE"), + PINK_DYE("INK_SACK", 9, "PINK_DYE"), + LIME_DYE("INK_SACK", 10, "LIME_DYE"), + DANDELION_YELLOW("INK_SACK", 11, "DANDELION_YELLOW"), + LIGHT_BLUE_DYE("INK_SACK", 12, "LIGHT_BLUE_DYE"), + MAGENTA_DYE("INK_SACK", 13, "MAGENTA_DYE"), + ORANGE_DYE("INK_SACK", 14, "ORANGE_DYE"), + BONE_MEAL("INK_SACK", 15, "BONE_MEAL"); + + private final String legacyName; + private final byte legacyData; + private final String modernName; + + private Material cachedMaterial = null; + private boolean initialized = false; + private boolean isLegacy = false; + + SFMaterial(String legacyName, int legacyData, String modernName) { + this.legacyName = legacyName; + this.legacyData = (byte) legacyData; + this.modernName = modernName; + } + + public String getLegacyName() { + return legacyName; + } + + public byte getLegacyData() { + return legacyData; + } + + public String getModernName() { + return modernName; + } + + /** + * Resolves the correct Bukkit Material for the current server version. + * + * @return The modern Material if available, otherwise the legacy Material. + */ + public Material toMaterial() { + if (initialized) { + return cachedMaterial; + } + + try { + cachedMaterial = Material.valueOf(modernName); + isLegacy = false; + } catch (IllegalArgumentException e) { + try { + cachedMaterial = Material.valueOf(legacyName); + isLegacy = true; + } catch (IllegalArgumentException e2) { + cachedMaterial = null; + } + } + + initialized = true; + return cachedMaterial; + } + + /** + * Creates an ItemStack of the given amount safely applying legacy data values if necessary. + * + * @param amount The size of the stack + * @return A valid ItemStack for the current server version + */ + @SuppressWarnings("deprecation") + public ItemStack toItemStack(int amount) { + Material mat = toMaterial(); + if (mat == null) { + return null; + } + + ItemStack item = new ItemStack(mat, amount); + + // If we fell back to the legacy material, we must apply the byte data / durability + // to get the correct variant (e.g. Red Wool instead of White Wool). + if (isLegacy && !legacyName.equals(modernName)) { + item.setDurability(legacyData); + } + + return item; + } + + /** + * Creates a single ItemStack of this material. + * + * @return A valid ItemStack for the current server version + */ + public ItemStack toItemStack() { + return toItemStack(1); + } +} \ No newline at end of file diff --git a/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SlimefunNMS.java b/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SlimefunNMS.java new file mode 100644 index 0000000000..ee8c7392ec --- /dev/null +++ b/compat-api/src/main/java/io/github/thebusybiscuit/slimefun5/compat/SlimefunNMS.java @@ -0,0 +1,46 @@ +package io.github.thebusybiscuit.slimefun5.compat; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; + +/** + * The central SlimefunNMS interface defining abstract methods for operations + * that require version-specific NMS code. + */ +public interface SlimefunNMS { + + /** + * Gets a String from the NBT tag of an ItemStack. + * + * @param item The ItemStack to read from + * @param key The key of the NBT tag + * @return The String value or null if it does not exist + */ + String getNBTString(ItemStack item, String key); + + /** + * Sets a String in the NBT tag of an ItemStack. + * + * @param item The ItemStack to write to + * @param key The key of the NBT tag + * @param value The value to write + * @return The modified ItemStack + */ + ItemStack setNBTString(ItemStack item, String key, String value); + + /** + * Sets a Block to a specific Material without triggering block physics. + * + * @param block The Block to update + * @param material The Material to set + */ + void setBlockTypeFast(Block block, Material material); + + /** + * Breaks a Block without triggering block physics. + * + * @param block The Block to break + */ + void breakBlockFast(Block block); +} \ No newline at end of file diff --git a/compat-stubs/build.gradle.kts b/compat-stubs/build.gradle.kts new file mode 100644 index 0000000000..be4cc92c43 --- /dev/null +++ b/compat-stubs/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + java +} + +java { + toolchain { + // Match the core Java 8 floor. + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + +repositories { + mavenCentral() + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") +} + +dependencies { + // The NamespacedKey(Plugin, String) ctor references org.bukkit.plugin.Plugin, which exists in 1.8.8. + compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT") { + isTransitive = false + } +} diff --git a/compat-stubs/src/main/java/io/papermc/paper/inventory/ItemRarity.java b/compat-stubs/src/main/java/io/papermc/paper/inventory/ItemRarity.java new file mode 100644 index 0000000000..313807e8df --- /dev/null +++ b/compat-stubs/src/main/java/io/papermc/paper/inventory/ItemRarity.java @@ -0,0 +1,12 @@ +package io.papermc.paper.inventory; + +/** + * Compile-only shadow stub of Paper's {@code io.papermc.paper.inventory.ItemRarity}. + * Not shaded; the real enum is used on modern Paper at runtime. Constants mirror Paper's. + */ +public enum ItemRarity { + COMMON, + UNCOMMON, + RARE, + EPIC; +} diff --git a/compat-stubs/src/main/java/io/papermc/paper/inventory/tooltip/TooltipContext.java b/compat-stubs/src/main/java/io/papermc/paper/inventory/tooltip/TooltipContext.java new file mode 100644 index 0000000000..0da8cc4607 --- /dev/null +++ b/compat-stubs/src/main/java/io/papermc/paper/inventory/tooltip/TooltipContext.java @@ -0,0 +1,8 @@ +package io.papermc.paper.inventory.tooltip; + +/** + * Compile-only shadow stub of Paper's {@code io.papermc.paper.inventory.tooltip.TooltipContext}. + * Not shaded; the real type is used on modern Paper at runtime. + */ +public interface TooltipContext { +} diff --git a/compat-stubs/src/main/java/io/papermc/paper/registry/set/RegistryKeySet.java b/compat-stubs/src/main/java/io/papermc/paper/registry/set/RegistryKeySet.java new file mode 100644 index 0000000000..458b9b8aa1 --- /dev/null +++ b/compat-stubs/src/main/java/io/papermc/paper/registry/set/RegistryKeySet.java @@ -0,0 +1,10 @@ +package io.papermc.paper.registry.set; + +/** + * Compile-only shadow stub of Paper's {@code io.papermc.paper.registry.set.RegistryKeySet}. + * Not shaded; the real type is used on modern Paper at runtime. + * + * @param the registry value type + */ +public interface RegistryKeySet { +} diff --git a/compat-stubs/src/main/java/net/kyori/adventure/text/Component.java b/compat-stubs/src/main/java/net/kyori/adventure/text/Component.java new file mode 100644 index 0000000000..2515a31d22 --- /dev/null +++ b/compat-stubs/src/main/java/net/kyori/adventure/text/Component.java @@ -0,0 +1,11 @@ +package net.kyori.adventure.text; + +/** + * Compile-only shadow stub of Adventure's {@code net.kyori.adventure.text.Component}. + *

+ * Core compiles against the 1.8.8 floor where Adventure is absent. This {@code compileOnly} stub lets + * the Adventure-typed methods compile; it is NOT shaded, so on modern Paper the real Component is used + * at runtime (full feature parity). On legacy servers these methods simply are not callable. + */ +public interface Component { +} diff --git a/compat-stubs/src/main/java/net/kyori/adventure/text/event/HoverEvent.java b/compat-stubs/src/main/java/net/kyori/adventure/text/event/HoverEvent.java new file mode 100644 index 0000000000..7d42042ab4 --- /dev/null +++ b/compat-stubs/src/main/java/net/kyori/adventure/text/event/HoverEvent.java @@ -0,0 +1,14 @@ +package net.kyori.adventure.text.event; + +/** + * Compile-only shadow stub of Adventure's {@code net.kyori.adventure.text.event.HoverEvent}. + * Not shaded; the real type is used on modern Paper at runtime. See {@code net.kyori.adventure.text.Component}. + * + * @param the hover value type + */ +public interface HoverEvent { + + /** Stub of {@code HoverEvent.ShowItem}. */ + interface ShowItem { + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/Axis.java b/compat-stubs/src/main/java/org/bukkit/Axis.java new file mode 100644 index 0000000000..174f3a194d --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/Axis.java @@ -0,0 +1,11 @@ +package org.bukkit; + +/** + * Compile-only stub for {@code org.bukkit.Axis} (added in Minecraft 1.13). Not shaded; on modern + * servers the real enum is used at runtime. + */ +public enum Axis { + X, + Y, + Z; +} diff --git a/compat-stubs/src/main/java/org/bukkit/Keyed.java b/compat-stubs/src/main/java/org/bukkit/Keyed.java new file mode 100644 index 0000000000..0e08bbb45a --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/Keyed.java @@ -0,0 +1,13 @@ +package org.bukkit; + +/** + * Compile-only shadow stub of Bukkit's {@code org.bukkit.Keyed} (introduced in MC 1.12). + *

+ * See {@link NamespacedKey} for the rationale. This is a {@code compileOnly} dependency and is not + * shaded into the jar. Note: classes that {@code implements Keyed} will fail to class-load on + * 1.8–1.11 servers (the interface is absent at runtime); those are handled in the version layer. + */ +public interface Keyed { + + NamespacedKey getKey(); +} diff --git a/compat-stubs/src/main/java/org/bukkit/Nameable.java b/compat-stubs/src/main/java/org/bukkit/Nameable.java new file mode 100644 index 0000000000..451d59dc74 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/Nameable.java @@ -0,0 +1,12 @@ +package org.bukkit; + +/** + * Compile-only stub for {@code org.bukkit.Nameable} (Minecraft 1.12+). Not shaded; on modern servers + * the real interface is used at runtime. + */ +public interface Nameable { + + String getCustomName(); + + void setCustomName(String name); +} diff --git a/compat-stubs/src/main/java/org/bukkit/NamespacedKey.java b/compat-stubs/src/main/java/org/bukkit/NamespacedKey.java new file mode 100644 index 0000000000..a9884a3be4 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/NamespacedKey.java @@ -0,0 +1,67 @@ +package org.bukkit; + +import org.bukkit.plugin.Plugin; + +/** + * Compile-only shadow stub of Bukkit's {@code org.bukkit.NamespacedKey} (introduced in MC 1.12). + *

+ * Slimefun's core compiles against the 1.8.8 API floor, where this type does not exist. This stub + * exposes only the surface that core uses so the code compiles. It is supplied through a + * {@code compileOnly} dependency and is not shaded into the jar: on 1.12+ servers + * the server's real {@code NamespacedKey} is used at runtime. On 1.8–1.11 the type is absent at + * runtime, so any code path touching it must be guarded by the version layer. + *

+ * The method and constructor signatures mirror Bukkit's exactly so bytecode compiled against this + * stub binds to the real class at runtime. + */ +public final class NamespacedKey { + + private final String namespace; + private final String key; + + public NamespacedKey(Plugin owner, String key) { + this.namespace = owner == null ? "minecraft" : owner.getName().toLowerCase(); + this.key = key; + } + + public NamespacedKey(String namespace, String key) { + this.namespace = namespace; + this.key = key; + } + + public static NamespacedKey minecraft(String key) { + return new NamespacedKey("minecraft", key); + } + + public String getNamespace() { + return namespace; + } + + public String getKey() { + return key; + } + + @Override + public int hashCode() { + return (namespace + ":" + key).hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (!(obj instanceof NamespacedKey)) { + return false; + } + + NamespacedKey other = (NamespacedKey) obj; + return namespace.equals(other.namespace) && key.equals(other.key); + } + + @Override + public String toString() { + return namespace + ":" + key; + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/Particle.java b/compat-stubs/src/main/java/org/bukkit/Particle.java new file mode 100644 index 0000000000..c1a07a0abf --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/Particle.java @@ -0,0 +1,51 @@ +package org.bukkit; + +/** + * Compile-only shadow stub of Bukkit's {@code org.bukkit.Particle} (introduced in MC 1.9). + *

+ * Core compiles against the 1.8.8 API floor where this type does not exist. This stub exposes only + * the constants and the {@link DustOptions} nested type that Slimefun core references directly, so + * the code compiles. It is a {@code compileOnly} dependency and is NOT shaded into the jar: on 1.9+ + * servers the server's real {@code Particle} is used at runtime (resolved by name, so differing enum + * ordinals are irrelevant). On 1.8 the type is absent at runtime, so particle code paths must be + * version-guarded (particles are a 1.9+ feature with no Bukkit API equivalent on 1.8). + *

+ * Constants are the post-1.20.5 names used directly in source; older-named variants are resolved + * reflectively at runtime by {@code VersionedParticle}. + */ +public enum Particle { + + DUST, + SMOKE, + HAPPY_VILLAGER, + ENCHANTED_HIT, + EXPLOSION, + WITCH, + FIREWORK, + ENCHANT, + PORTAL, + HEART, + CRIMSON_SPORE; + + /** + * Stub of {@code Particle.DustOptions} (the colored-dust data object). Signatures mirror Bukkit's. + */ + public static class DustOptions { + + private final Color color; + private final float size; + + public DustOptions(Color color, float size) { + this.color = color; + this.size = size; + } + + public Color getColor() { + return color; + } + + public float getSize() { + return size; + } + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/TileState.java b/compat-stubs/src/main/java/org/bukkit/block/TileState.java new file mode 100644 index 0000000000..2b4e241ae2 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/TileState.java @@ -0,0 +1,11 @@ +package org.bukkit.block; + +import org.bukkit.persistence.PersistentDataHolder; + +/** + * Compile-only stub for {@code org.bukkit.block.TileState} (Minecraft 1.14+). Not shaded; on modern + * servers the real interface is used at runtime. Mirrors the real hierarchy ({@code extends BlockState, + * PersistentDataHolder}) so {@code instanceof}/casts and {@code getPersistentDataContainer()} resolve. + */ +public interface TileState extends BlockState, PersistentDataHolder { +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/Ageable.java b/compat-stubs/src/main/java/org/bukkit/block/data/Ageable.java new file mode 100644 index 0000000000..e144379adf --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/Ageable.java @@ -0,0 +1,14 @@ +package org.bukkit.block.data; + +/** + * Compile-only stub for {@code org.bukkit.block.data.Ageable} (Minecraft 1.13+). Signatures match the + * real interface so calls resolve at runtime on modern servers. + */ +public interface Ageable extends BlockData { + + int getAge(); + + void setAge(int age); + + int getMaximumAge(); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/BlockData.java b/compat-stubs/src/main/java/org/bukkit/block/data/BlockData.java new file mode 100644 index 0000000000..1a6f8a21ec --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/BlockData.java @@ -0,0 +1,13 @@ +package org.bukkit.block.data; + +/** + * Compile-only stub for {@code org.bukkit.block.data.BlockData} (added in Minecraft 1.13). Not + * shaded; on modern servers the real interface is used at runtime. Declared as a marker — concrete + * methods live on the sub-interfaces that Slimefun actually calls. + */ +public interface BlockData { + + org.bukkit.Material getMaterial(); + + boolean isSupported(org.bukkit.block.Block block); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/Directional.java b/compat-stubs/src/main/java/org/bukkit/block/data/Directional.java new file mode 100644 index 0000000000..8499c40aa6 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/Directional.java @@ -0,0 +1,13 @@ +package org.bukkit.block.data; + +import org.bukkit.block.BlockFace; + +/** + * Compile-only stub for {@code org.bukkit.block.data.Directional} (Minecraft 1.13+). + */ +public interface Directional extends BlockData { + + BlockFace getFacing(); + + void setFacing(BlockFace facing); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/Levelled.java b/compat-stubs/src/main/java/org/bukkit/block/data/Levelled.java new file mode 100644 index 0000000000..549fbb94a9 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/Levelled.java @@ -0,0 +1,13 @@ +package org.bukkit.block.data; + +/** + * Compile-only stub for {@code org.bukkit.block.data.Levelled} (Minecraft 1.13+). + */ +public interface Levelled extends BlockData { + + int getLevel(); + + void setLevel(int level); + + int getMaximumLevel(); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/Orientable.java b/compat-stubs/src/main/java/org/bukkit/block/data/Orientable.java new file mode 100644 index 0000000000..c2e7e10b43 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/Orientable.java @@ -0,0 +1,13 @@ +package org.bukkit.block.data; + +import org.bukkit.Axis; + +/** + * Compile-only stub for {@code org.bukkit.block.data.Orientable} (Minecraft 1.13+). + */ +public interface Orientable extends BlockData { + + Axis getAxis(); + + void setAxis(Axis axis); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/Rotatable.java b/compat-stubs/src/main/java/org/bukkit/block/data/Rotatable.java new file mode 100644 index 0000000000..b0b3baad71 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/Rotatable.java @@ -0,0 +1,13 @@ +package org.bukkit.block.data; + +import org.bukkit.block.BlockFace; + +/** + * Compile-only stub for {@code org.bukkit.block.data.Rotatable} (Minecraft 1.13+). + */ +public interface Rotatable extends BlockData { + + BlockFace getRotation(); + + void setRotation(BlockFace rotation); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/Waterlogged.java b/compat-stubs/src/main/java/org/bukkit/block/data/Waterlogged.java new file mode 100644 index 0000000000..b8be5fc311 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/Waterlogged.java @@ -0,0 +1,11 @@ +package org.bukkit.block.data; + +/** + * Compile-only stub for {@code org.bukkit.block.data.Waterlogged} (Minecraft 1.13+). + */ +public interface Waterlogged extends BlockData { + + boolean isWaterlogged(); + + void setWaterlogged(boolean waterlogged); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/type/Dispenser.java b/compat-stubs/src/main/java/org/bukkit/block/data/type/Dispenser.java new file mode 100644 index 0000000000..74faf57567 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/type/Dispenser.java @@ -0,0 +1,9 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Directional; + +/** + * Compile-only stub for {@code org.bukkit.block.data.type.Dispenser} (Minecraft 1.13+). + */ +public interface Dispenser extends Directional { +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/type/Farmland.java b/compat-stubs/src/main/java/org/bukkit/block/data/type/Farmland.java new file mode 100644 index 0000000000..a70cdc093a --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/type/Farmland.java @@ -0,0 +1,15 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.BlockData; + +/** + * Compile-only stub for {@code org.bukkit.block.data.type.Farmland} (Minecraft 1.13+). + */ +public interface Farmland extends BlockData { + + int getMoisture(); + + void setMoisture(int moisture); + + int getMaximumMoisture(); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/type/GlassPane.java b/compat-stubs/src/main/java/org/bukkit/block/data/type/GlassPane.java new file mode 100644 index 0000000000..a7c5911e84 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/type/GlassPane.java @@ -0,0 +1,21 @@ +package org.bukkit.block.data.type; + +import java.util.Set; + +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Waterlogged; + +/** + * Compile-only stub for {@code org.bukkit.block.data.type.GlassPane} (Minecraft 1.13+). Mirrors the + * subset of {@code MultipleFacing} and {@code Waterlogged} that Slimefun uses. + */ +public interface GlassPane extends Waterlogged { + + boolean hasFace(BlockFace face); + + void setFace(BlockFace face, boolean has); + + Set getFaces(); + + Set getAllowedFaces(); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/type/Hopper.java b/compat-stubs/src/main/java/org/bukkit/block/data/type/Hopper.java new file mode 100644 index 0000000000..3dbf3866ad --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/type/Hopper.java @@ -0,0 +1,13 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Directional; + +/** + * Compile-only stub for {@code org.bukkit.block.data.type.Hopper} (Minecraft 1.13+). + */ +public interface Hopper extends Directional { + + boolean isEnabled(); + + void setEnabled(boolean enabled); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/type/Piston.java b/compat-stubs/src/main/java/org/bukkit/block/data/type/Piston.java new file mode 100644 index 0000000000..ddf5942243 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/type/Piston.java @@ -0,0 +1,13 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Directional; + +/** + * Compile-only stub for {@code org.bukkit.block.data.type.Piston} (Minecraft 1.13+). + */ +public interface Piston extends Directional { + + boolean isExtended(); + + void setExtended(boolean extended); +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/type/PistonHead.java b/compat-stubs/src/main/java/org/bukkit/block/data/type/PistonHead.java new file mode 100644 index 0000000000..702226a082 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/type/PistonHead.java @@ -0,0 +1,9 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Directional; + +/** + * Compile-only stub for {@code org.bukkit.block.data.type.PistonHead} (Minecraft 1.13+). + */ +public interface PistonHead extends Directional { +} diff --git a/compat-stubs/src/main/java/org/bukkit/block/data/type/Sapling.java b/compat-stubs/src/main/java/org/bukkit/block/data/type/Sapling.java new file mode 100644 index 0000000000..765eacfe65 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/block/data/type/Sapling.java @@ -0,0 +1,15 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.BlockData; + +/** + * Compile-only stub for {@code org.bukkit.block.data.type.Sapling} (Minecraft 1.13+). + */ +public interface Sapling extends BlockData { + + int getStage(); + + void setStage(int stage); + + int getMaximumStage(); +} diff --git a/compat-stubs/src/main/java/org/bukkit/entity/AbstractArrow.java b/compat-stubs/src/main/java/org/bukkit/entity/AbstractArrow.java new file mode 100644 index 0000000000..aec863efdb --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/entity/AbstractArrow.java @@ -0,0 +1,26 @@ +package org.bukkit.entity; + +/** + * Compile-only stub for {@code org.bukkit.entity.AbstractArrow} (Minecraft 1.14+). Not shaded; on + * modern servers the real interface is used at runtime. + */ +public interface AbstractArrow extends Projectile { + + int getPierceLevel(); + + void setPierceLevel(int level); + + PickupStatus getPickupStatus(); + + void setPickupStatus(PickupStatus status); + + double getDamage(); + + void setDamage(double damage); + + enum PickupStatus { + DISALLOWED, + ALLOWED, + CREATIVE_ONLY; + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/entity/Bee.java b/compat-stubs/src/main/java/org/bukkit/entity/Bee.java new file mode 100644 index 0000000000..e2000ef529 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/entity/Bee.java @@ -0,0 +1,9 @@ +package org.bukkit.entity; + +/** + * Compile-only stub for {@code org.bukkit.entity.Bee} (Minecraft 1.15+). Not shaded; on modern servers + * the real interface is used at runtime. Slimefun only uses it for {@code instanceof}, so it is a marker + * extending {@link LivingEntity} (a conservative supertype present on the 1.8 floor). + */ +public interface Bee extends LivingEntity { +} diff --git a/compat-stubs/src/main/java/org/bukkit/entity/ChestedHorse.java b/compat-stubs/src/main/java/org/bukkit/entity/ChestedHorse.java new file mode 100644 index 0000000000..597fbbbab1 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/entity/ChestedHorse.java @@ -0,0 +1,16 @@ +package org.bukkit.entity; + +import org.bukkit.inventory.Inventory; + +/** + * Compile-only stub for {@code org.bukkit.entity.ChestedHorse} (Minecraft 1.11+). Not shaded; on + * modern servers the real interface is used at runtime. Declared as a marker extending + * {@link LivingEntity} (a conservative supertype that exists on the 1.8 floor), plus the + * {@code getInventory()} accessor Slimefun reads (inherited from {@code AbstractHorse} on the real type). + */ +public interface ChestedHorse extends LivingEntity { + + Inventory getInventory(); + + boolean isCarryingChest(); +} diff --git a/compat-stubs/src/main/java/org/bukkit/entity/Goat.java b/compat-stubs/src/main/java/org/bukkit/entity/Goat.java new file mode 100644 index 0000000000..105226015c --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/entity/Goat.java @@ -0,0 +1,9 @@ +package org.bukkit.entity; + +/** + * Compile-only stub for {@code org.bukkit.entity.Goat} (Minecraft 1.17+). Not shaded; on modern servers + * the real interface is used at runtime. Used only for {@code instanceof}, so it is a marker extending + * {@link LivingEntity} (a conservative supertype present on the 1.8 floor). + */ +public interface Goat extends LivingEntity { +} diff --git a/compat-stubs/src/main/java/org/bukkit/entity/Piglin.java b/compat-stubs/src/main/java/org/bukkit/entity/Piglin.java new file mode 100644 index 0000000000..067f7c3afd --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/entity/Piglin.java @@ -0,0 +1,9 @@ +package org.bukkit.entity; + +/** + * Compile-only stub for {@code org.bukkit.entity.Piglin} (Minecraft 1.16+). Not shaded; on modern + * servers the real interface is used at runtime. Slimefun only uses it for {@code instanceof} checks + * and casts, so it is declared as a marker extending {@link Monster}. + */ +public interface Piglin extends Monster { +} diff --git a/compat-stubs/src/main/java/org/bukkit/entity/Ravager.java b/compat-stubs/src/main/java/org/bukkit/entity/Ravager.java new file mode 100644 index 0000000000..0e6f34c7d9 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/entity/Ravager.java @@ -0,0 +1,9 @@ +package org.bukkit.entity; + +/** + * Compile-only stub for {@code org.bukkit.entity.Ravager} (Minecraft 1.14+). Not shaded; on modern + * servers the real interface is used at runtime. Used only for {@code instanceof}, so it is a marker + * extending {@link LivingEntity} (a conservative supertype present on the 1.8 floor). + */ +public interface Ravager extends LivingEntity { +} diff --git a/compat-stubs/src/main/java/org/bukkit/entity/Trident.java b/compat-stubs/src/main/java/org/bukkit/entity/Trident.java new file mode 100644 index 0000000000..27a43d3fac --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/entity/Trident.java @@ -0,0 +1,9 @@ +package org.bukkit.entity; + +/** + * Compile-only stub for {@code org.bukkit.entity.Trident} (Minecraft 1.13+). Not shaded; on modern + * servers the real interface is used at runtime. Used only for {@code instanceof} on a + * {@link Projectile}, so it is a marker extending {@link Projectile} (present on the 1.8 floor). + */ +public interface Trident extends Projectile { +} diff --git a/compat-stubs/src/main/java/org/bukkit/entity/ZombieVillager.java b/compat-stubs/src/main/java/org/bukkit/entity/ZombieVillager.java new file mode 100644 index 0000000000..0b01a6e029 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/entity/ZombieVillager.java @@ -0,0 +1,9 @@ +package org.bukkit.entity; + +/** + * Compile-only stub for {@code org.bukkit.entity.ZombieVillager} (Minecraft 1.9+). Not shaded; on + * modern servers the real interface is used at runtime. Slimefun only uses it for {@code instanceof} + * checks, so it is declared as a marker extending {@link Zombie}. + */ +public interface ZombieVillager extends Zombie { +} diff --git a/compat-stubs/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java b/compat-stubs/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java new file mode 100644 index 0000000000..a7fc3ad292 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java @@ -0,0 +1,55 @@ +package org.bukkit.event.block; + +import java.util.List; + +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Compile-only stub for {@code org.bukkit.event.block.BlockDropItemEvent} (Minecraft 1.13+). Not + * shaded; on modern servers the real concrete class is used at runtime. Stubbed as a class (not an + * interface) so that virtual method calls resolve to {@code invokevirtual}, matching the real type. + */ +public class BlockDropItemEvent extends BlockEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + + public BlockDropItemEvent(Block block, BlockState blockState, Player player, List items) { + super(block); + } + + public Player getPlayer() { + return null; + } + + public BlockState getBlockState() { + return null; + } + + public List getItems() { + return null; + } + + @Override + public boolean isCancelled() { + return false; + } + + @Override + public void setCancelled(boolean cancel) { + // no-op stub + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java b/compat-stubs/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java new file mode 100644 index 0000000000..c9ac348ea5 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java @@ -0,0 +1,43 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Compile-only stub for {@code org.bukkit.event.entity.EntityDropItemEvent}. Not shaded; on modern + * servers the real concrete class is used at runtime. Stubbed as a class (not an interface) so virtual + * calls resolve via invokevirtual, matching the real type. + */ +public class EntityDropItemEvent extends EntityEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + + public EntityDropItemEvent(Entity entity, Item drop) { + super(entity); + } + + public Item getItemDrop() { + return null; + } + + @Override + public boolean isCancelled() { + return false; + } + + @Override + public void setCancelled(boolean cancel) { + // no-op stub + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java b/compat-stubs/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java new file mode 100644 index 0000000000..75a12573a0 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java @@ -0,0 +1,52 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Compile-only stub for {@code org.bukkit.event.entity.EntityPickupItemEvent} (Minecraft 1.12+). Not + * shaded; on modern servers the real concrete class is used at runtime. Stubbed as a class (not an + * interface) so that virtual method calls resolve to {@code invokevirtual}, matching the real type. + */ +public class EntityPickupItemEvent extends EntityEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + + public EntityPickupItemEvent(LivingEntity entity, Item item, int remaining) { + super(entity); + } + + @Override + public LivingEntity getEntity() { + return (LivingEntity) super.getEntity(); + } + + public Item getItem() { + return null; + } + + public int getRemaining() { + return 0; + } + + @Override + public boolean isCancelled() { + return false; + } + + @Override + public void setCancelled(boolean cancel) { + // no-op stub + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java b/compat-stubs/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java new file mode 100644 index 0000000000..50399f88ce --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java @@ -0,0 +1,42 @@ +package org.bukkit.event.entity; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; + +/** + * Compile-only stub for {@code org.bukkit.event.entity.EntityToggleGlideEvent} (Minecraft 1.9+). Not + * shaded; on modern servers the real concrete class is used at runtime. Stubbed as a class (not an + * interface) so that virtual method calls resolve to {@code invokevirtual}, matching the real type. + */ +public class EntityToggleGlideEvent extends EntityEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + + public EntityToggleGlideEvent(LivingEntity entity, boolean isGliding) { + super(entity); + } + + public boolean isGliding() { + return false; + } + + @Override + public boolean isCancelled() { + return false; + } + + @Override + public void setCancelled(boolean cancel) { + // no-op stub + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java b/compat-stubs/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java new file mode 100644 index 0000000000..823c4e5bfb --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java @@ -0,0 +1,21 @@ +package org.bukkit.event.inventory; + +import org.bukkit.inventory.InventoryView; +import org.bukkit.inventory.ItemStack; + +/** + * Compile-only stub for {@code org.bukkit.event.inventory.PrepareSmithingEvent} (Minecraft 1.16+). Not + * shaded; on modern servers the real concrete class is used at runtime. Stubbed as a class extending + * the real {@link InventoryEvent} (present on 1.8); {@code getInventory()} is inherited and + * {@code setResult(ItemStack)} mirrors the real type (from {@code PrepareInventoryResultEvent}). + */ +public class PrepareSmithingEvent extends InventoryEvent { + + public PrepareSmithingEvent(InventoryView view) { + super(view); + } + + public void setResult(ItemStack result) { + // no-op stub + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java b/compat-stubs/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java new file mode 100644 index 0000000000..ba32c1a490 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java @@ -0,0 +1,17 @@ +package org.bukkit.event.inventory; + +import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.inventory.InventoryView; + +/** + * Compile-only stub for {@code org.bukkit.event.inventory.SmithItemEvent} (Minecraft 1.16+). Not + * shaded; on modern servers the real concrete class is used at runtime. Stubbed as a class extending + * the real {@link InventoryClickEvent} (present on 1.8); the methods Slimefun uses (getInventory, + * setResult, getWhoClicked) are inherited. + */ +public class SmithItemEvent extends InventoryClickEvent { + + public SmithItemEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) { + super(view, type, slot, click, action); + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/inventory/RecipeChoice.java b/compat-stubs/src/main/java/org/bukkit/inventory/RecipeChoice.java new file mode 100644 index 0000000000..7d173c2134 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/inventory/RecipeChoice.java @@ -0,0 +1,27 @@ +package org.bukkit.inventory; + +import java.util.List; +import java.util.function.Predicate; + +import org.bukkit.Material; + +/** + * Compile-only stub for {@code org.bukkit.inventory.RecipeChoice} (Minecraft 1.13+) and its nested + * {@code MaterialChoice}. Not shaded; on modern servers the real types are used at runtime. Slimefun + * only casts to {@code MaterialChoice} and reads {@code getChoices()}, so only those members are + * declared. + * + *

+ * {@code RecipeChoice} is a real interface, but {@code MaterialChoice} is a real concrete class — it + * must be stubbed as a class (not an interface) so that {@code getChoices()} compiles to + * {@code invokevirtual} and resolves against the real class at runtime. + */ +public interface RecipeChoice extends Predicate { + + ItemStack getItemStack(); + + abstract class MaterialChoice implements RecipeChoice { + + public abstract List getChoices(); + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/inventory/meta/Damageable.java b/compat-stubs/src/main/java/org/bukkit/inventory/meta/Damageable.java new file mode 100644 index 0000000000..71f7af30b9 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/inventory/meta/Damageable.java @@ -0,0 +1,14 @@ +package org.bukkit.inventory.meta; + +/** + * Compile-only stub for {@code org.bukkit.inventory.meta.Damageable} (Minecraft 1.13+). Not shaded; + * on modern servers the real interface is used at runtime. Signatures match the real type. + */ +public interface Damageable extends ItemMeta { + + boolean hasDamage(); + + int getDamage(); + + void setDamage(int damage); +} diff --git a/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataContainer.java b/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataContainer.java new file mode 100644 index 0000000000..5884a79b6b --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataContainer.java @@ -0,0 +1,21 @@ +package org.bukkit.persistence; + +import org.bukkit.NamespacedKey; + +/** + * Compile-only stub for {@code org.bukkit.persistence.PersistentDataContainer} (Minecraft 1.14+). Not + * shaded; on modern servers the real interface is used at runtime. Method signatures match the real + * type so virtual calls resolve via {@code invokeinterface}. + */ +public interface PersistentDataContainer { + + void set(NamespacedKey key, PersistentDataType type, Z value); + + boolean has(NamespacedKey key, PersistentDataType type); + + Z get(NamespacedKey key, PersistentDataType type); + + Z getOrDefault(NamespacedKey key, PersistentDataType type, Z defaultValue); + + void remove(NamespacedKey key); +} diff --git a/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataHolder.java b/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataHolder.java new file mode 100644 index 0000000000..a68bc674e5 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataHolder.java @@ -0,0 +1,11 @@ +package org.bukkit.persistence; + +/** + * Compile-only stub for {@code org.bukkit.persistence.PersistentDataHolder} (Minecraft 1.14+). Not + * shaded; on modern servers the real interface (implemented by ItemMeta, TileState, Entity, etc.) is + * used at runtime. Code casts a holder to this type before reading its container. + */ +public interface PersistentDataHolder { + + PersistentDataContainer getPersistentDataContainer(); +} diff --git a/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataType.java b/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataType.java new file mode 100644 index 0000000000..a478e501a9 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/persistence/PersistentDataType.java @@ -0,0 +1,19 @@ +package org.bukkit.persistence; + +/** + * Compile-only stub for {@code org.bukkit.persistence.PersistentDataType} (Minecraft 1.14+). Not + * shaded; on modern servers the real interface and its constants are used at runtime. Only the typed + * constants that Slimefun references are declared. The {@code null} initializers are never read at + * runtime — consumers resolve the real static fields via {@code getstatic}. + */ +public interface PersistentDataType { + + PersistentDataType STRING = null; + PersistentDataType BYTE = null; + PersistentDataType SHORT = null; + PersistentDataType INTEGER = null; + PersistentDataType LONG = null; + PersistentDataType FLOAT = null; + PersistentDataType DOUBLE = null; + PersistentDataType BYTE_ARRAY = null; +} diff --git a/compat-stubs/src/main/java/org/bukkit/potion/PotionData.java b/compat-stubs/src/main/java/org/bukkit/potion/PotionData.java new file mode 100644 index 0000000000..20264ffa84 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/potion/PotionData.java @@ -0,0 +1,30 @@ +package org.bukkit.potion; + +/** + * Compile-only stub for {@code org.bukkit.potion.PotionData} (Minecraft 1.9+, deprecated 1.20.2+). Not + * shaded; on modern servers the real concrete class is used at runtime. Stubbed as a class (not an + * interface) so that virtual method calls resolve to {@code invokevirtual} and {@code new PotionData(..)} + * resolves to the real constructor, matching the real type. + */ +public class PotionData { + + public PotionData(PotionType type) { + // stub + } + + public PotionData(PotionType type, boolean extended, boolean upgraded) { + // stub + } + + public PotionType getType() { + return null; + } + + public boolean isUpgraded() { + return false; + } + + public boolean isExtended() { + return false; + } +} diff --git a/compat-stubs/src/main/java/org/bukkit/profile/PlayerProfile.java b/compat-stubs/src/main/java/org/bukkit/profile/PlayerProfile.java new file mode 100644 index 0000000000..e72e749fb7 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/profile/PlayerProfile.java @@ -0,0 +1,13 @@ +package org.bukkit.profile; + +/** + * Compile-only stub for {@code org.bukkit.profile.PlayerProfile} (Minecraft 1.18+). Not shaded; on + * modern servers the real interface is used at runtime. Only the texture accessors that Slimefun uses + * are declared; signatures match the real type so calls resolve via invokeinterface. + */ +public interface PlayerProfile { + + PlayerTextures getTextures(); + + void setTextures(PlayerTextures textures); +} diff --git a/compat-stubs/src/main/java/org/bukkit/profile/PlayerTextures.java b/compat-stubs/src/main/java/org/bukkit/profile/PlayerTextures.java new file mode 100644 index 0000000000..aaa30faca6 --- /dev/null +++ b/compat-stubs/src/main/java/org/bukkit/profile/PlayerTextures.java @@ -0,0 +1,13 @@ +package org.bukkit.profile; + +import java.net.URL; + +/** + * Compile-only stub for {@code org.bukkit.profile.PlayerTextures} (Minecraft 1.18+). Not shaded; on + * modern servers the real interface is used at runtime. Only the {@code setSkin(URL)} overload that + * Slimefun uses is declared; signatures match the real type so calls resolve via invokeinterface. + */ +public interface PlayerTextures { + + void setSkin(URL skinUrl); +} diff --git a/core/build.gradle.kts b/core/build.gradle.kts new file mode 100644 index 0000000000..76fe84d050 --- /dev/null +++ b/core/build.gradle.kts @@ -0,0 +1,632 @@ +import java.util.concurrent.TimeUnit +import java.io.ByteArrayOutputStream +import java.net.URI +import java.net.HttpURLConnection +import java.nio.file.FileSystems +import java.nio.file.Files +import java.util.zip.ZipEntry +import java.util.zip.ZipFile +import java.util.zip.ZipInputStream +import java.util.zip.ZipOutputStream +plugins { + java + id("com.gradleup.shadow") + id("io.github.intisy.github-gradle") + id("xyz.jpenilla.run-paper") +} + +group = "com.github.slimefun" +// Release builds pass -Partifact_version= (e.g. v5.2.2) so plugin.yml reports the real version; +// local/dev builds fall back to the current release number. +version = (project.findProperty("artifact_version") as String?)?.removePrefix("v")?.takeIf { it.isNotBlank() } ?: "5.2.2" +description = "Slimefun is a Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items and recipes to your Minecraft Server." + +github { + accessToken = System.getenv("GITHUB_TOKEN") ?: "" + publish { + tag = System.getenv("GITHUB_REF_NAME") + } +} + +java { + toolchain { + // Java 8 so the universal jar's bytecode loads on legacy (1.8+) servers running Java 8. + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + +repositories { + mavenCentral() + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") + maven("https://repo.papermc.io/repository/maven-public/") + maven("https://jitpack.io") + maven("https://maven.enginehub.org/repo/") + maven("https://repo.extendedclip.com/content/repositories/placeholderapi") + maven("https://nexus.neetgames.com/repository/maven-public") + maven("https://repo.walshy.dev/public") + maven("https://repo.codemc.io/repository/maven-public/") +} + +dependencies { + implementation(project(":compat-api")) + + githubImplementation("Slimefun5:dough:4.0.6:all") + + implementation("io.papermc:paperlib:1.0.8") + implementation("commons-lang:commons-lang:2.6") + // XSeries: cross-version Material/Sound/Particle resolution, shaded. + implementation("com.github.cryptomorin:XSeries:9.10.0") + + compileOnly("com.google.code.findbugs:jsr305:3.0.2") + // Compile against the oldest Bukkit API (1.8.8); newer APIs go through compat-api / NMS. + compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT") + // Compile-only stubs of post-1.8 org.bukkit types; not shaded, real classes used at runtime. + compileOnly(project(":compat-stubs")) + + testImplementation(platform("org.junit:junit-bom:5.11.4")) + testImplementation("org.junit.jupiter:junit-jupiter") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + testImplementation("org.mockito:mockito-core:5.15.2") + testImplementation("org.slf4j:slf4j-simple:2.0.16") +} + +configurations { + testImplementation { + extendsFrom(configurations.compileOnly.get()) + } +} + +tasks { + compileJava { + options.encoding = "UTF-8" + options.compilerArgs.add("-Xlint:-deprecation") + // Raise javac's default 100-error cap so the Java-8 port can see the full remaining surface. + options.compilerArgs.addAll(listOf("-Xmaxerrs", "2000", "-Xmaxwarns", "2000")) + exclude("**/package-info.java") + // WorldEdit/PlaceholderAPI hooks subclass Java-17 API types, so they can't compile on Java 8. + exclude( + "**/integrations/WorldEditIntegration.java", + "**/integrations/PlaceholderAPIIntegration.java" + ) + } + + // Tests need MockBukkit (Java 25+), incompatible with the Java 8 toolchain. + compileTestJava { enabled = false } + test { enabled = false } + + processResources { + // Declare the version as an input so changing -Partifact_version re-expands plugin.yml + // instead of reusing a stale cached copy (which once shipped 5.0.0-UNOFFICIAL). + inputs.property("version", project.version) + filesMatching("plugin.yml") { + expand("version" to project.version) + } + } + + jar { + enabled = false + } + + shadowJar { + archiveFileName.set("Slimefun v${project.version}-MC26.1.2.jar") + + relocate("io.github.bakedlibs.dough", "io.github.thebusybiscuit.slimefun5.libraries.dough") + relocate("io.papermc.lib", "io.github.thebusybiscuit.slimefun5.libraries.paperlib") + relocate("org.apache.commons.lang", "io.github.thebusybiscuit.slimefun5.libraries.commons.lang") + relocate("com.cryptomorin.xseries", "io.github.thebusybiscuit.slimefun5.libraries.xseries") + + exclude("META-INF/**") + + from(rootProject.projectDir) { + include("LICENSE") + } + + // XSeries 9.10.0's regex "MC: \d\.(\d+)" can't parse a 26.x major; binary-patch the relocated + // XMaterial$Data constant to "MC: (?:1\.)?(\d+)" (a newer XSeries would need Java 11+). + doLast { + val jarFile = archiveFile.get().asFile + val entryName = "io/github/thebusybiscuit/slimefun5/libraries/xseries/XMaterial\$Data.class" + + fun u2(value: ByteArray): ByteArray = byteArrayOf((value.size shr 8 and 0xFF).toByte(), (value.size and 0xFF).toByte()) + val oldConst = u2("MC: \\d\\.(\\d+)".toByteArray(Charsets.UTF_8)) + "MC: \\d\\.(\\d+)".toByteArray(Charsets.UTF_8) + val newConst = u2("MC: (?:1\\.)?(\\d+)".toByteArray(Charsets.UTF_8)) + "MC: (?:1\\.)?(\\d+)".toByteArray(Charsets.UTF_8) + + fun indexOf(haystack: ByteArray, needle: ByteArray): Int { + outer@ for (i in 0..haystack.size - needle.size) { + for (j in needle.indices) { + if (haystack[i + j] != needle[j]) continue@outer + } + return i + } + return -1 + } + + val uri = URI.create("jar:" + jarFile.toURI()) + FileSystems.newFileSystem(uri, mapOf()).use { fs -> + val path = fs.getPath(entryName) + if (!Files.exists(path)) { + logger.warn("XSeries 26.x patch: $entryName not found in jar") + } else { + val content = Files.readAllBytes(path) + if (indexOf(content, newConst) >= 0) { + logger.lifecycle("XSeries 26.x patch: already applied") + } else { + val idx = indexOf(content, oldConst) + if (idx < 0) { + logger.warn("XSeries 26.x patch: version regex constant not found (XSeries version changed?)") + } else { + val patched = content.copyOfRange(0, idx) + newConst + content.copyOfRange(idx + oldConst.size, content.size) + Files.write(path, patched) + logger.lifecycle("XSeries 26.x patch: rewrote XMaterial\$Data version regex for non-1.x majors") + } + } + } + } + } + } + + test { + useJUnitPlatform() + } + + build { + dependsOn(shadowJar) + } +} + +val cloneAndBuildAddons by tasks.registering { + group = "slimefun" + description = "Clones or pulls and compiles specified addons from GitHub" + + // Addons compile against the freshly-built core jar, so it must exist first. + dependsOn(tasks.named("shadowJar")) + + doLast { + var addonsProp = project.findProperty("addons") as String? ?: "" + + // The interactive runServer picker publishes its selection here. + if (addonsProp.isBlank()) { + addonsProp = project.findProperty("resolvedAddons") as String? ?: "" + } + + if (addonsProp.isBlank()) { + addonsProp = project.findProperty("slimefunAddons") as String? ?: "" + } + + if (addonsProp.isBlank()) { + println("No addons specified (use -Paddons=Owner/Repo,... or the interactive runServer menu)") + return@doLast + } + + val addonsSrcDir = project.layout.buildDirectory.dir("addons-src").get().asFile + addonsSrcDir.mkdirs() + + val mcVer = (project.findProperty("mcVersion") as String?)?.takeIf { it.isNotBlank() } ?: "26.1.2" + val pluginsDir = project.layout.projectDirectory.dir("run/$mcVer/plugins").asFile + pluginsDir.mkdirs() + + val addons = addonsProp.split(",") + + // -PlocalAddons builds the existing addons-src working copy as-is: skips the git fetch/reset + // (so local edits survive) and forces a rebuild. For iterating addon source against a live boot + // before committing. Does NOT introduce any hard-coded paths - it reuses addonsSrcDir/. + val localAddons = project.hasProperty("localAddons") + if (localAddons) println("[localAddons] building working copies as-is (no git fetch/reset)") + + // Addon build files reference the core jar by a relative path valid only in the old layout; + // rewrite it to the absolute jar path after each checkout (reset --hard reverts it every run). + val coreJarFile = project.layout.buildDirectory.file("libs/Slimefun v${project.version}-MC26.1.2.jar").get().asFile + val coreJarPath = coreJarFile.absolutePath.replace("\\", "/") + if (!coreJarFile.exists()) { + println("WARNING: Core jar not found at ${coreJarFile.absolutePath} - addon compiles will fail until :core:shadowJar produces it.") + } + // Bump to force a one-time rebuild when the patching below changes. + val addonBuildRecipe = "4" + val coreJarRefRegex = Regex("""files\((["'])\.\./\.\./core/Slimefun5/core/build/libs/[^"']*\.jar\1\)""") + fun patchCoreJarReference(repoDir: File) { + for (name in listOf("build.gradle.kts", "build.gradle")) { + val buildFile = File(repoDir, name) + if (!buildFile.exists()) continue + val text = buildFile.readText() + if (coreJarRefRegex.containsMatchIn(text)) { + val quote = coreJarRefRegex.find(text)!!.groupValues[1] + val patched = coreJarRefRegex.replace(text) { "files($quote$coreJarPath$quote)" } + if (patched != text) { + buildFile.writeText(patched) + println("Patched Slimefun core jar path in $name for ${repoDir.name}") + } + } + } + } + + fun getGitHash(dir: File): String { + try { + val proc = ProcessBuilder("git", "-c", "safe.directory=*", "rev-parse", "HEAD") + .directory(dir) + .redirectErrorStream(true) + .start() + proc.waitFor() + return proc.inputStream.bufferedReader().readText().trim() + } catch (e: Exception) { + return "" + } + } + + val buildTimeoutMinutes = 5L + + fun runProcess(pb: ProcessBuilder, timeoutMinutes: Long = buildTimeoutMinutes): Int { + pb.redirectErrorStream(true) + pb.redirectInput(ProcessBuilder.Redirect.from( + if (org.gradle.internal.os.OperatingSystem.current().isWindows) File("NUL") else File("/dev/null") + )) + val proc = pb.start() + val output = StringBuilder() + val reader = proc.inputStream.bufferedReader() + val readerThread = Thread { + reader.forEachLine { output.appendLine(it) } + } + readerThread.start() + val finished = proc.waitFor(timeoutMinutes, TimeUnit.MINUTES) + if (!finished) { + proc.destroyForcibly() + readerThread.join(2000) + println(output) + println("ERROR: Process timed out after $timeoutMinutes minutes.") + return -1 + } + readerThread.join(2000) + val exitCode = proc.exitValue() + if (exitCode != 0) { + println(output) + } + return exitCode + } + + // Bytecode major version of a plugin jar's main class (Java 8 = 52); null for library jars. + // Guards the skip-build optimization against stale higher-version jars from an earlier JDK. + fun pluginMainClassVersion(jar: File): Int? { + try { + ZipFile(jar).use { zf -> + zf.getEntry("plugin.yml") ?: return null + val mainClass = zf.getInputStream(zf.getEntry("plugin.yml")).bufferedReader().use { reader -> + reader.lineSequence() + .firstOrNull { it.trimStart().startsWith("main:") } + ?.substringAfter("main:")?.trim()?.trim('"', '\'') + } ?: return null + val classEntry = zf.getEntry(mainClass.replace('.', '/') + ".class") ?: return null + zf.getInputStream(classEntry).use { ins -> + val header = ByteArray(8) + var off = 0 + while (off < 8) { + val n = ins.read(header, off, 8 - off) + if (n < 0) break + off += n + } + if (off < 8) return null + return ((header[6].toInt() and 0xFF) shl 8) or (header[7].toInt() and 0xFF) + } + } + } catch (e: Exception) { + return null + } + } + + fun jarHasPluginYml(jar: File): Boolean { + return try { + ZipFile(jar).use { it.getEntry("plugin.yml") != null } + } catch (e: Exception) { + false + } + } + + // Equal-length byte swap of slimefun4 -> slimefun5 in a jar's .class entries (idempotent). Catches + // shaded deps (e.g. a metrics module) compiled against the upstream slimefun4 package, which the + // source-level patchSlimefun4Refs can't reach. + fun relocateSlimefun4InJar(jar: File) { + val from = "slimefun4".toByteArray(Charsets.UTF_8) + val to = "slimefun5".toByteArray(Charsets.UTF_8) + val temp = File(jar.parentFile, jar.name + ".tmp") + var changed = false + ZipInputStream(jar.inputStream()).use { zin -> + ZipOutputStream(temp.outputStream()).use { zout -> + var entry = zin.nextEntry + while (entry != null) { + val data = zin.readBytes() + if (entry.name.endsWith(".class")) { + var i = 0 + while (i <= data.size - from.size) { + var match = true + for (j in from.indices) if (data[i + j] != from[j]) { match = false; break } + if (match) { System.arraycopy(to, 0, data, i, to.size); changed = true } + i++ + } + } + zout.putNextEntry(ZipEntry(entry.name)) + zout.write(data) + zout.closeEntry() + entry = zin.nextEntry + } + } + } + if (changed) { + jar.delete() + temp.renameTo(jar) + println("Relocated slimefun4 -> slimefun5 in ${jar.name}") + } else { + temp.delete() + } + } + + // Only plugin jars (with plugin.yml) go in the plugins folder; library addons are shaded into consumers. + fun copyAddonJar(jar: File) { + if (!jarHasPluginYml(jar)) { + println("Not copying ${jar.name} to plugins (library jar, no plugin.yml).") + return + } + println("Copying ${jar.name} to plugins folder...") + val dest = File(pluginsDir, jar.name) + // A stale jar may be locked by an orphaned server JVM from a previous run; copyTo(overwrite) + // would then throw FileAlreadyExistsException and fail the whole build. Try a plain delete + + // copy, and if the lock persists fall back to streaming over the existing file rather than + // aborting - the addon is still updated and the next run starts clean. + try { + if (dest.exists() && !dest.delete()) { + dest.outputStream().use { out -> jar.inputStream().use { it.copyTo(out) } } + } else { + jar.copyTo(dest, overwrite = true) + } + } catch (e: Exception) { + println("WARNING: could not refresh ${dest.name} (locked by a stale server?): ${e.message}. Using existing copy.") + if (!dest.exists()) throw e + return + } + relocateSlimefun4InJar(dest) + } + + // bStats refuses to run unless org.bstats is relocated; the committed builds omit it, so inject it. + fun patchBstatsRelocation(repoDir: File) { + for (name in listOf("build.gradle.kts", "build.gradle")) { + val buildFile = File(repoDir, name) + if (!buildFile.exists()) continue + var text = buildFile.readText() + if (!text.contains("SlimefunMetrics")) continue + if (text.contains("\"org.bstats\"") || text.contains("'org.bstats'")) continue + val target = repoDir.name.lowercase().replace(Regex("[^a-z0-9]"), "") + ".libs.bstats" + val anchor = when { + text.contains("shadowJar {") -> "shadowJar {" + text.contains("shadowJar{") -> "shadowJar{" + else -> null + } + if (anchor != null) { + text = text.replaceFirst(anchor, "$anchor\n relocate(\"org.bstats\", \"$target\")") + buildFile.writeText(text) + println("Patched bStats relocation in $name for ${repoDir.name}") + } + } + } + + // An addon relocating InfinityLib must also bundle it; promote compileOnly -> implementation. + fun patchInfinityLibShading(repoDir: File) { + for (name in listOf("build.gradle.kts", "build.gradle")) { + val buildFile = File(repoDir, name) + if (!buildFile.exists()) continue + val text = buildFile.readText() + if (!text.contains("infinitylib")) continue + val regex = Regex("""compileOnly\((files\(["'][^"']*InfinityLib[^"']*\.jar["']\))\)""") + if (regex.containsMatchIn(text)) { + val patched = regex.replace(text) { "implementation(${it.groupValues[1]})" } + if (patched != text) { + buildFile.writeText(patched) + println("Patched InfinityLib to be shaded (implementation) in $name for ${repoDir.name}") + } + } + } + } + + // Some addons import the old slimefun4.* package; our core is slimefun5, so rewrite it in their sources. + fun patchSlimefun4Refs(repoDir: File) { + val srcDir = File(repoDir, "src") + if (!srcDir.isDirectory) return + var count = 0 + srcDir.walkTopDown().filter { it.isFile && it.name.endsWith(".java") }.forEach { javaFile -> + val text = javaFile.readText() + if (text.contains("io.github.thebusybiscuit.slimefun4")) { + javaFile.writeText(text.replace("io.github.thebusybiscuit.slimefun4", "io.github.thebusybiscuit.slimefun5")) + count++ + } + } + if (count > 0) println("Rewrote slimefun4 -> slimefun5 in $count source file(s) for ${repoDir.name}") + } + + // Clear stale addon jars (mismatched names cause Bukkit "Ambiguous plugin name"); keep the core jar. + pluginsDir.listFiles { f: File -> f.name.endsWith(".jar") && !f.name.contains("_RunServer_") }?.forEach { it.delete() } + + for (addon in addons) { + // Each entry is Owner/Repo or Owner/Repo@branch (run.ps1 appends the chosen branch). + val ownerRepo = addon.substringBefore("@").trim() + val branch = addon.substringAfter("@", "").trim() + val parts = ownerRepo.split("/") + if (parts.size != 2) { + println("Invalid addon format: $addon. Expected Owner/Repo or Owner/Repo@branch") + continue + } + val repo = parts[1] + val upstreamRef = if (branch.isNotBlank()) "origin/$branch" else "origin/HEAD" + val label = if (branch.isNotBlank()) "$ownerRepo ($branch)" else ownerRepo + + val repoDir = File(addonsSrcDir, repo) + val isWindows = org.gradle.internal.os.OperatingSystem.current().isWindows + + val oldHash = if (repoDir.exists()) getGitHash(repoDir) else "" + + if (localAddons && repoDir.exists()) { + println("[localAddons] using working copy of $label as-is") + } else if (repoDir.exists()) { + println("Pulling latest for $label...") + runProcess(ProcessBuilder("git", "-c", "safe.directory=*", "fetch", "--all").directory(repoDir), 2) + runProcess(ProcessBuilder("git", "-c", "safe.directory=*", "remote", "set-head", "origin", "-a").directory(repoDir), 1) + if (branch.isNotBlank()) { + runProcess(ProcessBuilder("git", "-c", "safe.directory=*", "checkout", branch).directory(repoDir), 1) + } + // addons-src is a throwaway clone; always force it to match origin exactly. + runProcess(ProcessBuilder("git", "-c", "safe.directory=*", "reset", "--hard", upstreamRef).directory(repoDir), 1) + } else { + println("Cloning $label...") + val cloneCmd = mutableListOf("git", "-c", "safe.directory=*", "clone") + if (branch.isNotBlank()) { cloneCmd.add("-b"); cloneCmd.add(branch) } + cloneCmd.add("https://github.com/$ownerRepo.git") + runProcess(ProcessBuilder(cloneCmd).directory(addonsSrcDir), 5) + } + + // Re-point the (just-checked-out) core jar reference at the real built jar. + patchCoreJarReference(repoDir) + // Ensure bStats is relocated so SlimefunMetrics-using addons can enable. + patchBstatsRelocation(repoDir) + // Shade relocated InfinityLib + fix stray slimefun4 package references (both fail on every MC version). + patchInfinityLibShading(repoDir) + patchSlimefun4Refs(repoDir) + + val newHash = getGitHash(repoDir) + val libsDir = File(repoDir, "build/libs") + val jars = libsDir.listFiles { file: File -> file.name.endsWith(".jar") && !file.name.endsWith("-javadoc.jar") && !file.name.endsWith("-sources.jar") } + val hasCompiledJar = jars != null && jars.isNotEmpty() + + val existingJar = if (hasCompiledJar) { + jars!!.firstOrNull { it.name.contains("v") || it.name.contains("shadow") } ?: jars!![0] + } else null + // Skip only when unchanged AND the cached jar is already Java-8 bytecode (<= 52). + val existingJarVersion = existingJar?.let { pluginMainClassVersion(it) } + val recipeMarker = File(libsDir, ".addon-recipe") + val recipeMatches = recipeMarker.exists() && recipeMarker.readText().trim() == addonBuildRecipe + if (!localAddons && oldHash == newHash && oldHash.isNotBlank() && existingJar != null && existingJarVersion != null && existingJarVersion <= 52 && recipeMatches) { + println("No updates found for $addon. Skipping build.") + copyAddonJar(existingJar) + continue + } + + // Clear stale jars so we copy this build's output, not an outdated artifact. + libsDir.listFiles { file: File -> file.name.endsWith(".jar") }?.forEach { it.delete() } + + println("Building $addon...") + // Use the wrapper's absolute path; "gradlew.bat" alone relies on cmd resolving the cwd, which + // intermittently fails with "'gradlew.bat' is not recognized" even when the file is present. + val wrapperName = if (isWindows) "gradlew.bat" else "gradlew" + val wrapperFile = File(repoDir, wrapperName) + val gradlewCmd = if (wrapperFile.exists()) wrapperFile.absolutePath else if (isWindows) "gradlew.bat" else "./gradlew" + val buildPb = if (isWindows) { + ProcessBuilder("cmd", "/c", gradlewCmd, "shadowJar") + } else { + ProcessBuilder("sh", "-c", "\"$gradlewCmd\" shadowJar") + } + buildPb.directory(repoDir) + val exitCode = runProcess(buildPb, buildTimeoutMinutes) + + if (exitCode != 0) { + println("WARNING: Build failed for $addon (Exit Code: $exitCode). Skipping.") + continue + } + + val newJars = libsDir.listFiles { file: File -> file.name.endsWith(".jar") && !file.name.endsWith("-javadoc.jar") && !file.name.endsWith("-sources.jar") } + if (newJars != null && newJars.isNotEmpty()) { + val targetJar = newJars.firstOrNull { it.name.contains("v") || it.name.contains("shadow") } ?: newJars[0] + copyAddonJar(targetJar) + recipeMarker.writeText(addonBuildRecipe) + } else { + println("WARNING: No compiled jar found for $addon") + } + } + } +} + +// runServer reads -PmcVersion / -Paddons; the interactive picker is run.ps1 (the daemon has no console). +val runServerMcVer = (project.findProperty("mcVersion") as String?)?.takeIf { it.isNotBlank() } ?: "26.1.2" + +// Addons to build for runServer: -Paddons (comma-separated Owner/Repo) selects them; otherwise none +// (core only). -PskipAddons is still accepted as an explicit "no addons". +val runServerAddons = if (project.hasProperty("skipAddons")) "" else (project.findProperty("addons") as String? ?: "") +project.extra.set("resolvedAddons", runServerAddons) + +// The server JVM must match the MC version's Java requirement (the plugin jar itself is Java 8). +fun requiredJavaFor(mc: String): Int { + val parts = mc.split(".") + val major = parts.getOrNull(0)?.toIntOrNull() ?: 0 + val minor = parts.getOrNull(1)?.toIntOrNull() ?: 0 + val patch = parts.getOrNull(2)?.toIntOrNull() ?: 0 + return when { + major >= 26 -> 25 + major == 1 && minor >= 21 -> 21 + major == 1 && minor == 20 && patch >= 5 -> 21 + major == 1 && minor >= 18 -> 17 + major == 1 && minor == 17 -> 16 + else -> 8 + } +} + +// ViaVersion + ViaBackwards + ViaRewind let the test server accept clients of other versions. +// On by default for runServer (the scripts rely on it); disable with -PnoVia. +val installVia = !project.hasProperty("noVia") + +// Downloads the latest build that supports from Modrinth into pluginsDir, +// replacing any older copy. Best-effort: a failure logs a warning and never blocks the launch. +fun installViaPlugin(slug: String, mcVersion: String, pluginsDir: java.io.File) { + try { + // Modrinth tags the 1.8 line as "1.8.9"; map 1.8.x to it so the query resolves. + val viaMc = if (mcVersion.startsWith("1.8")) "1.8.9" else mcVersion + val api = "https://api.modrinth.com/v2/project/$slug/version?game_versions=%5B%22$viaMc%22%5D" + + "&loaders=%5B%22paper%22%2C%22spigot%22%2C%22bukkit%22%5D" + val conn = URI.create(api).toURL().openConnection() as HttpURLConnection + conn.setRequestProperty("User-Agent", "Slimefun5-universal-build") + conn.connectTimeout = 15000 + conn.readTimeout = 15000 + val body = conn.inputStream.bufferedReader().use { it.readText() } + @Suppress("UNCHECKED_CAST") + val versions = groovy.json.JsonSlurper().parseText(body) as List> + if (versions.isEmpty()) { + logger.warn("[via] no $slug build found for MC $viaMc") + return + } + @Suppress("UNCHECKED_CAST") + val files = versions[0]["files"] as List> + val file = files.firstOrNull { it["primary"] == true } ?: files[0] + val url = file["url"] as String + val name = file["filename"] as String + val dest = pluginsDir.resolve(name) + if (dest.exists()) { + logger.lifecycle("[via] $name already present") + return + } + // Remove older versions of this plugin so it's an update, not a duplicate. + pluginsDir.listFiles()?.filter { it.name.startsWith(slug, ignoreCase = true) && it.name.endsWith(".jar") }?.forEach { it.delete() } + URI.create(url).toURL().openStream().use { input -> dest.outputStream().use { input.copyTo(it) } } + logger.lifecycle("[via] installed $name") + } catch (e: Exception) { + logger.warn("[via] failed to install $slug for MC $mcVersion: ${e.message}") + } +} + +tasks.runServer { + dependsOn(tasks.shadowJar) + if (runServerAddons.isNotBlank()) { + dependsOn(cloneAndBuildAddons) + } + minecraftVersion(runServerMcVer) + javaLauncher.set(javaToolchains.launcherFor { + languageVersion.set(JavaLanguageVersion.of(requiredJavaFor(runServerMcVer))) + }) + + // Per-version run dir: Paper world/config aren't backward-compatible across MC versions. + val perVersionRunDir = layout.projectDirectory.dir("run/$runServerMcVer") + runDirectory.set(perVersionRunDir) + doFirst { + val runDirFile = perVersionRunDir.asFile + runDirFile.mkdirs() + runDirFile.resolve("eula.txt").writeText("eula=true\n") + + if (installVia) { + val pluginsDir = runDirFile.resolve("plugins").also { it.mkdirs() } + listOf("viaversion", "viabackwards", "viarewind").forEach { installViaPlugin(it, runServerMcVer, pluginsDir) } + } + } +} + + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/ErrorReport.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/ErrorReport.java index fc42940f84..5e29a3ef86 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/ErrorReport.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.api; +package io.github.thebusybiscuit.slimefun5.api; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; import java.io.File; import java.io.PrintStream; import java.nio.charset.StandardCharsets; @@ -21,9 +22,9 @@ import org.bukkit.Location; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetProvider; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -92,7 +93,7 @@ public ErrorReport(T throwable, Location l, SlimefunItem item) { stream.println(" Y: " + l.getBlockY()); stream.println(" Z: " + l.getBlockZ()); stream.println(" Material: " + l.getBlock().getType()); - stream.println(" Block Data: " + l.getBlock().getBlockData().getClass().getName()); + stream.println(" Block Data: " + BlockDataCompat.getBlockData(l.getBlock()).getClass().getName()); stream.println(" State: " + l.getBlock().getState().getClass().getName()); stream.println(); @@ -276,3 +277,4 @@ public static void tryCatch(@Nonnull Function> } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/MinecraftVersion.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/MinecraftVersion.java index afad06e3bc..d123b95dbc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/MinecraftVersion.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.api; +package io.github.thebusybiscuit.slimefun5.api; import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; import org.bukkit.Server; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import io.papermc.lib.PaperLib; /** @@ -19,6 +19,19 @@ */ public enum MinecraftVersion { + /* + * Java-8 universal port: legacy versions 1.8-1.15 are supported by the universal jar. They are + * listed FIRST so the enum ordinal order stays oldest-to-newest (isAtLeast/isBefore rely on it). + */ + MINECRAFT_1_8(8, "1.8.x"), + MINECRAFT_1_9(9, "1.9.x"), + MINECRAFT_1_10(10, "1.10.x"), + MINECRAFT_1_11(11, "1.11.x"), + MINECRAFT_1_12(12, "1.12.x"), + MINECRAFT_1_13(13, "1.13.x"), + MINECRAFT_1_14(14, "1.14.x"), + MINECRAFT_1_15(15, "1.15.x"), + /** * This constant represents Minecraft (Java Edition) Version 1.16 * (The "Nether Update") @@ -58,8 +71,21 @@ public enum MinecraftVersion { /** * This constant represents Minecraft (Java Edition) Version 1.21 * ("Tricky Trials") + * This covers versions 1.21.0 through 1.21.3 + */ + MINECRAFT_1_21(21, 0, 3, "1.21.x"), + + /** + * This constant represents Minecraft (Java Edition) Version 1.21.4+ + * ("The Garden Awakens" and later drops including "Spring to Life", + * "The Copper Age", and "Mounts of Mayhem") */ - MINECRAFT_1_21(21, 0, "1.21.x"), + MINECRAFT_1_21_4(21, 4, "1.21.4+"), + + /** + * This constant represents Minecraft (Java Edition) Version 1.26 + */ + MINECRAFT_1_26(26, "1.26.x"), /** * This constant represents an exceptional state in which we were unable @@ -298,3 +324,4 @@ public boolean isBefore(int minecraftVersion, int patchVersion) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/SlimefunAddon.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/SlimefunAddon.java index 8d8609c8be..7c9611fa9e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/SlimefunAddon.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api; +package io.github.thebusybiscuit.slimefun5.api; import java.util.logging.Logger; @@ -10,7 +10,7 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This is a very basic interface that will be used to identify @@ -98,3 +98,4 @@ default boolean hasDependency(@Nonnull String dependency) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/SlimefunBranch.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/SlimefunBranch.java index f755717da1..b86e4716e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/SlimefunBranch.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api; +package io.github.thebusybiscuit.slimefun5.api; import javax.annotation.Nonnull; @@ -76,3 +76,4 @@ public boolean isOfficial() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AncientAltarCraftEvent.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AncientAltarCraftEvent.java index 2e282d966a..df634246a7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AncientAltarCraftEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -12,9 +12,9 @@ import org.bukkit.event.player.PlayerEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientAltar; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.AncientAltarListener; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AncientAltarTask; /** * This {@link Event} is fired before an item is dropped by an {@link AncientAltar}. @@ -105,3 +105,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AndroidFarmEvent.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AndroidFarmEvent.java index e2a3d1c9c6..6522e58d6d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AndroidFarmEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -9,8 +9,8 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.AndroidInstance; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.FarmerAndroid; /** * This {@link Event} is fired before a {@link FarmerAndroid} harvests a {@link Block}. @@ -119,4 +119,4 @@ public HandlerList getHandlers() { return getHandlerList(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AndroidMineEvent.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AndroidMineEvent.java index 66d3c2c158..897e4ab9ac 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AndroidMineEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,8 +8,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.AndroidInstance; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.MinerAndroid; /** * This {@link Event} is fired before a {@link MinerAndroid} mines a {@link Block}. @@ -80,4 +80,4 @@ public HandlerList getHandlers() { return getHandlerList(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncAutoEnchanterProcessEvent.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncAutoEnchanterProcessEvent.java index 09f306186e..47537592f5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncAutoEnchanterProcessEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -8,7 +8,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting.AutoEnchanter; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -91,3 +91,4 @@ public void setCancelled(boolean cancel) { this.cancelled = cancel; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncMachineOperationFinishEvent.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncMachineOperationFinishEvent.java index 8c6a413a0e..cf7e9a3f26 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncMachineOperationFinishEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -8,8 +8,8 @@ import org.bukkit.event.HandlerList; import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineOperation; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineProcessor; /** * This {@link Event} is fired whenever an {@link MachineProcessor} has completed a {@link MachineOperation}. @@ -75,3 +75,4 @@ public HandlerList getHandlers() { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncProfileLoadEvent.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncProfileLoadEvent.java index b05f8e5c30..d2693e5507 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AsyncProfileLoadEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import java.util.UUID; @@ -9,7 +9,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; /** * This {@link Event} is called when the {@link PlayerProfile} of a {@link Player} @@ -73,3 +73,4 @@ public HandlerList getHandlers() { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AutoDisenchantEvent.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AutoDisenchantEvent.java index 0a4585470a..ca61e71844 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AutoDisenchantEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting.AutoDisenchanter; /** * An {@link Event} that is called whenever an {@link AutoDisenchanter} has @@ -62,3 +62,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AutoEnchantEvent.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AutoEnchantEvent.java index 30d34df9d8..68ec1aba44 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/AutoEnchantEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting.AutoEnchanter; /** * An {@link Event} that is called whenever an {@link AutoEnchanter} is trying to enchant @@ -62,3 +62,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/BlockPlacerPlaceEvent.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/BlockPlacerPlaceEvent.java index 59ee4bdf51..5b187c5e55 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/BlockPlacerPlaceEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -11,8 +11,8 @@ import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.BlockPlacer; /** * This {@link Event} is fired whenever a {@link BlockPlacer} wants to place a {@link Block}. @@ -117,3 +117,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ClimbingPickLaunchEvent.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ClimbingPickLaunchEvent.java index e5bb91dc24..1845a189ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ClimbingPickLaunchEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.ClimbingPick; /** * An {@link Event} that is called whenever a {@link Player} has @@ -118,3 +118,4 @@ public HandlerList getHandlers() { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/CoolerFeedPlayerEvent.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/CoolerFeedPlayerEvent.java index b6a3d579cb..e4bf6571ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/CoolerFeedPlayerEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -13,7 +13,7 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.Cooler; /** * This {@link Event} is called whenever a {@link Player} is @@ -111,3 +111,4 @@ public HandlerList getHandlers() { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ExplosiveToolBreakBlocksEvent.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ExplosiveToolBreakBlocksEvent.java index e0bd18e6e0..90a55d3fdb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ExplosiveToolBreakBlocksEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import java.util.List; @@ -14,7 +14,7 @@ import org.bukkit.event.player.PlayerEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveTool; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.ExplosiveTool; /** * This {@link Event} is called when an {@link ExplosiveTool} is used to break blocks. @@ -112,3 +112,4 @@ public HandlerList getHandlers() { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/GEOResourceGenerationEvent.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/GEOResourceGenerationEvent.java index cc659b7734..edb4a99760 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/GEOResourceGenerationEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -11,9 +11,9 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.geo.ResourceManager; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOScanner; /** * This {@link Event} is fired whenever a {@link GEOResource} is being freshly generated. @@ -147,3 +147,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockCraftEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/MultiBlockCraftEvent.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockCraftEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/MultiBlockCraftEvent.java index 7a3fc3c535..f4cffc8e78 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockCraftEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/MultiBlockCraftEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -11,7 +11,7 @@ import org.bukkit.event.player.PlayerEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; /** * This {@link Event} is called when a {@link Player} crafts an item using a {@link MultiBlockMachine}. @@ -118,3 +118,4 @@ public void setCancelled(boolean cancel) { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/MultiBlockInteractEvent.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/MultiBlockInteractEvent.java index 067aa5b180..d6ba84af43 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/MultiBlockInteractEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -11,7 +11,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlock; /** * This {@link Event} is called when a {@link Player} interacts with a {@link MultiBlock}. @@ -88,3 +88,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerLanguageChangeEvent.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerLanguageChangeEvent.java index 5f13972832..1092622f23 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerLanguageChangeEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -6,8 +6,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun5.core.services.LocalizationService; +import io.github.thebusybiscuit.slimefun5.core.services.localization.Language; /** * This {@link Event} gets called when a {@link Player} has switched their {@link Language}. @@ -73,3 +73,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerPreResearchEvent.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerPreResearchEvent.java index 1e0a618697..d717b17b1f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerPreResearchEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -9,10 +9,10 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.guide.CheatSheetSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.guide.SurvivalSlimefunGuide; /** * This {@link Event} is called whenever a {@link Player} clicks to unlock a {@link Research}. @@ -80,3 +80,4 @@ public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerRightClickEvent.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerRightClickEvent.java index 30c9c927af..add063f96a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/PlayerRightClickEvent.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.Optional; @@ -17,7 +19,7 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.data.TriStateOptional; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -66,7 +68,7 @@ public PlayerRightClickEvent(@Nonnull PlayerInteractEvent originalEvent) { event = originalEvent; clickedBlock = Optional.ofNullable(originalEvent.getClickedBlock()); face = originalEvent.getBlockFace(); - hand = originalEvent.getHand(); + hand = HandCompat.getHand(originalEvent); itemResult = originalEvent.useItemInHand(); blockResult = originalEvent.useInteractedBlock(); @@ -103,7 +105,7 @@ public ItemStack getItem() { /** * This returns the hand that was used in this interaction. - * Can either be {@code EquipmentSlot.HAND} or {@code EquipmentSlot.OFF_HAND}. + * Can either be {@code EquipmentSlot.HAND} or {@code HandCompat.OFF_HAND}. * * @return The hand used in this {@link Event} */ @@ -189,3 +191,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/RadiationDamageEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/RadiationDamageEvent.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/RadiationDamageEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/RadiationDamageEvent.java index b3ef284e75..b945672a6d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/RadiationDamageEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/RadiationDamageEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -67,3 +67,4 @@ public void setCancelled(boolean cancelled) { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ReactorExplodeEvent.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ReactorExplodeEvent.java index 859a80935b..befe25b3e1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ReactorExplodeEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -7,8 +7,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.Reactor; /** * The {@link ReactorExplodeEvent} is called whenever a reactor explodes. @@ -63,3 +63,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ResearchUnlockEvent.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ResearchUnlockEvent.java index 59d097a2ad..d17446618e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/ResearchUnlockEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -9,7 +9,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; /** * This {@link Event} is called whenever a {@link Player} unlocks a {@link Research}. @@ -69,3 +69,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunBlockBreakEvent.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunBlockBreakEvent.java index 8554a69499..ef3e9e9a7e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunBlockBreakEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -11,7 +11,7 @@ import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This {@link Event} is fired whenever a {@link SlimefunItem} placed as a {@link Block} in the world is broken. @@ -104,3 +104,4 @@ public void setCancelled(boolean cancelled) { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunBlockPlaceEvent.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunBlockPlaceEvent.java index 2978b9d77a..ad1c35c2f2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunBlockPlaceEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -10,7 +10,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This {@link Event} is fired whenever a {@link SlimefunItem} is placed as a {@link Block} in the world. @@ -103,3 +103,4 @@ public void setCancelled(boolean cancelled) { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunGuideOpenEvent.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunGuideOpenEvent.java index ecf46a5311..b4c6c10d42 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunGuideOpenEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -9,7 +9,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; /** * This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book. @@ -102,3 +102,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemRegistryFinalizedEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunItemRegistryFinalizedEvent.java similarity index 80% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemRegistryFinalizedEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunItemRegistryFinalizedEvent.java index 12943c82bf..4221ab7485 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemRegistryFinalizedEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunItemRegistryFinalizedEvent.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** @@ -33,3 +33,4 @@ public HandlerList getHandlers() { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunItemSpawnEvent.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunItemSpawnEvent.java index 95b5fadf6f..8e88ea9487 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/SlimefunItemSpawnEvent.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.Optional; @@ -14,7 +16,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; /** * This {@link Event} is fired whenever slimefun drops an {@link ItemStack}. @@ -105,7 +107,7 @@ public void setLocation(@Nonnull Location location) { */ public void setItemStack(@Nonnull ItemStack itemStack) { Validate.notNull(itemStack, "Cannot drop null."); - Validate.isTrue(!itemStack.getType().isAir(), "Cannot drop air."); + Validate.isTrue(!MaterialCompat.isAir(itemStack.getType()), "Cannot drop air."); this.itemStack = itemStack; } @@ -129,3 +131,4 @@ public void setCancelled(boolean cancelled) { return getHandlerList(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivateEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/TalismanActivateEvent.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivateEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/TalismanActivateEvent.java index b8515bed47..2ff9482887 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/TalismanActivateEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/TalismanActivateEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.Talisman; /** * This {@link PlayerEvent} is called when a {@link Player} activates a {@link Talisman} @@ -94,3 +94,4 @@ public void setCancelled(boolean cancel) { return handlers; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/WaypointCreateEvent.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/WaypointCreateEvent.java index 4253f7983e..e3113422bb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/WaypointCreateEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import javax.annotation.Nonnull; @@ -9,9 +9,9 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; -import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork; -import io.github.thebusybiscuit.slimefun4.api.gps.TeleportationManager; -import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint; +import io.github.thebusybiscuit.slimefun5.api.gps.GPSNetwork; +import io.github.thebusybiscuit.slimefun5.api.gps.TeleportationManager; +import io.github.thebusybiscuit.slimefun5.api.gps.Waypoint; /** * A {@link WaypointCreateEvent} is called when a {@link Player} creates a new waypoint. @@ -120,3 +120,4 @@ public HandlerList getHandlers() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/package-info.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/package-info.java index cb36d7d8c2..9a2dce6292 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/events/package-info.java @@ -2,4 +2,4 @@ * This package contains all extensions of {@link org.bukkit.event.Event} that Slimefun provides * and allows you to listen to. */ -package io.github.thebusybiscuit.slimefun4.api.events; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.api.events; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/BiomeMapException.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/BiomeMapException.java index 8a116e283c..8031d32708 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/BiomeMapException.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.api.exceptions; +package io.github.thebusybiscuit.slimefun5.api.exceptions; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; -import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap; +import io.github.thebusybiscuit.slimefun5.utils.biomes.BiomeMap; /** * A {@link BiomeMapException} is thrown whenever a {@link BiomeMap} @@ -45,3 +45,4 @@ public BiomeMapException(NamespacedKey key, Throwable cause) { super("Biome Map '" + key + "' has been misconfigured (" + cause.getMessage() + ')', cause); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/IdConflictException.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/IdConflictException.java index bc9b5b4fe0..4c25b3c9c4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/IdConflictException.java @@ -1,8 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.api.exceptions; +package io.github.thebusybiscuit.slimefun5.api.exceptions; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * An {@link IdConflictException} is thrown whenever two Addons try to add @@ -29,3 +29,4 @@ public IdConflictException(SlimefunItem item1, SlimefunItem item2) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/IncompatibleItemHandlerException.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/IncompatibleItemHandlerException.java index e80f23a505..c64d9dbd7a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/IncompatibleItemHandlerException.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.api.exceptions; +package io.github.thebusybiscuit.slimefun5.api.exceptions; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; /** * An {@link IncompatibleItemHandlerException} is thrown whenever a {@link Plugin} tried @@ -43,3 +43,4 @@ public IncompatibleItemHandlerException(String message, SlimefunItem item, ItemH } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/MissingDependencyException.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/MissingDependencyException.java index d88ef290ec..f309cb5124 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/MissingDependencyException.java @@ -1,8 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.api.exceptions; +package io.github.thebusybiscuit.slimefun5.api.exceptions; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; /** * A {@link MissingDependencyException} is thrown when a {@link SlimefunAddon} tried @@ -32,3 +32,4 @@ public MissingDependencyException(SlimefunAddon addon, String dependency) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/PrematureCodeException.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/PrematureCodeException.java index 1918fdb5d5..7dda11e1cd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/PrematureCodeException.java @@ -1,8 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.api.exceptions; +package io.github.thebusybiscuit.slimefun5.api.exceptions; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; /** * A {@link PrematureCodeException} is thrown when a {@link SlimefunAddon} tried @@ -28,3 +28,4 @@ public PrematureCodeException(String message) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/TagMisconfigurationException.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/TagMisconfigurationException.java index 165f5c3be6..75a51f4b0d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/TagMisconfigurationException.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.api.exceptions; +package io.github.thebusybiscuit.slimefun5.api.exceptions; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * An {@link TagMisconfigurationException} is thrown whenever a {@link SlimefunTag} @@ -46,3 +46,4 @@ public TagMisconfigurationException(NamespacedKey key, Throwable cause) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/UnregisteredItemException.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/UnregisteredItemException.java index 2d2549bf00..eda7a95673 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/UnregisteredItemException.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.api.exceptions; +package io.github.thebusybiscuit.slimefun5.api.exceptions; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * An {@link UnregisteredItemException} is thrown whenever a {@link Plugin} tried to @@ -33,3 +33,4 @@ public UnregisteredItemException(SlimefunItem item) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/package-info.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/package-info.java index da014fff27..9af841bb6e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/exceptions/package-info.java @@ -2,4 +2,4 @@ * This package contains all different extensions of {@link java.lang.Exception} that Slimefun * uses internally. */ -package io.github.thebusybiscuit.slimefun4.api.exceptions; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.api.exceptions; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/GEOResource.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/GEOResource.java index 36aa5aee76..cbef780cbb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/GEOResource.java @@ -1,20 +1,20 @@ -package io.github.thebusybiscuit.slimefun4.api.geo; +package io.github.thebusybiscuit.slimefun5.api.geo; import javax.annotation.Nonnull; import org.bukkit.Chunk; -import org.bukkit.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Biome; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; +import io.github.thebusybiscuit.slimefun5.api.events.GEOResourceGenerationEvent; +import io.github.thebusybiscuit.slimefun5.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOMiner; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOScanner; /** * A {@link GEOResource} is a virtual resource that can be thought of as world-gen. @@ -101,3 +101,4 @@ default String getName(@Nonnull Player p) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/ResourceManager.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/ResourceManager.java index e88ec4e15e..95ba9500da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/ResourceManager.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.geo; +package io.github.thebusybiscuit.slimefun5.api.geo; import java.util.ArrayList; import java.util.Comparator; @@ -23,14 +23,14 @@ import io.github.bakedlibs.dough.blocks.BlockPosition; import io.github.bakedlibs.dough.config.Config; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.events.GEOResourceGenerationEvent; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOMiner; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOScanner; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -81,7 +81,7 @@ void register(@Nonnull GEOResource resource) { boolean enabled = config.getOrSetDefault(key + ".enabled", true); if (enabled) { - Slimefun.getRegistry().getGEOResources().add(resource); + Slimefun.getRegistry().getGEOResources().put(resource.getKey(), resource); } if (Slimefun.getMinecraftVersion() != MinecraftVersion.UNIT_TEST) { @@ -276,3 +276,4 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/package-info.java new file mode 100644 index 0000000000..c25e299825 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/geo/package-info.java @@ -0,0 +1,5 @@ +/** + * This package contains classes that are centered around the + * {@link io.github.thebusybiscuit.slimefun5.api.geo.GEOResource} API. + */ +package io.github.thebusybiscuit.slimefun5.api.geo; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/GPSNetwork.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/GPSNetwork.java index 8d3a951188..d8664955f2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/GPSNetwork.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.gps; +package io.github.thebusybiscuit.slimefun5.api.gps; import java.util.HashMap; import java.util.HashSet; @@ -23,19 +23,19 @@ import io.github.bakedlibs.dough.chat.ChatInput; import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.events.WaypointCreateEvent; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.geo.ResourceManager; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.gps.GPSTransmitter; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.Teleporter; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -113,8 +113,8 @@ public int getNetworkComplexity(@Nonnull UUID uuid) { for (Location l : locations) { SlimefunItem item = BlockStorage.check(l); - if (item instanceof GPSTransmitter transmitter) { - level += transmitter.getMultiplier(Math.max(l.getBlockY(), 0)); + if (item instanceof GPSTransmitter) { + GPSTransmitter transmitter = (GPSTransmitter) item; level += transmitter.getMultiplier(Math.max(l.getBlockY(), 0)); } } @@ -174,8 +174,8 @@ public void openTransmitterControlPanel(@Nonnull Player p) { SlimefunItem sfi = BlockStorage.check(l); - if (sfi instanceof GPSTransmitter transmitter) { - int slot = inventory[index]; + if (sfi instanceof GPSTransmitter) { + GPSTransmitter transmitter = (GPSTransmitter) sfi; int slot = inventory[index]; menu.addItem(slot, CustomItemStack.create(SlimefunItems.GPS_TRANSMITTER.item(), "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + transmitter.getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms")); menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler()); @@ -377,3 +377,4 @@ public ResourceManager getResourceManager() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/TeleportationManager.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/TeleportationManager.java index 40035920ba..e5818c8753 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/TeleportationManager.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.api.gps; +package io.github.thebusybiscuit.slimefun5.api.gps; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import java.util.HashSet; import java.util.Set; @@ -19,14 +22,14 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.Teleporter; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -186,7 +189,7 @@ private void cancel(@Nonnull UUID uuid, @Nullable Player p) { teleporterUsers.remove(uuid); if (p != null) { - p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.cancelled")), ChatColors.color("&c&k40&f&c%"), 20, 60, 20); + ReflectionCompat.invoke(p, "sendTitle", ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.cancelled")), ChatColors.color("&c&k40&f&c%"), 20, 60, 20); } } @@ -196,12 +199,12 @@ private void updateProgress(UUID uuid, int speed, int progress, Location source, if (isValid(p, source)) { if (progress > 99) { - p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20); + ReflectionCompat.invoke(p, "sendTitle", ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20); PaperLib.teleportAsync(p, destination).thenAccept(success -> onTeleport(p, destination, success, resistance)); } else { - p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0); + ReflectionCompat.invoke(p, "sendTitle", ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0); - source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F); + ParticleCompat.spawn(source.getWorld(), Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F); SoundEffect.TELEPORT_UPDATE_SOUND.playFor(p); Slimefun.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L); } @@ -226,7 +229,7 @@ private void onTeleport(Player p, Location destination, boolean success, boolean // Spawn some particles for aesthetic reasons. Location loc = new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()); - destination.getWorld().spawnParticle(Particle.PORTAL, loc, 200, 0.2F, 0.8F, 0.2F); + ParticleCompat.spawn(destination.getWorld(), Particle.PORTAL, loc, 200, 0.2F, 0.8F, 0.2F); SoundEffect.TELEPORT_SOUND.playFor(p); teleporterUsers.remove(p.getUniqueId()); } else { @@ -240,3 +243,4 @@ private void onTeleport(Player p, Location destination, boolean success, boolean } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/Waypoint.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/Waypoint.java index 468b70af6b..0b7f55eee6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/Waypoint.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.gps; +package io.github.thebusybiscuit.slimefun5.api.gps; import java.util.Objects; import java.util.UUID; @@ -13,10 +13,10 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; +import io.github.thebusybiscuit.slimefun5.api.events.WaypointCreateEvent; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.Teleporter; /** * A {@link Waypoint} represents a named {@link Location} that was created by a {@link Player}. @@ -181,3 +181,4 @@ public boolean equals(Object obj) { && name.equals(waypoint.getName()); } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/package-info.java new file mode 100644 index 0000000000..a24ffe8e13 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/gps/package-info.java @@ -0,0 +1,5 @@ +/** + * This package stores classes of the API that are related to the + * {@link io.github.thebusybiscuit.slimefun5.api.gps.GPSNetwork}. + */ +package io.github.thebusybiscuit.slimefun5.api.gps; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/HashedArmorpiece.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/HashedArmorpiece.java index 92a66e5a2f..5bd12b1fa3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/HashedArmorpiece.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items; +package io.github.thebusybiscuit.slimefun5.api.items; import java.util.Optional; @@ -8,11 +8,11 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SlimefunArmorTask; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.SlimefunArmorTask; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; /** * This class serves as a way of checking whether a {@link Player} has changed their armor @@ -29,6 +29,9 @@ */ public final class HashedArmorpiece { + // org.bukkit.inventory.meta.Damageable is 1.13+; pre-1.13 stores durability on the ItemStack instead. + private static final boolean DAMAGEABLE_META = classExists("org.bukkit.inventory.meta.Damageable"); + private int hash; private Optional item; @@ -54,15 +57,11 @@ public void update(@Nullable ItemStack stack, @Nullable SlimefunItem item) { if (stack == null || stack.getType() == Material.AIR) { this.hash = 0; } else { - ItemStack copy = stack.clone(); - ItemMeta meta = copy.getItemMeta(); - ((Damageable) meta).setDamage(0); - copy.setItemMeta(meta); - this.hash = copy.hashCode(); + this.hash = normalizedHash(stack); } - if (item instanceof SlimefunArmorPiece armorPiece) { - this.item = Optional.of(armorPiece); + if (item instanceof SlimefunArmorPiece) { + SlimefunArmorPiece armorPiece = (SlimefunArmorPiece) item; this.item = Optional.of(armorPiece); } else { this.item = Optional.empty(); } @@ -80,11 +79,36 @@ public boolean hasDiverged(@Nullable ItemStack stack) { if (stack == null || stack.getType() == Material.AIR) { return hash != 0; } else { - ItemStack copy = stack.clone(); + return normalizedHash(stack) != hash; + } + } + + /** + * Hashes the {@link ItemStack} with its durability normalised to zero, so that natural durability + * loss does not register as a divergence. On 1.13+ the damage lives on the {@link ItemMeta} + * ({@code Damageable#setDamage}, invoked reflectively to avoid referencing a 1.13+ type); on older + * versions it lives on the {@link ItemStack} ({@code setDurability}). + */ + private static int normalizedHash(@Nonnull ItemStack stack) { + ItemStack copy = stack.clone(); + + if (DAMAGEABLE_META) { ItemMeta meta = copy.getItemMeta(); - ((Damageable) meta).setDamage(0); + ReflectionCompat.invoke(meta, "setDamage", 0); copy.setItemMeta(meta); - return copy.hashCode() != hash; + } else { + copy.setDurability((short) 0); + } + + return copy.hashCode(); + } + + private static boolean classExists(@Nonnull String name) { + try { + Class.forName(name); + return true; + } catch (Throwable ignored) { + return false; } } @@ -104,3 +128,4 @@ public String toString() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemGroup.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemGroup.java index 8524c6a7e7..fba542f9cb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemGroup.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items; +package io.github.thebusybiscuit.slimefun5.api.items; import java.util.ArrayList; import java.util.Arrays; @@ -12,20 +12,19 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; -import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedItemFlag; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.groups.LockedItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.groups.SeasonalItemGroup; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedItemFlag; /** * Represents an item group, which structure @@ -84,9 +83,7 @@ public ItemGroup(NamespacedKey key, ItemStack item, int tier) { this.key = key; ItemMeta meta = item.getItemMeta(); - meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - meta.addItemFlags(VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP); + VersionedItemFlag.addFlags(meta, VersionedItemFlag.HIDE_ATTRIBUTES, VersionedItemFlag.HIDE_ENCHANTS, VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP); this.item.setItemMeta(meta); this.tier = tier; } @@ -352,8 +349,8 @@ public void setCrossAddonItemGroup(boolean crossAddonItemGroup) { @Override public final boolean equals(Object obj) { - if (obj instanceof ItemGroup group) { - return group.getKey().equals(this.getKey()); + if (obj instanceof ItemGroup) { + ItemGroup group = (ItemGroup) obj; return group.getKey().equals(this.getKey()); } else { return false; } @@ -386,3 +383,4 @@ public boolean isHidden(@Nonnull Player p) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemHandler.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemHandler.java index 251daefe14..e81e6744d0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemHandler.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.api.items; +package io.github.thebusybiscuit.slimefun5.api.items; import java.util.Optional; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IncompatibleItemHandlerException; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BowShootHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityKillHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; /** * An {@link ItemHandler} represents a certain action that a {@link SlimefunItem} @@ -53,3 +53,4 @@ default Optional validate(@Nonnull SlimefunIte @Nonnull Class getIdentifier(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemSetting.java similarity index 98% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemSetting.java index 4a49b89ec8..981fefbfea 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemSetting.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items; +package io.github.thebusybiscuit.slimefun5.api.items; import java.util.List; import java.util.Objects; @@ -9,7 +9,7 @@ import org.apache.commons.lang.Validate; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This class represents a Setting for a {@link SlimefunItem} that can be modified via @@ -222,3 +222,4 @@ public final boolean equals(Object obj) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemSpawnReason.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemSpawnReason.java index 1d1589afd0..c63655a64f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemSpawnReason.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.api.items; +package io.github.thebusybiscuit.slimefun5.api.items; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemSpawnEvent; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.implementation.items.seasonal.ChristmasPresent; -import io.github.thebusybiscuit.slimefun4.implementation.items.seasonal.EasterEgg; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfContainment; +import io.github.thebusybiscuit.slimefun5.api.events.SlimefunItemSpawnEvent; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.implementation.items.seasonal.ChristmasPresent; +import io.github.thebusybiscuit.slimefun5.implementation.items.seasonal.EasterEgg; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GoldPan; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.PickaxeOfContainment; /** * This enum holds the different reasons as to why we may need to spawn an item. @@ -67,3 +67,4 @@ public enum ItemSpawnReason { MISC; } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemState.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemState.java index 0dfaaef4bb..5ad9316769 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/ItemState.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.api.items; +package io.github.thebusybiscuit.slimefun5.api.items; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; /** * Defines whether a SlimefunItem is enabled, disabled or fall-back to its vanilla behavior. @@ -34,3 +34,4 @@ public enum ItemState { VANILLA_FALLBACK; } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/SlimefunItem.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/SlimefunItem.java index 3d52b81245..90413413ef 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/SlimefunItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items; +package io.github.thebusybiscuit.slimefun5.api.items; import java.util.Arrays; import java.util.Collection; @@ -24,26 +24,26 @@ import io.github.bakedlibs.dough.collections.OptionalMap; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IdConflictException; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; -import io.github.thebusybiscuit.slimefun4.api.exceptions.MissingDependencyException; -import io.github.thebusybiscuit.slimefun4.api.exceptions.UnregisteredItemException; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable; -import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.handlers.GlobalItemHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.SlimefunBranch; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IdConflictException; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IncompatibleItemHandlerException; +import io.github.thebusybiscuit.slimefun5.api.exceptions.MissingDependencyException; +import io.github.thebusybiscuit.slimefun5.api.exceptions.UnregisteredItemException; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.SlimefunRegistry; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotConfigurable; +import io.github.thebusybiscuit.slimefun5.core.attributes.Placeable; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactive; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.handlers.GlobalItemHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting.AutoDisenchanter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting.AutoEnchanter; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -506,6 +506,12 @@ public void register(@Nonnull SlimefunAddon addon) { info("Item was registered during runtime."); load(); } + } catch (IncompatibleItemHandlerException x) { + // Java-8 universal port: on legacy servers an item's material may not be a placeable block + // (a 1.13+ block material falls back to a non-block item), so a BlockTicker/BlockUseHandler + // cannot attach. This is an expected version limitation, not a bug - log it concisely on a + // single line instead of a full error stacktrace, and leave the item unregistered. + Slimefun.logger().log(Level.WARNING, "{0} is unavailable on this Minecraft version ({1})", new Object[] { this, x.getMessage() }); } catch (Exception x) { error("Registering " + toString() + " has failed!", x); } @@ -795,8 +801,8 @@ public final void addItemHandler(ItemHandler... handlers) { itemHandlers.put(handler.getIdentifier(), handler); // Tickers are a special case (at the moment at least) - if (handler instanceof BlockTicker ticker) { - ticking = true; + if (handler instanceof BlockTicker) { + BlockTicker ticker = (BlockTicker) handler; ticking = true; Slimefun.getRegistry().getTickerBlocks().add(getId()); blockTicker = ticker; } @@ -865,7 +871,7 @@ public void postRegister() { */ public final void addOfficialWikipage(@Nonnull String page) { Validate.notNull(page, "Wiki page cannot be null."); - wikiURL = Optional.of("https://github.com/Slimefun/Slimefun4/wiki/" + page); + wikiURL = Optional.of("https://github.com/Slimefun5/Slimefun5/wiki/" + page); } /** @@ -983,9 +989,16 @@ public void info(String message) { */ @ParametersAreNonnullByDefault public void warn(String message) { - Validate.notNull(addon, "Cannot send a warning for an unregistered item!"); - String msg = toString() + ": " + message; + + // Java-8 universal port: an item may warn from its constructor (e.g. about a material that is + // missing on a legacy server) before it has been registered, so addon is still null. Rather + // than throw - which would abort the whole item setup - fall back to Slimefun's own logger. + if (addon == null) { + Slimefun.logger().log(Level.WARNING, msg); + return; + } + addon.getLogger().log(Level.WARNING, msg); if (addon.getBugTrackerURL() != null) { @@ -1016,8 +1029,8 @@ public void error(String message, Throwable throwable) { addon.getLogger().log(Level.SEVERE, message, throwable); // We definitely want to re-throw them during Unit Tests - if (throwable instanceof RuntimeException e && Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { - throw e; + if (throwable instanceof RuntimeException && Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { + RuntimeException e = (RuntimeException) throwable; throw e; } } @@ -1118,8 +1131,8 @@ public boolean canUse(@Nonnull Player p, boolean sendMessage) { @Override public final boolean equals(Object obj) { - if (obj instanceof SlimefunItem item) { - return item.getId().equals(this.getId()); + if (obj instanceof SlimefunItem) { + SlimefunItem item = (SlimefunItem) obj; return item.getId().equals(this.getId()); } else { return false; } @@ -1157,7 +1170,7 @@ public final int hashCode() { return null; } - var delegate = slimefunItemStack.item(); + ItemStack delegate = slimefunItemStack.item(); if (delegate.getType() == Material.AIR) { return null; } @@ -1194,3 +1207,4 @@ public final int hashCode() { return Optional.ofNullable(getByItem(item)); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/SlimefunItemStack.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/SlimefunItemStack.java index 8a427b249f..e383a7e5ea 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/SlimefunItemStack.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items; +package io.github.thebusybiscuit.slimefun5.api.items; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -24,6 +24,7 @@ import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -38,13 +39,14 @@ import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.items.ItemMetaSnapshot; -import io.github.bakedlibs.dough.skins.PlayerHead; -import io.github.bakedlibs.dough.skins.PlayerSkin; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedItemFlag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPlayerHead; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.exceptions.PrematureCodeException; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedItemFlag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link SlimefunItemStack} functions as the base for any @@ -62,6 +64,14 @@ public class SlimefunItemStack { private String texture = null; + /** + * Legacy-safe placeholder material. On servers older than the version that introduced a given + * material, {@code XMaterial#parseMaterial()} returns {@code null}; the universal Java-8 jar + * substitutes this material so the item still registers (with a fallback icon) instead of + * crashing the whole plugin. {@code PAPER} exists on every supported Minecraft version. + */ + private static final Material LEGACY_FALLBACK_MATERIAL = Material.PAPER; + public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item) { delegate = new ItemStack(item); @@ -91,7 +101,18 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nonnull C } public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Consumer consumer) { - this(id, new ItemStack(type), consumer); + this(id, safeStack(type), consumer); + } + + /** + * Builds an {@link ItemStack} from the given {@link Material}, falling back to + * {@link #LEGACY_FALLBACK_MATERIAL} when the material is {@code null} (i.e. it does not exist + * on the running legacy server). This keeps the universal jar from crashing on items whose + * material was introduced in a newer Minecraft version. + */ + @Nonnull + private static ItemStack safeStack(@Nullable Material type) { + return new ItemStack(type != null ? type : LEGACY_FALLBACK_MATERIAL); } public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer consumer) { @@ -122,7 +143,7 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nullable } public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, String... lore) { - this(id, new ItemStack(type), name, lore); + this(id, safeStack(type), name, lore); } public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Color color, @Nullable String name, String... lore) { @@ -141,12 +162,13 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Co im.setLore(lines); } - if (im instanceof LeatherArmorMeta leatherArmorMeta) { - leatherArmorMeta.setColor(color); + if (im instanceof LeatherArmorMeta) { + LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) im; leatherArmorMeta.setColor(color); } - if (im instanceof PotionMeta potionMeta) { - potionMeta.setColor(color); + if (im instanceof PotionMeta) { + PotionMeta potionMeta = (PotionMeta) im; + ReflectionCompat.invoke(potionMeta, "setColor", color); } }); } @@ -167,12 +189,13 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Color color, @Nonnull Poti im.setLore(lines); } - if (im instanceof PotionMeta potionMeta) { - potionMeta.setColor(color); + if (im instanceof PotionMeta) { + PotionMeta potionMeta = (PotionMeta) im; + ReflectionCompat.invoke(potionMeta, "setColor", color); potionMeta.addCustomEffect(effect, true); if (effect.getType().equals(PotionEffectType.SATURATION)) { - im.addItemFlags(VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP); + VersionedItemFlag.addFlags(im, VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP); } } }); @@ -281,11 +304,10 @@ public void setAmount(int amount) { private static @Nonnull ItemStack getSkull(@Nonnull String id, @Nonnull String texture) { if (Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { - return new ItemStack(Material.PLAYER_HEAD); + return MaterialCompat.stack(XMaterial.PLAYER_HEAD); } - PlayerSkin skin = PlayerSkin.fromBase64(getTexture(id, texture)); - return PlayerHead.getItemStack(skin); + return VersionedPlayerHead.getItemStack(getTexture(id, texture)); } private static @Nonnull String getTexture(@Nonnull String id, @Nonnull String texture) { @@ -295,7 +317,7 @@ public void setAmount(int amount) { if (texture.startsWith("ey")) { return texture; } else if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) { - String value = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}"; + String value = "{\"textures\":{\"SKIN\":{\"url\":\"https://textures.minecraft.net/texture/" + texture + "\"}}}"; return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8)); } else { throw new IllegalArgumentException("The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!"); @@ -342,7 +364,7 @@ public Material getType() { } public ItemStack withType(Material type) { - return this.delegate.withType(type); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "withType", type); } public int getAmount() { @@ -414,7 +436,7 @@ public int removeEnchantment(Enchantment ench) { } public void removeEnchantments() { - this.delegate.removeEnchantments(); + ReflectionCompat.invoke(this.delegate, "removeEnchantments"); } public Map serialize() { @@ -422,11 +444,13 @@ public Map serialize() { } public boolean editMeta(Consumer consumer) { - return this.delegate.editMeta(consumer); + Object result = ReflectionCompat.invoke(this.delegate, "editMeta", consumer); + return result instanceof Boolean ? (Boolean) result : false; } public boolean editMeta(Class metaClass, Consumer consumer) { - return this.delegate.editMeta(metaClass, consumer); + Object result = ReflectionCompat.invoke(this.delegate, "editMeta", metaClass, consumer); + return result instanceof Boolean ? (Boolean) result : false; } public ItemMeta getItemMeta() { @@ -439,137 +463,157 @@ public boolean hasItemMeta() { /** @deprecated */ @Deprecated + // Java-8 port: the methods below mirror modern Paper ItemStack APIs that are absent at the 1.8.8 + // compile floor. Their bodies go through ReflectionCompat so they fully work on modern servers and + // degrade gracefully (null / sensible default) on legacy ones. Signatures use compileOnly-stubbed + // Paper/Adventure types. @SuppressWarnings: the Object->generic casts are unchecked by nature. + @SuppressWarnings("unchecked") public String getTranslationKey() { - return this.delegate.getTranslationKey(); + return (String) ReflectionCompat.invoke(this.delegate, "getTranslationKey"); } public ItemStack enchantWithLevels(int levels, boolean allowTreasure, Random random) { - return this.delegate.enchantWithLevels(levels, allowTreasure, random); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "enchantWithLevels", levels, allowTreasure, random); } public ItemStack enchantWithLevels(int levels, RegistryKeySet keySet, Random random) { - return this.delegate.enchantWithLevels(levels, keySet, random); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "enchantWithLevels", levels, keySet, random); } + @SuppressWarnings("unchecked") public HoverEvent asHoverEvent(UnaryOperator op) { - return this.delegate.asHoverEvent(op); + return (HoverEvent) ReflectionCompat.invoke(this.delegate, "asHoverEvent", op); } public Component displayName() { - return this.delegate.displayName(); + return (Component) ReflectionCompat.invoke(this.delegate, "displayName"); } public ItemStack ensureServerConversions() { - return this.delegate.ensureServerConversions(); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "ensureServerConversions"); } public byte[] serializeAsBytes() { - return this.delegate.serializeAsBytes(); + Object result = ReflectionCompat.invoke(this.delegate, "serializeAsBytes"); + return result instanceof byte[] ? (byte[]) result : new byte[0]; } /** @deprecated */ public String getI18NDisplayName() { - return this.delegate.getI18NDisplayName(); + return (String) ReflectionCompat.invoke(this.delegate, "getI18NDisplayName"); } /** @deprecated */ public int getMaxItemUseDuration() { - return this.delegate.getMaxItemUseDuration(); + Object result = ReflectionCompat.invoke(this.delegate, "getMaxItemUseDuration"); + return result instanceof Integer ? (Integer) result : 0; } public int getMaxItemUseDuration(LivingEntity entity) { - return this.delegate.getMaxItemUseDuration(entity); + Object result = ReflectionCompat.invoke(this.delegate, "getMaxItemUseDuration", entity); + return result instanceof Integer ? (Integer) result : 0; } public ItemStack asOne() { - return this.delegate.asOne(); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "asOne"); } public ItemStack asQuantity(int qty) { - return this.delegate.asQuantity(qty); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "asQuantity", qty); } public ItemStack add() { - return this.delegate.add(); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "add"); } public ItemStack add(int qty) { - return this.delegate.add(qty); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "add", qty); } public ItemStack subtract() { - return this.delegate.subtract(); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "subtract"); } public ItemStack subtract(int qty) { - return this.delegate.subtract(qty); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "subtract", qty); } @Deprecated + @SuppressWarnings("unchecked") public List getLore() { - return this.delegate.getLore(); + return (List) ReflectionCompat.invoke(this.delegate, "getLore"); } + @SuppressWarnings("unchecked") public List lore() { - return this.delegate.lore(); + return (List) ReflectionCompat.invoke(this.delegate, "lore"); } @Deprecated public void setLore(List lore) { - this.delegate.setLore(lore); + ReflectionCompat.invoke(this.delegate, "setLore", lore); } public void lore(List lore) { - this.delegate.lore(lore); + ReflectionCompat.invoke(this.delegate, "lore", lore); } public void addItemFlags(ItemFlag... itemFlags) { - this.delegate.addItemFlags(itemFlags); + ReflectionCompat.invoke(this.delegate, "addItemFlags", (Object) itemFlags); } public void removeItemFlags(ItemFlag... itemFlags) { - this.delegate.removeItemFlags(itemFlags); + ReflectionCompat.invoke(this.delegate, "removeItemFlags", (Object) itemFlags); } + @SuppressWarnings("unchecked") public Set getItemFlags() { - return this.delegate.getItemFlags(); + Object result = ReflectionCompat.invoke(this.delegate, "getItemFlags"); + return result instanceof Set ? (Set) result : java.util.Collections.emptySet(); } public boolean hasItemFlag(ItemFlag flag) { - return this.delegate.hasItemFlag(flag); + Object result = ReflectionCompat.invoke(this.delegate, "hasItemFlag", flag); + return result instanceof Boolean ? (Boolean) result : false; } public String translationKey() { - return this.delegate.translationKey(); + return (String) ReflectionCompat.invoke(this.delegate, "translationKey"); } /** @deprecated */ @Deprecated public ItemRarity getRarity() { - return this.delegate.getRarity(); + return (ItemRarity) ReflectionCompat.invoke(this.delegate, "getRarity"); } public boolean isRepairableBy(ItemStack repairMaterial) { - return this.delegate.isRepairableBy(repairMaterial); + Object result = ReflectionCompat.invoke(this.delegate, "isRepairableBy", repairMaterial); + return result instanceof Boolean ? (Boolean) result : false; } public boolean canRepair(ItemStack toBeRepaired) { - return this.delegate.canRepair(toBeRepaired); + Object result = ReflectionCompat.invoke(this.delegate, "canRepair", toBeRepaired); + return result instanceof Boolean ? (Boolean) result : false; } public ItemStack damage(int amount, LivingEntity livingEntity) { - return this.delegate.damage(amount, livingEntity); + return (ItemStack) ReflectionCompat.invoke(this.delegate, "damage", amount, livingEntity); } public boolean isEmpty() { - return this.delegate.isEmpty(); + Object result = ReflectionCompat.invoke(this.delegate, "isEmpty"); + return result instanceof Boolean ? (Boolean) result : (this.delegate == null || this.delegate.getType() == Material.AIR); } + @SuppressWarnings("unchecked") public List computeTooltipLines(TooltipContext tooltipContext, Player player) { - return this.delegate.computeTooltipLines(tooltipContext, player); + return (List) ReflectionCompat.invoke(this.delegate, "computeTooltipLines", tooltipContext, player); } + @SuppressWarnings("unchecked") public HoverEvent asHoverEvent() { - return this.delegate.asHoverEvent(); + return (HoverEvent) ReflectionCompat.invoke(this.delegate, "asHoverEvent"); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/FlexItemGroup.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/FlexItemGroup.java index 92f137dcfc..f77e13edfe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/FlexItemGroup.java @@ -1,19 +1,19 @@ -package io.github.thebusybiscuit.slimefun4.api.items.groups; +package io.github.thebusybiscuit.slimefun5.api.items.groups; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; /** * A {@link FlexItemGroup} is a {@link ItemGroup} inside the {@link SlimefunGuide} that can @@ -97,3 +97,4 @@ public final void remove(@Nonnull SlimefunItem item) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/LockedItemGroup.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/LockedItemGroup.java index 826ddbf301..a7d533f2cf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/LockedItemGroup.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.groups; +package io.github.thebusybiscuit.slimefun5.api.items.groups; import java.util.ArrayList; import java.util.HashSet; @@ -10,15 +10,15 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * Represents a {@link ItemGroup} that cannot be opened until the parent group(s) @@ -166,3 +166,4 @@ public boolean hasUnlocked(@Nonnull Player p, @Nonnull PlayerProfile profile) { return true; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/NestedItemGroup.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/NestedItemGroup.java index 0d99f7347e..289e5c8303 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/NestedItemGroup.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.groups; +package io.github.thebusybiscuit.slimefun5.api.items.groups; import java.util.ArrayList; import java.util.List; @@ -8,19 +8,19 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.guide.GuideHistory; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.guide.SurvivalSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -145,3 +145,4 @@ private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode, } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/SeasonalItemGroup.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/SeasonalItemGroup.java index c61212c265..e7be5062d8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/SeasonalItemGroup.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.groups; +package io.github.thebusybiscuit.slimefun5.api.items.groups; import java.time.LocalDate; import java.time.Month; @@ -7,11 +7,11 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; /** * Represents a {@link ItemGroup} that is only displayed in the Guide during @@ -65,3 +65,4 @@ public boolean isAccessible(@Nonnull Player p) { return super.isAccessible(p); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/SubItemGroup.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/SubItemGroup.java index 35b5aef3d1..626501cef5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/SubItemGroup.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.api.items.groups; +package io.github.thebusybiscuit.slimefun5.api.items.groups; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * The {@link SubItemGroup} is a child {@link ItemGroup} of the @@ -96,3 +96,4 @@ public final void register(@Nonnull SlimefunAddon addon) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/package-info.java new file mode 100644 index 0000000000..cc15d893ca --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/groups/package-info.java @@ -0,0 +1,4 @@ +/** + * This package contains a few {@link io.github.thebusybiscuit.slimefun5.api.items.ItemGroup} variations. + */ +package io.github.thebusybiscuit.slimefun5.api.items.groups; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/package-info.java new file mode 100644 index 0000000000..0a0f1021df --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/package-info.java @@ -0,0 +1,6 @@ +/** + * This package contains a few classes that revolve around the API for + * {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem}, such as + * {@link io.github.thebusybiscuit.slimefun5.api.items.ItemSetting} + */ +package io.github.thebusybiscuit.slimefun5.api.items; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/DoubleRangeSetting.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/DoubleRangeSetting.java index 3caeb974b3..467be76ae5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/DoubleRangeSetting.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This variation of {@link ItemSetting} allows you to define an {@link Double} range @@ -62,3 +62,4 @@ public final double getMaximum() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/EnumSetting.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/EnumSetting.java index a588a02abd..8cc931c76e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/EnumSetting.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import java.util.Arrays; import java.util.stream.Collectors; @@ -6,8 +6,8 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be @@ -76,3 +76,4 @@ public boolean validateInput(String input) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/IntRangeSetting.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/IntRangeSetting.java index 58e5dc34bf..7bd5a1fefa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/IntRangeSetting.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This variation of {@link ItemSetting} allows you to define an {@link Integer} range @@ -62,3 +62,4 @@ public final int getMaximum() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/MaterialTagSetting.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/MaterialTagSetting.java index 047f08d4d5..4b5f431a23 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/MaterialTagSetting.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import java.util.List; import java.util.stream.Collectors; @@ -7,10 +7,10 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; -import org.bukkit.Tag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This variation of {@link ItemSetting} allows you to define a default {@link Tag}. @@ -80,3 +80,4 @@ public boolean validateInput(List input) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/package-info.java new file mode 100644 index 0000000000..ac30de6e17 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/items/settings/package-info.java @@ -0,0 +1,4 @@ +/** + * This package contains various sub classes of {@link io.github.thebusybiscuit.slimefun5.api.items.ItemSetting}. + */ +package io.github.thebusybiscuit.slimefun5.api.items.settings; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/Network.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/Network.java index 49fb36520e..6afa3a43d1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/Network.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.network; +package io.github.thebusybiscuit.slimefun5.api.network; import java.util.ArrayDeque; import java.util.HashSet; @@ -16,9 +16,9 @@ import org.bukkit.World; import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener; +import io.github.thebusybiscuit.slimefun5.core.networks.NetworkManager; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.NetworkListener; /** * An abstract Network class to manage networks in a stateful way @@ -269,3 +269,4 @@ public void tick() { discoverStep(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/NetworkComponent.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/NetworkComponent.java index a741ceadde..069a3abcf9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/NetworkComponent.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.api.network; +package io.github.thebusybiscuit.slimefun5.api.network; -import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; +import io.github.thebusybiscuit.slimefun5.core.networks.NetworkManager; /** * This enum holds the different types of components a {@link Network} can have. @@ -31,4 +31,4 @@ public enum NetworkComponent { */ TERMINUS; -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/NetworkVisualizer.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/NetworkVisualizer.java index 256442972a..d3322a08f3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/NetworkVisualizer.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.api.network; +package io.github.thebusybiscuit.slimefun5.api.network; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import javax.annotation.Nonnull; @@ -7,7 +9,7 @@ import org.bukkit.Location; import org.bukkit.Particle.DustOptions; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; /** * This class represents the visualizer task of a given {@link Network}. @@ -59,7 +61,8 @@ public void run() { * The {@link Location} of our node */ private void spawnParticles(@Nonnull Location l) { - l.getWorld().spawnParticle(VersionedParticle.DUST, l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, 1, 0, 0, 0, 1, particleOptions); + ParticleCompat.spawn(l.getWorld(), VersionedParticle.DUST, l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, 1, 0, 0, 0, 1, particleOptions); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/package-info.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/package-info.java index b2232cf176..e312c1e076 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/network/package-info.java @@ -1,4 +1,4 @@ /** * This package provides the API infrastructure for networks, such as the Cargo- or Energy net. */ -package io.github.thebusybiscuit.slimefun4.api.network; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.api.network; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/package-info.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/package-info.java index 7929e334cc..ae65d81742 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/package-info.java @@ -2,4 +2,4 @@ * This package contains a bunch of classes and sub-packages related to the interaction * with Slimefun via an API. */ -package io.github.thebusybiscuit.slimefun4.api; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.api; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerBackpack.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerBackpack.java index c0886778df..527ef4ac8a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerBackpack.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.player; +package io.github.thebusybiscuit.slimefun5.api.player; import java.io.File; import java.util.ArrayList; @@ -17,9 +17,9 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SlimefunBackpack; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BackpackListener; /** * This class represents the instance of a {@link SlimefunBackpack} that is ready to @@ -264,3 +264,4 @@ public static PlayerBackpack newBackpack(UUID ownerId, int id, int size) { return backpack; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerProfile.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerProfile.java index 8dfc7414f8..d814d46b3e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerProfile.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.player; +package io.github.thebusybiscuit.slimefun5.api.player; import java.util.Collection; import java.util.Iterator; @@ -14,11 +14,11 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.thebusybiscuit.slimefun4.storage.data.PlayerData; +import io.github.thebusybiscuit.slimefun5.storage.data.PlayerData; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -30,18 +30,18 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.events.AsyncProfileLoadEvent; -import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint; -import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.events.AsyncProfileLoadEvent; +import io.github.thebusybiscuit.slimefun5.api.gps.Waypoint; +import io.github.thebusybiscuit.slimefun5.api.items.HashedArmorpiece; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectiveArmor; +import io.github.thebusybiscuit.slimefun5.core.debug.Debug; +import io.github.thebusybiscuit.slimefun5.core.debug.TestCase; +import io.github.thebusybiscuit.slimefun5.core.guide.GuideHistory; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; /** * A class that can store a Player's {@link Research} progress for caching purposes. @@ -403,7 +403,7 @@ public static boolean get(@Nonnull OfflinePlayer p, @Nonnull Consumer armorPiece = armorpiece.getItem(); - if (armorPiece.isPresent() && armorPiece.get() instanceof ProtectiveArmor protectiveArmor) { - for (ProtectionType protectionType : protectiveArmor.getProtectionTypes()) { + if (armorPiece.isPresent() && armorPiece.get() instanceof ProtectiveArmor) { + ProtectiveArmor protectiveArmor = (ProtectiveArmor) armorPiece.get(); for (ProtectionType protectionType : protectiveArmor.getProtectionTypes()) { if (protectionType == type) { if (!protectiveArmor.isFullSetRequired()) { return true; @@ -540,8 +540,7 @@ public int hashCode() { @Override public boolean equals(Object obj) { - return obj instanceof PlayerProfile profile && ownerId.equals(profile.ownerId); - } + return obj instanceof PlayerProfile && ownerId.equals(((PlayerProfile) obj).ownerId); } @Override public String toString() { @@ -549,3 +548,4 @@ public String toString() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/StatusEffect.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/StatusEffect.java index a66daf5fbf..827909c79d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/StatusEffect.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.api.player; +package io.github.thebusybiscuit.slimefun5.api.player; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.util.Optional; import java.util.OptionalInt; @@ -6,8 +8,8 @@ import javax.annotation.Nonnull; -import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import io.github.bakedlibs.dough.common.CommonPatterns; @@ -67,7 +69,7 @@ public void add(@Nonnull Player p, int duration, @Nonnull TimeUnit unit) { * The {@link TimeUnit} for the given duration */ public void add(@Nonnull Player p, int level, int duration, @Nonnull TimeUnit unit) { - PersistentDataAPI.setString(p, getKey(), level + ";" + System.currentTimeMillis() + unit.toMillis(duration)); + PdcCompat.setString(p, getKey(), level + ";" + System.currentTimeMillis() + unit.toMillis(duration)); } /** @@ -80,7 +82,7 @@ public void add(@Nonnull Player p, int level, int duration, @Nonnull TimeUnit un * The level of this effect */ public void addPermanent(@Nonnull Player p, int level) { - PersistentDataAPI.setString(p, getKey(), level + ";0"); + PdcCompat.setString(p, getKey(), level + ";0"); } /** @@ -94,7 +96,7 @@ public void addPermanent(@Nonnull Player p, int level) { * @return Whether this {@link StatusEffect} is currently applied */ public boolean isPresent(@Nonnull Player p) { - Optional optional = PersistentDataAPI.getOptionalString(p, getKey()); + Optional optional = PdcCompat.getOptionalString(p, getKey()); if (optional.isPresent()) { String[] data = CommonPatterns.SEMICOLON.split(optional.get()); @@ -120,7 +122,7 @@ public boolean isPresent(@Nonnull Player p) { * @return An {@link OptionalInt} that describes the result */ public @Nonnull OptionalInt getLevel(@Nonnull Player p) { - Optional optional = PersistentDataAPI.getOptionalString(p, getKey()); + Optional optional = PdcCompat.getOptionalString(p, getKey()); if (optional.isPresent()) { String[] data = CommonPatterns.SEMICOLON.split(optional.get()); @@ -137,7 +139,8 @@ public boolean isPresent(@Nonnull Player p) { * The {@link Player} to clear it from */ public void clear(@Nonnull Player p) { - PersistentDataAPI.remove(p, getKey()); + PdcCompat.remove(p, getKey()); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/package-info.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/package-info.java index b213a63aab..76e0f97d2b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/package-info.java @@ -1,5 +1,5 @@ /** * This package stores API-related classes that are related to a {@link org.bukkit.entity.Player}, - * such as the {@link io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile} for example. + * such as the {@link io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile} for example. */ -package io.github.thebusybiscuit.slimefun4.api.player; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.api.player; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/recipes/RecipeType.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/recipes/RecipeType.java index 1db98b7e6e..ee7d5fc0df 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/recipes/RecipeType.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.recipes; +package io.github.thebusybiscuit.slimefun5.api.recipes; import java.util.ArrayList; import java.util.Arrays; @@ -15,27 +15,28 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.ChatColor; -import org.bukkit.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.recipes.MinecraftRecipe; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AltarRecipe; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AltarRecipe; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientAltar; // TODO: Remove this class and rewrite the recipe system public class RecipeType implements Keyed { - public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(Slimefun.instance(), "multiblock"), CustomItemStack.create(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World")); + public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(Slimefun.instance(), "multiblock"), CustomItemStack.create(XMaterial.BRICKS.parseMaterial(), "&bMultiBlock", "", "&a&oBuild it in the World")); public static final RecipeType ARMOR_FORGE = new RecipeType(new NamespacedKey(Slimefun.instance(), "armor_forge"), SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge"); public static final RecipeType GRIND_STONE = new RecipeType(new NamespacedKey(Slimefun.instance(), "grind_stone"), SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone"); public static final RecipeType SMELTERY = new RecipeType(new NamespacedKey(Slimefun.instance(), "smeltery"), SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery"); @@ -56,7 +57,7 @@ public class RecipeType implements Keyed { public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "mob_drop"), CustomItemStack.create(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item"); public static final RecipeType BARTER_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "barter_drop"), CustomItemStack.create(Material.GOLD_INGOT, "&bBarter Drop"), RecipeType::registerBarterDrop, "&aBarter with piglins for a chance", "&ato obtain this item"); - public static final RecipeType INTERACT = new RecipeType(new NamespacedKey(Slimefun.instance(), "interact"), CustomItemStack.create(Material.PLAYER_HEAD, "&bInteract", "", "&a&oRight click with this item")); + public static final RecipeType INTERACT = new RecipeType(new NamespacedKey(Slimefun.instance(), "interact"), CustomItemStack.create(XMaterial.PLAYER_HEAD.parseMaterial(), "&bInteract", "", "&a&oRight click with this item")); public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(Slimefun.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER); public static final RecipeType FOOD_FABRICATOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR); @@ -92,7 +93,17 @@ public RecipeType(ItemStack item, String machine) { } public RecipeType(NamespacedKey key, SlimefunItemStack slimefunItem, String... lore) { - this(key, slimefunItem.item(), null, lore); + this.item = CustomItemStack.create(slimefunItem.item(), null, lore); + this.key = key; + this.consumer = null; + this.machine = slimefunItem.getItemId(); + } + + public RecipeType(NamespacedKey key, SlimefunItemStack slimefunItem) { + this.item = slimefunItem.item().clone(); + this.key = key; + this.consumer = null; + this.machine = slimefunItem.getItemId(); } public RecipeType(NamespacedKey key, ItemStack item, BiConsumer callback, String... lore) { @@ -109,9 +120,16 @@ public RecipeType(NamespacedKey key, ItemStack item) { } public RecipeType(MinecraftRecipe recipe) { - this.item = new ItemStack(recipe.getMachine()); this.machine = ""; - this.key = NamespacedKey.minecraft(recipe.getRecipeClass().getSimpleName().toLowerCase(Locale.ROOT).replace("recipe", "")); + // A MinecraftRecipe constant can be null on older servers that lack that recipe type or its + // machine material (e.g. SHAPED_CRAFTING's CRAFTING_TABLE on 1.8) - degrade to a generic type. + if (recipe == null) { + this.item = new ItemStack(XMaterial.CRAFTING_TABLE.parseMaterial()); + this.key = NamespacedKey.minecraft("crafting"); + } else { + this.item = new ItemStack(recipe.getMachine()); + this.key = NamespacedKey.minecraft(recipe.getRecipeClass().getSimpleName().toLowerCase(Locale.ROOT).replace("recipe", "")); + } } public void register(ItemStack[] recipe, ItemStack result) { @@ -120,8 +138,8 @@ public void register(ItemStack[] recipe, ItemStack result) { } else { SlimefunItem slimefunItem = SlimefunItem.getById(this.machine); - if (slimefunItem instanceof MultiBlockMachine mbm) { - mbm.addRecipe(recipe, result); + if (slimefunItem instanceof MultiBlockMachine) { + MultiBlockMachine mbm = (MultiBlockMachine) slimefunItem; mbm.addRecipe(recipe, result); } } } @@ -145,8 +163,8 @@ public SlimefunItem getMachine() { @Override public final boolean equals(Object obj) { - if (obj instanceof RecipeType recipeType) { - return recipeType.getKey().equals(this.getKey()); + if (obj instanceof RecipeType) { + RecipeType recipeType = (RecipeType) obj; return recipeType.getKey().equals(this.getKey()); } else { return false; } @@ -165,7 +183,13 @@ private static void registerBarterDrop(ItemStack[] recipe, ItemStack output) { @ParametersAreNonnullByDefault private static void registerMobDrop(ItemStack[] recipe, ItemStack output) { String mob = ChatColor.stripColor(recipe[4].getItemMeta().getDisplayName()).toUpperCase(Locale.ROOT).replace(' ', '_'); - EntityType entity = EntityType.valueOf(mob); + EntityType entity; + try { + entity = EntityType.valueOf(mob); + } catch (IllegalArgumentException e) { + // Mob type doesn't exist on this Minecraft version (e.g. VEX on 1.8); skip its drop. + return; + } Set dropping = Slimefun.getRegistry().getMobDrops().getOrDefault(entity, new HashSet<>()); dropping.add(output); Slimefun.getRegistry().getMobDrops().put(entity, dropping); @@ -227,3 +251,4 @@ public static ItemStack getRecipeOutputList(MultiBlockMachine machine, ItemStack return recipes.get((recipes.indexOf(input) + 1))[0]; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/recipes/package-info.java similarity index 57% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/recipes/package-info.java index ac5c2a8d45..ca2b8d0e41 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/recipes/package-info.java @@ -1,4 +1,4 @@ /** * This package contains all classes related to our recipe system. */ -package io.github.thebusybiscuit.slimefun4.api.recipes; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.api.recipes; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/PlayerResearchTask.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/PlayerResearchTask.java index 010f258f6c..891f9a123e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/PlayerResearchTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.researches; +package io.github.thebusybiscuit.slimefun5.api.researches; import java.util.function.Consumer; @@ -9,12 +9,12 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; +import io.github.thebusybiscuit.slimefun5.api.events.ResearchUnlockEvent; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.guide.options.SlimefunGuideSettings; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.FireworkUtils; /** * A {@link PlayerResearchTask} is run when a {@link Player} unlocks a {@link Research}. @@ -126,3 +126,4 @@ private void onFinish(@Nonnull Player p) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/Research.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/Research.java index c4c96e4e79..052766c11d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/Research.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.researches; +package io.github.thebusybiscuit.slimefun5.api.researches; import java.util.ArrayList; import java.util.LinkedList; @@ -14,21 +14,21 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; -import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerPreResearchEvent; -import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemState; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerPreResearchEvent; +import io.github.thebusybiscuit.slimefun5.api.events.ResearchUnlockEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemState; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideImplementation; +import io.github.thebusybiscuit.slimefun5.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.setup.ResearchSetup; /** * Represents a research, which is bound to one @@ -349,4 +349,4 @@ public static Optional getResearch(@Nullable NamespacedKey key) { public String toString() { return "Research (" + getKey() + ')'; } -} \ No newline at end of file +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/package-info.java new file mode 100644 index 0000000000..482c367ad9 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/api/researches/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds everything connected to the {@link io.github.thebusybiscuit.slimefun5.api.researches.Research} + * class. + */ +package io.github.thebusybiscuit.slimefun5.api.researches; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/SlimefunRegistry.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/SlimefunRegistry.java index ab8d41bd21..83371f2406 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/SlimefunRegistry.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core; +package io.github.thebusybiscuit.slimefun5.core; import java.util.ArrayList; import java.util.Collections; @@ -15,7 +15,7 @@ import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.Server; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -23,21 +23,20 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.bakedlibs.dough.collections.KeyMap; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideImplementation; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlock; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.guide.CheatSheetSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.guide.SurvivalSlimefunGuide; import me.mrCookieSlime.Slimefun.api.BlockInfoConfig; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -81,7 +80,9 @@ public final class SlimefunRegistry { private NamespacedKey itemChargeKey; private NamespacedKey guideKey; - private final KeyMap geoResources = new KeyMap<>(); + // Java-8 universal port: keyed by Slimefun's own NamespacedKey (GEOResource implements our own + // Keyed), so a plain Map is used instead of dough's KeyMap (which is bound to org.bukkit.Keyed). + private final Map geoResources = new HashMap<>(); private final Map profiles = new ConcurrentHashMap<>(); private final Map worlds = new ConcurrentHashMap<>(); @@ -335,7 +336,7 @@ public Map getChunks() { } @Nonnull - public KeyMap getGEOResources() { + public Map getGEOResources() { return geoResources; } @@ -363,3 +364,4 @@ public NamespacedKey getGuideDataKey() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/VersionManager.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/VersionManager.java new file mode 100644 index 0000000000..ff8c143726 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/VersionManager.java @@ -0,0 +1,24 @@ +package io.github.thebusybiscuit.slimefun5.core; + +import org.bukkit.Bukkit; +import io.github.thebusybiscuit.slimefun5.compat.SlimefunNMS; + +public class VersionManager { + + private static SlimefunNMS nms; + + public static SlimefunNMS getNMS() { + if (nms != null) { + return nms; + } + + try { + String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; + nms = (SlimefunNMS) Class.forName("io.github.thebusybiscuit.slimefun5.nms." + version + ".SlimefunNMSImpl").newInstance(); + return nms; + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + throw new RuntimeException("Could not load NMS implementation for version: " + Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3], e); + } + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/DamageableItem.java similarity index 52% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/DamageableItem.java index 74f4a5ef88..5225359fe9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/DamageableItem.java @@ -1,4 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ItemMetaCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCompat; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -7,13 +12,13 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.UnbreakingAlgorithm; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEnchantment; /** * This interface, when attached to a {@link SlimefunItem}, provides an easy method for damaging @@ -51,7 +56,7 @@ public interface DamageableItem extends ItemAttribute { * The {@link ItemStack} to damage */ default void damageItem(@Nonnull Player p, @Nullable ItemStack item) { - if (isDamageable() && item != null && !item.getType().isAir() && item.getAmount() > 0) { + if (isDamageable() && item != null && !MaterialCompat.isAir(item.getType()) && item.getAmount() > 0) { int unbreakingLevel = item.getEnchantmentLevel(VersionedEnchantment.UNBREAKING); if (evaluateUnbreakingEnchantment(unbreakingLevel)) { @@ -60,21 +65,49 @@ default void damageItem(@Nonnull Player p, @Nullable ItemStack item) { ItemMeta meta = item.getItemMeta(); - if (meta != null && !meta.isUnbreakable()) { - Damageable damageable = (Damageable) meta; + if (meta != null && !ItemMetaCompat.isUnbreakable(meta)) { + int maxDurability = item.getType().getMaxDurability(); + // 1.13+ stores damage on the ItemMeta (Damageable, accessed reflectively to avoid a + // 1.13+ type reference); older versions store it on the ItemStack's durability. + int damage = DAMAGEABLE_META ? (Integer) ReflectionCompat.invoke(meta, "getDamage") : item.getDurability(); + + // On 1.8 the interaction event hands us a COPY of the held item, so mutating `item` + // below never reaches the inventory (confirmed: sameRef=false, equalsHand=true). Capture + // whether it came from the main hand so we can write the result back. On 1.9+ the item is + // live, so this write-back is a harmless no-op (or simply skipped for off-hand/non-hand items). + ItemStack heldBefore = p.getInventory().getItemInHand(); + boolean fromHand = heldBefore != null && heldBefore.equals(item); - if (damageable.getDamage() >= item.getType().getMaxDurability()) { + if (damage >= maxDurability) { // No need for a SoundEffect equivalent here since this is supposed to be a vanilla sound. - p.playSound(p.getEyeLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); + SoundCompat.playFor(p, p.getEyeLocation(), "ENTITY_ITEM_BREAK", null, 1, 1); item.setAmount(0); - } else { - damageable.setDamage(damageable.getDamage() + 1); + } else if (DAMAGEABLE_META) { + ReflectionCompat.invoke(meta, "setDamage", damage + 1); item.setItemMeta(meta); + } else { + item.setDurability((short) (damage + 1)); + } + + if (fromHand) { + p.getInventory().setItemInHand(item.getAmount() <= 0 ? null : item); } } } } + // org.bukkit.inventory.meta.Damageable is 1.13+; pre-1.13 uses ItemStack durability instead. + boolean DAMAGEABLE_META = classExists("org.bukkit.inventory.meta.Damageable"); + + static boolean classExists(@Nonnull String name) { + try { + Class.forName(name); + return true; + } catch (Throwable ignored) { + return false; + } + } + /** * This method will randomly decide if the item should be damaged or not * This does not damage the item, it is called by {@link #damageItem(Player, ItemStack)} to randomly generate a @@ -92,3 +125,4 @@ default boolean evaluateUnbreakingEnchantment(int unbreakingLevel) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/DistinctiveItem.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/DistinctiveItem.java index 150bef8319..83e3aa7f62 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/DistinctiveItem.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; import javax.annotation.Nonnull; @@ -31,3 +31,4 @@ public interface DistinctiveItem extends ItemAttribute { */ boolean canStack(@Nonnull ItemMeta itemMetaOne, @Nonnull ItemMeta itemMetaTwo); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/EnergyNetComponent.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/EnergyNetComponent.java index 64a9063ec3..3a9a075a03 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/EnergyNetComponent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import java.util.logging.Level; @@ -8,13 +8,13 @@ import org.bukkit.Location; import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.Capacitor; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -200,3 +200,4 @@ default void removeCharge(@Nonnull Location l, int charge) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/EnergyNetProvider.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/EnergyNetProvider.java index 10dafe4d4b..66cc9b1d4a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/EnergyNetProvider.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; import org.bukkit.Location; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.AbstractEnergyProvider; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.Reactor; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -64,3 +64,4 @@ default boolean willExplode(@Nonnull Location l, @Nonnull Config data) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ExternallyInteractable.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ExternallyInteractable.java index 8204409886..76836c24a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ExternallyInteractable.java @@ -1,7 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.interactions.InteractionResult; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.interactions.InteractionResult; import org.bukkit.Location; import javax.annotation.Nonnull; @@ -28,3 +28,4 @@ public interface ExternallyInteractable { InteractionResult onInteract(@Nonnull Location location); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/HologramOwner.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/HologramOwner.java index b14e32c35c..9bb79923b5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/HologramOwner.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; @@ -7,9 +7,9 @@ import org.bukkit.util.Vector; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector; +import io.github.thebusybiscuit.slimefun5.core.services.holograms.HologramsService; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.HologramProjector; /** * This {@link ItemAttribute} manages holograms. @@ -63,3 +63,4 @@ default Vector getHologramOffset(@Nonnull Block block) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ItemAttribute.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ItemAttribute.java index 44236086ba..edca2dcda8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ItemAttribute.java @@ -1,9 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * An empty interface that only serves the purpose of bundling together all @@ -28,3 +28,4 @@ public interface ItemAttribute { String getId(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineProcessHolder.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineProcessHolder.java index 7a1c283f6b..6abf785ae3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineProcessHolder.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineOperation; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineProcessor; /** * This {@link ItemAttribute} marks a {@link SlimefunItem} as a {@link MachineProcessHolder}. @@ -27,3 +27,4 @@ public interface MachineProcessHolder extends ItemAt MachineProcessor getMachineProcessor(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineTier.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineTier.java index eb01529ece..87e09a95e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineTier.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; @@ -23,3 +23,4 @@ public String toString() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineType.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineType.java index c408e69385..70c939f1b5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/MachineType.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; @@ -20,3 +20,4 @@ public String toString() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotConfigurable.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotConfigurable.java index f69984d9fd..73566c3cae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotConfigurable.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * Implement this interface for any {@link SlimefunItem} to prevent @@ -12,3 +12,4 @@ public interface NotConfigurable extends ItemAttribute { } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotHopperable.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotHopperable.java index 5e284e5695..f6ea87341f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotHopperable.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -12,3 +12,4 @@ public interface NotHopperable extends ItemAttribute { } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotPlaceable.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotPlaceable.java index 464e91b911..551bb5b306 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/NotPlaceable.java @@ -1,9 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * Implement this interface for any {@link SlimefunItem} to prevent @@ -19,3 +19,4 @@ public interface NotPlaceable extends ItemAttribute { } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/PiglinBarterDrop.java similarity index 80% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/PiglinBarterDrop.java index cda9536f8b..afbd9fa6a5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/PiglinBarterDrop.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import org.bukkit.entity.Piglin; import org.bukkit.event.entity.EntityDropItemEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.PiglinListener; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.PiglinListener; /** * This interface, when attached to a {@link SlimefunItem}, provides a variable (0-100%) chance for @@ -33,3 +33,4 @@ public interface PiglinBarterDrop extends ItemAttribute { int getBarteringLootChance(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Placeable.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Placeable.java index 28130d102e..37b80c0192 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Placeable.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import java.util.Collection; @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * DO NOT IMPLEMENT THIS INTERFACE @@ -42,3 +42,4 @@ default boolean useVanillaBlockBreaking() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ProtectionType.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ProtectionType.java index ac0e488c7f..46fa7b330b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ProtectionType.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import org.bukkit.entity.Bee; @@ -30,3 +30,4 @@ public enum ProtectionType { FLYING_INTO_WALL; } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ProtectiveArmor.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ProtectiveArmor.java index f51c943780..c29365013a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/ProtectiveArmor.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.HazmatArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; /** * Implement this interface to a {@link SlimefunArmorPiece} to protect @@ -51,3 +51,4 @@ public interface ProtectiveArmor extends ItemAttribute { @Nullable NamespacedKey getArmorSetId(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RadiationSymptom.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RadiationSymptom.java index 154b48efc4..610c7d067c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RadiationSymptom.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; @@ -8,9 +8,9 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.RadiationUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; /** * An enum of potential radiation symptoms. @@ -68,3 +68,4 @@ public boolean shouldApply(int exposure) { return exposure >= minExposure; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Radioactive.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Radioactive.java index 22b09378d0..7bf55433ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Radioactive.java @@ -1,8 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks @@ -26,3 +26,4 @@ public interface Radioactive extends ItemAttribute { Radioactivity getRadioactivity(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Radioactivity.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Radioactivity.java index 1025e1e073..7a11078174 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Radioactivity.java @@ -1,8 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.RadiationTask; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -85,3 +85,4 @@ public int getRadiationLevel() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RandomMobDrop.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RandomMobDrop.java index a0e51fe32d..1ae088b663 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RandomMobDrop.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.MobDropListener; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.BasicCircuitBoard; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.MobDropListener; /** * This interface, when attached to a {@link SlimefunItem}, provides an easy method for adding @@ -33,3 +33,4 @@ public interface RandomMobDrop extends ItemAttribute { int getMobDropChance(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Rechargeable.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Rechargeable.java index e76348c62f..a752f9d055 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Rechargeable.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.MultiTool; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ChargingBench; -import io.github.thebusybiscuit.slimefun4.utils.ChargeUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.Jetpack; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.MultiTool; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ChargingBench; +import io.github.thebusybiscuit.slimefun5.utils.ChargeUtils; /** * A {@link Rechargeable} {@link SlimefunItem} can hold energy and is able to @@ -148,3 +148,4 @@ default boolean removeItemCharge(ItemStack item, float charge) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RecipeDisplayItem.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RecipeDisplayItem.java index c85cce7f3f..8eca9e7e22 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/RecipeDisplayItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import java.util.List; @@ -7,11 +7,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOMiner; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GoldPan; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -53,3 +53,4 @@ default String getRecipeSectionLabel(@Nonnull Player p) { return "&7\u21E9 " + Slimefun.getLocalization().getMessage(p, getLabelLocalPath()) + " \u21E9"; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Soulbound.java similarity index 62% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Soulbound.java index c8ddd7fbba..8012a2e777 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/Soulbound.java @@ -1,7 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.SoulboundItem; /** * This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks @@ -16,3 +16,4 @@ public interface Soulbound extends ItemAttribute { } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/WitherProof.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/WitherProof.java index 712f0df3ea..984f7483f2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/WitherProof.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes; +package io.github.thebusybiscuit.slimefun5.core.attributes; import javax.annotation.Nonnull; import org.bukkit.block.Block; import org.bukkit.entity.Wither; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.WitherProofBlock; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.WitherProofBlock; /** * This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks @@ -32,3 +32,4 @@ public interface WitherProof extends ItemAttribute { void onAttack(@Nonnull Block block, @Nonnull Wither wither); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/InteractionResult.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/InteractionResult.java index d0b36ae606..fc0b01e643 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/InteractionResult.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes.interactions; +package io.github.thebusybiscuit.slimefun5.core.attributes.interactions; -import io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable; +import io.github.thebusybiscuit.slimefun5.core.attributes.ExternallyInteractable; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; @@ -59,3 +59,4 @@ public boolean hasResultMessage() { return resultMessage; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/ItemInteractionResult.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/ItemInteractionResult.java index 3d93ffaf01..beb43b6a28 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/ItemInteractionResult.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.attributes.interactions; +package io.github.thebusybiscuit.slimefun5.core.attributes.interactions; -import io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable; +import io.github.thebusybiscuit.slimefun5.core.attributes.ExternallyInteractable; import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; @@ -62,3 +62,4 @@ public boolean resultedInItems() { return Collections.unmodifiableSet(resultItems); } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/package-info.java new file mode 100644 index 0000000000..29fe78e62b --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/interactions/package-info.java @@ -0,0 +1,5 @@ +/** + * This package contains the various possible {@link io.github.thebusybiscuit.slimefun5.core.attributes.interactions.InteractionResult}s + * that can be returned by an {@link io.github.thebusybiscuit.slimefun5.core.attributes.ExternallyInteractable} object. + */ +package io.github.thebusybiscuit.slimefun5.core.attributes.interactions; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/package-info.java new file mode 100644 index 0000000000..1e7c9d7be7 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/attributes/package-info.java @@ -0,0 +1,5 @@ +/** + * This package contains all variations of {@link io.github.thebusybiscuit.slimefun5.core.attributes.ItemAttribute} that + * can be assigned to a {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + */ +package io.github.thebusybiscuit.slimefun5.core.attributes; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SlimefunCommand.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SlimefunCommand.java index 4ef1a411a5..cbb1b45c97 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SlimefunCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands; +package io.github.thebusybiscuit.slimefun5.core.commands; import java.util.HashMap; import java.util.LinkedList; @@ -17,8 +17,8 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.SlimefunSubCommands; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.subcommands.SlimefunSubCommands; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link CommandExecutor} holds the functionality of our {@code /slimefun} command. @@ -124,3 +124,4 @@ public void onCommand(PlayerCommandPreprocessEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SlimefunTabCompleter.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SlimefunTabCompleter.java index 50a665f308..20475b8a9c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SlimefunTabCompleter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands; +package io.github.thebusybiscuit.slimefun5.core.commands; import java.util.ArrayList; import java.util.Arrays; @@ -14,10 +14,10 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.debug.TestCase; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class SlimefunTabCompleter implements TabCompleter { @@ -114,3 +114,4 @@ private List getSlimefunItems() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SubCommand.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SubCommand.java index 4b5717a7a6..c4c08c2055 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/SubCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands; +package io.github.thebusybiscuit.slimefun5.core.commands; import java.util.Map; @@ -10,8 +10,8 @@ import org.bukkit.command.defaults.HelpCommand; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This class represents a {@link SubCommand}, it is a {@link Command} that starts with @@ -81,11 +81,12 @@ protected String getDescription() { * @return A possibly localized description of this {@link SubCommand} */ public @Nonnull String getDescription(@Nonnull CommandSender sender) { - if (sender instanceof Player player) { - return Slimefun.getLocalization().getMessage(player, getDescription()); + if (sender instanceof Player) { + Player player = (Player) sender; return Slimefun.getLocalization().getMessage(player, getDescription()); } else { return Slimefun.getLocalization().getMessage(getDescription()); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/package-info.java similarity index 58% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/package-info.java index 13a08a12ac..e98d3c381f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/package-info.java @@ -1,4 +1,4 @@ /** * This package contains everything related to Slimefun's ingame command. */ -package io.github.thebusybiscuit.slimefun4.core.commands; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.commands; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/BackpackCommand.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/BackpackCommand.java index 3e124b8e77..7796bafcec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/BackpackCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import javax.annotation.ParametersAreNonnullByDefault; @@ -9,12 +9,12 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.RestoredBackpack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.RestoredBackpack; /** * This command that allows for backpack retrieval in the event they are lost. @@ -40,8 +40,8 @@ protected String getDescription() { @Override public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - if (sender.hasPermission("slimefun.command.backpack")) { + if (sender instanceof Player) { + Player player = (Player) sender; if (sender.hasPermission("slimefun.command.backpack")) { if (args.length != 3) { Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack ")); return; @@ -83,3 +83,4 @@ public void onExecute(CommandSender sender, String[] args) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/ChargeCommand.java similarity index 59% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/ChargeCommand.java index 119091e1e6..39156f0902 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/ChargeCommand.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,11 +8,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * {@link ChargeCommand} adds an in game command which charges any {@link Rechargeable} @@ -33,13 +35,13 @@ protected String getDescription() { @Override public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - if (sender.hasPermission("slimefun.command.charge")) { - ItemStack item = player.getInventory().getItemInMainHand(); + if (sender instanceof Player) { + Player player = (Player) sender; if (sender.hasPermission("slimefun.command.charge")) { + ItemStack item = HandCompat.getMainHand(player.getInventory()); SlimefunItem slimefunItem = SlimefunItem.getByItem(item); - if (slimefunItem instanceof Rechargeable rechargeableItem) { - rechargeableItem.setItemCharge(item, rechargeableItem.getMaxItemCharge(item)); + if (slimefunItem instanceof Rechargeable) { + Rechargeable rechargeableItem = (Rechargeable) slimefunItem; rechargeableItem.setItemCharge(item, rechargeableItem.getMaxItemCharge(item)); Slimefun.getLocalization().sendMessage(sender, "commands.charge.charge-success", true); } else { Slimefun.getLocalization().sendMessage(sender, "commands.charge.not-rechargeable", true); @@ -52,3 +54,4 @@ public void onExecute(CommandSender sender, String[] args) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/CheatCommand.java similarity index 60% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/CheatCommand.java index 973ed1ee39..8422071b20 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/CheatCommand.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class CheatCommand extends SubCommand { @@ -19,8 +19,8 @@ class CheatCommand extends SubCommand { @Override public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - if (sender.hasPermission("slimefun.cheat.items")) { + if (sender instanceof Player) { + Player player = (Player) sender; if (sender.hasPermission("slimefun.cheat.items")) { SlimefunGuide.openCheatMenu(player); } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); @@ -31,3 +31,4 @@ public void onExecute(CommandSender sender, String[] args) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/DebugCommand.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/DebugCommand.java index 12c567cb14..54bcc1ee95 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/DebugCommand.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import javax.annotation.Nonnull; import org.bukkit.command.CommandSender; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.core.debug.Debug; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * The debug command will allow server owners to get information for us developers. @@ -54,3 +54,4 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/DebugFishCommand.java similarity index 51% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/DebugFishCommand.java index 7b0c85b277..b2369401af 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/DebugFishCommand.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; class DebugFishCommand extends SubCommand { @@ -19,11 +19,12 @@ class DebugFishCommand extends SubCommand { @Override public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player player && sender.hasPermission("slimefun.debugging")) { - player.getInventory().addItem(SlimefunItems.DEBUG_FISH.item()); + if (sender instanceof Player && sender.hasPermission("slimefun.debugging")) { + Player player = (Player) sender; player.getInventory().addItem(SlimefunItems.DEBUG_FISH.item()); } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/GiveCommand.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/GiveCommand.java index cdf67f5bab..57c896294d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/GiveCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import java.util.Locale; import java.util.Map; @@ -13,11 +13,11 @@ import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.common.PlayerList; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class GiveCommand extends SubCommand { @@ -94,3 +94,4 @@ private int parseAmount(String[] args) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/GuideCommand.java similarity index 61% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/GuideCommand.java index 006744d6c7..2ed179c4c7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/GuideCommand.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class GuideCommand extends SubCommand { @@ -20,8 +20,8 @@ class GuideCommand extends SubCommand { @Override public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - if (sender.hasPermission("slimefun.command.guide")) { + if (sender instanceof Player) { + Player player = (Player) sender; if (sender.hasPermission("slimefun.command.guide")) { SlimefunGuideMode design = SlimefunGuide.getDefaultMode(); player.getInventory().addItem(SlimefunGuide.getItem(design).clone()); } else { @@ -33,3 +33,4 @@ public void onExecute(CommandSender sender, String[] args) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/HelpCommand.java similarity index 62% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/HelpCommand.java index b3e411d388..f6c8d3dafc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/HelpCommand.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.command.CommandSender; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class HelpCommand extends SubCommand { @@ -21,3 +21,4 @@ public void onExecute(CommandSender sender, String[] args) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/OpenGuideCommand.java similarity index 60% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/OpenGuideCommand.java index 83db842925..ff4003bb9a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/OpenGuideCommand.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class OpenGuideCommand extends SubCommand { @@ -21,8 +21,8 @@ class OpenGuideCommand extends SubCommand { @Override @ParametersAreNonnullByDefault public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - if (sender.hasPermission("slimefun.command.open_guide")) { + if (sender instanceof Player) { + Player player = (Player) sender; if (sender.hasPermission("slimefun.command.open_guide")) { SlimefunGuide.openGuide(player, SlimefunGuideMode.SURVIVAL_MODE); } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); @@ -33,3 +33,4 @@ public void onExecute(CommandSender sender, String[] args) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/ResearchCommand.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/ResearchCommand.java index 8b81c87b53..1315a982a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/ResearchCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import java.util.Optional; import java.util.function.UnaryOperator; @@ -10,11 +10,11 @@ import org.bukkit.entity.Player; import io.github.bakedlibs.dough.common.PlayerList; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class ResearchCommand extends SubCommand { @@ -117,3 +117,4 @@ private Optional getResearchFromString(@Nonnull String input) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/SearchCommand.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/SearchCommand.java index 9783518b17..b68e31d20d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/SearchCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import java.util.Arrays; @@ -7,12 +7,12 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class SearchCommand extends SubCommand { @@ -23,8 +23,8 @@ class SearchCommand extends SubCommand { @Override public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - if (sender.hasPermission("slimefun.command.search")) { + if (sender instanceof Player) { + Player player = (Player) sender; if (sender.hasPermission("slimefun.command.search")) { if (args.length > 1) { String query = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); PlayerProfile.get(player, profile -> SlimefunGuide.openSearch(profile, query, SlimefunGuideMode.SURVIVAL_MODE, true)); @@ -40,3 +40,4 @@ public void onExecute(CommandSender sender, String[] args) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/SlimefunSubCommands.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/SlimefunSubCommands.java index 17d70bce3e..f90beefac6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/SlimefunSubCommands.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import java.util.Collection; import java.util.LinkedList; @@ -6,9 +6,9 @@ import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This class holds the implementations of every {@link SubCommand}. @@ -46,3 +46,4 @@ public static Collection getAllCommands(@Nonnull SlimefunCommand cmd return commands; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/StatsCommand.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/StatsCommand.java index cb9069eb6a..b3208bac31 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/StatsCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import java.util.Optional; @@ -9,10 +9,10 @@ import org.bukkit.entity.Player; import io.github.bakedlibs.dough.common.PlayerList; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class StatsCommand extends SubCommand { @@ -41,11 +41,12 @@ public void onExecute(CommandSender sender, String[] args) { } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); } - } else if (sender instanceof Player player) { - PlayerProfile.get(player, profile -> profile.sendStats(sender)); + } else if (sender instanceof Player) { + Player player = (Player) sender; PlayerProfile.get(player, profile -> profile.sendStats(sender)); } else { Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/TeleporterCommand.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/TeleporterCommand.java index 891ba85059..9f441c8978 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/TeleporterCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,9 +8,9 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class TeleporterCommand extends SubCommand { @@ -21,8 +21,8 @@ class TeleporterCommand extends SubCommand { @Override public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player player) { - if (sender.hasPermission("slimefun.command.teleporter")) { + if (sender instanceof Player) { + Player player = (Player) sender; if (sender.hasPermission("slimefun.command.teleporter")) { if (args.length == 1) { Slimefun.getGPSNetwork().getTeleportationManager().openTeleporterGUI(player, player.getUniqueId(), player.getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999); } else if (args.length == 2) { @@ -47,3 +47,4 @@ public void onExecute(CommandSender sender, String[] args) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/TimingsCommand.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/TimingsCommand.java index 3dfd8a78cc..844ae7713e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/TimingsCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import java.util.Arrays; import java.util.HashSet; @@ -12,13 +12,13 @@ import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.ConsolePerformanceInspector; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.PlayerPerformanceInspector; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.core.services.profiler.PerformanceInspector; +import io.github.thebusybiscuit.slimefun5.core.services.profiler.SummaryOrderType; +import io.github.thebusybiscuit.slimefun5.core.services.profiler.inspectors.ConsolePerformanceInspector; +import io.github.thebusybiscuit.slimefun5.core.services.profiler.inspectors.PlayerPerformanceInspector; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class TimingsCommand extends SubCommand { @@ -99,10 +99,11 @@ private boolean hasFlag(String[] args, String flag) { @Nonnull @ParametersAreNonnullByDefault private PerformanceInspector inspectorOf(CommandSender sender, boolean verbose, SummaryOrderType orderType) { - if (sender instanceof Player player) { - return new PlayerPerformanceInspector(player, orderType); + if (sender instanceof Player) { + Player player = (Player) sender; return new PlayerPerformanceInspector(player, orderType); } else { return new ConsolePerformanceInspector(sender, verbose, orderType); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/VersionsCommand.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/VersionsCommand.java index 34ff1f4a20..741a7d962c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/VersionsCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; import java.util.Collection; @@ -10,18 +10,19 @@ import org.bukkit.command.ConsoleCommandSender; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; import io.papermc.lib.PaperLib; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.hover.content.Text; +import net.md_5.bungee.api.chat.TextComponent; /** * This is our class for the /sf versions subcommand. @@ -57,7 +58,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { * so we will just fix this inconsistency for them :) */ String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName(); - ComponentBuilder builder = new ComponentBuilder(); + ComponentBuilder builder = new ComponentBuilder(""); // @formatter:off builder.append("This Server uses the following setup of Slimefun:\n") @@ -75,7 +76,7 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { if (!Slimefun.getUpdater().isLatestVersion()) { builder .append(" (").color(ChatColor.GRAY) - .append("Update available").color(ChatColor.RED).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text( + .append("Update available").color(ChatColor.RED).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText( "Your Slimefun version is out of date!\n" + "Please update to get the latest bug fixes and performance improvements.\n" + "Please do not report any bugs without updating first." @@ -100,7 +101,8 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { builder.append("\n").event((HoverEvent) null); addPluginVersions(builder); - sender.spigot().sendMessage(builder.create()); + // CommandSender#spigot() is post-1.8; reached reflectively (no-op on legacy). + ReflectionCompat.invoke(ReflectionCompat.invoke(sender, "spigot"), "sendMessage", (Object) builder.create()); } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); } @@ -112,7 +114,7 @@ private void addJavaVersion(@Nonnull ComponentBuilder builder) { if (version < RECOMMENDED_JAVA_VERSION) { // @formatter:off builder.append("Java " + version).color(ChatColor.RED) - .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text( + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText( "Your Java version is out of date!\n!" + "You should use Java " + RECOMMENDED_JAVA_VERSION + " or higher.\n" + JAVA_VERSION_NOTICE @@ -148,49 +150,49 @@ private void addPluginVersions(@Nonnull ComponentBuilder builder) { secondaryColor = ChatColor.DARK_GREEN; String authors = String.join(", ", plugin.getDescription().getAuthors()); - if (plugin instanceof SlimefunAddon addon && addon.getBugTrackerURL() != null) { - // @formatter:off - hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder() + if (plugin instanceof SlimefunAddon && ((SlimefunAddon) plugin).getBugTrackerURL() != null) { + SlimefunAddon addon = (SlimefunAddon) plugin; // @formatter:off + hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("") .append("Author(s): ") .append(authors) .color(ChatColor.YELLOW) .append("\n> Click here to go to their issues tracker") .color(ChatColor.GOLD) .create() - )); + ); // @formatter:on clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, addon.getBugTrackerURL()); } else { // @formatter:off - hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder() + hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("") .append("Author(s): ") .append(authors) .color(ChatColor.YELLOW) .create() - )); + ); // @formatter:on } } else { primaryColor = ChatColor.RED; secondaryColor = ChatColor.DARK_RED; - if (plugin instanceof SlimefunAddon addon && addon.getBugTrackerURL() != null) { - // @formatter:off - hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new ComponentBuilder() + if (plugin instanceof SlimefunAddon && ((SlimefunAddon) plugin).getBugTrackerURL() != null) { + SlimefunAddon addon = (SlimefunAddon) plugin; // @formatter:off + hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("") .append("This plugin is disabled.\nCheck the console for an error message.") .color(ChatColor.RED) .append("\n> Click here to report on their issues tracker") .color(ChatColor.DARK_RED) .create() - )); + ); // @formatter:on if (addon.getBugTrackerURL() != null) { clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, addon.getBugTrackerURL()); } } else { - hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Plugin is disabled. Check the console for an error and report on their issues tracker.")); + hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("Plugin is disabled. Check the console for an error and report on their issues tracker.")); } } @@ -209,3 +211,4 @@ private void addPluginVersions(@Nonnull ComponentBuilder builder) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/package-info.java similarity index 51% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/package-info.java index c1b87ef5c7..ee7c7989df 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/commands/subcommands/package-info.java @@ -1,5 +1,5 @@ /** - * This package holds all implementations of {@link io.github.thebusybiscuit.slimefun4.core.commands.SubCommand}. + * This package holds all implementations of {@link io.github.thebusybiscuit.slimefun5.core.commands.SubCommand}. * You can find all sub commands of Slimefun in here. */ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.commands.subcommands; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/Debug.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/Debug.java index 50a05c309e..d3cbbde4c2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/Debug.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.core.debug; +package io.github.thebusybiscuit.slimefun5.core.debug; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This class is responsible for debug logging. @@ -132,3 +132,4 @@ public static void setTestCase(@Nullable String test) { return testCase; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/TestCase.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/TestCase.java index e41ecddc42..5314efb56b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/TestCase.java @@ -1,12 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.core.debug; +package io.github.thebusybiscuit.slimefun5.core.debug; import java.util.Arrays; import java.util.List; import java.util.Locale; +import java.util.stream.Collectors; import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.core.services.AnalyticsService; +import io.github.thebusybiscuit.slimefun5.core.services.AnalyticsService; /** * Test cases in Slimefun. These are very useful for debugging why behavior is happening. @@ -34,7 +35,7 @@ public enum TestCase { */ ANALYTICS; - public static final List VALUES_LIST = Arrays.stream(values()).map(TestCase::toString).toList(); + public static final List VALUES_LIST = Arrays.stream(values()).map(TestCase::toString).collect(Collectors.toList()); TestCase() {} @@ -43,3 +44,4 @@ public enum TestCase { return "slimefun_" + name().toLowerCase(Locale.ROOT); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/package-info.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/package-info.java index 57ef3809c0..edf4d6cf53 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/debug/package-info.java @@ -2,4 +2,4 @@ * This package holds the debug functionality of Slimefun, these can be used as addons but are mostly just * going to be used by Slimefun itself. */ -package io.github.thebusybiscuit.slimefun4.core.debug; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.debug; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/GuideEntry.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/GuideEntry.java index 14f65fd071..60d698ddbf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/GuideEntry.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun5.core.guide; import javax.annotation.Nonnull; @@ -26,3 +26,4 @@ public void setPage(int page) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/GuideHistory.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/GuideHistory.java index d84adcfee2..76c40503c8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/GuideHistory.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun5.core.guide; import java.util.Deque; import java.util.LinkedList; @@ -10,9 +10,9 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; /** * {@link GuideHistory} represents the browsing history of a {@link Player} through the @@ -188,17 +188,18 @@ public void goBack(@Nonnull SlimefunGuideImplementation guide) { private void open(@Nonnull SlimefunGuideImplementation guide, @Nullable GuideEntry entry) { if (entry == null) { guide.openMainMenu(profile, mainMenuPage); - } else if (entry.getIndexedObject() instanceof ItemGroup group) { - guide.openItemGroup(profile, group, entry.getPage()); - } else if (entry.getIndexedObject() instanceof SlimefunItem item) { - guide.displayItem(profile, item, false); - } else if (entry.getIndexedObject() instanceof ItemStack stack) { - guide.displayItem(profile, stack, entry.getPage(), false); - } else if (entry.getIndexedObject() instanceof String query) { - guide.openSearch(profile, query, false); + } else if (entry.getIndexedObject() instanceof ItemGroup) { + ItemGroup group = (ItemGroup) entry.getIndexedObject(); guide.openItemGroup(profile, group, entry.getPage()); + } else if (entry.getIndexedObject() instanceof SlimefunItem) { + SlimefunItem item = (SlimefunItem) entry.getIndexedObject(); guide.displayItem(profile, item, false); + } else if (entry.getIndexedObject() instanceof ItemStack) { + ItemStack stack = (ItemStack) entry.getIndexedObject(); guide.displayItem(profile, stack, entry.getPage(), false); + } else if (entry.getIndexedObject() instanceof String) { + String query = (String) entry.getIndexedObject(); guide.openSearch(profile, query, false); } else { throw new IllegalStateException("Unknown GuideHistory entry: " + entry.getIndexedObject()); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuide.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuide.java index 91f70a6c80..3d0c593b8b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuide.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun5.core.guide; import java.util.Optional; @@ -10,13 +10,13 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.guide.SurvivalSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.SlimefunGuideItem; /** * This is a static utility class that provides convenient access to the methods @@ -131,3 +131,4 @@ public static SlimefunGuideMode getDefaultMode() { return SlimefunGuideMode.SURVIVAL_MODE; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuideImplementation.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuideImplementation.java index d035715ed7..6717171a93 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuideImplementation.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun5.core.guide; import java.util.function.Consumer; @@ -9,13 +9,13 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.guide.options.SlimefunGuideSettings; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.guide.SurvivalSlimefunGuide; /** * This interface is used for the different implementations that add behaviour @@ -78,3 +78,4 @@ default void unlockItem(Player p, SlimefunItem sfitem, Consumer callback } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuideMode.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuideMode.java index 5b269f96e4..0c1355ed9b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/SlimefunGuideMode.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun5.core.guide; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This enum holds the different designs a {@link SlimefunGuide} can have. @@ -26,3 +26,4 @@ public enum SlimefunGuideMode { CHEAT_MODE; } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/ContributorsMenu.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/ContributorsMenu.java index 06d06c3379..74bd9b9ea2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/ContributorsMenu.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.guide.options; +package io.github.thebusybiscuit.slimefun5.core.guide.options; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.Comparator; @@ -13,12 +15,12 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.core.services.github.Contributor; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.core.services.github.Contributor; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -42,7 +44,7 @@ public static void open(Player p, int page) { menu.addItem(1, ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings"))); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { - SlimefunGuideSettings.openSettings(pl, p.getInventory().getItemInMainHand()); + SlimefunGuideSettings.openSettings(pl, HandCompat.getMainHand(p.getInventory())); return false; }); @@ -127,3 +129,4 @@ private static ItemStack getContributorHead(Player p, Contributor contributor) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/FireworksOption.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/FireworksOption.java index d16b85a170..61fcd6ddb3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/FireworksOption.java @@ -1,18 +1,21 @@ -package io.github.thebusybiscuit.slimefun4.core.guide.options; +package io.github.thebusybiscuit.slimefun5.core.guide.options; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.util.List; import java.util.Optional; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.core.SlimefunRegistry; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class FireworksOption implements SlimefunGuideOption { @@ -38,7 +41,7 @@ public Optional getDisplayItem(Player p, ItemStack guide) { lore.add(""); lore.add("&7\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.options.fireworks." + optionState + ".click")); - ItemStack item = CustomItemStack.create(Material.FIREWORK_ROCKET, lore); + ItemStack item = CustomItemStack.create(XMaterial.FIREWORK_ROCKET.parseMaterial(), lore); return Optional.of(item); } else { return Optional.empty(); @@ -54,13 +57,14 @@ public void onClick(Player p, ItemStack guide) { @Override public Optional getSelectedOption(Player p, ItemStack guide) { NamespacedKey key = getKey(); - boolean value = !PersistentDataAPI.hasByte(p, key) || PersistentDataAPI.getByte(p, key) == (byte) 1; + boolean value = !PdcCompat.hasByte(p, key) || PdcCompat.getByte(p, key) == (byte) 1; return Optional.of(value); } @Override public void setSelectedOption(Player p, ItemStack guide, Boolean value) { - PersistentDataAPI.setByte(p, getKey(), value.booleanValue() ? (byte) 1 : (byte) 0); + PdcCompat.setByte(p, getKey(), value.booleanValue() ? (byte) 1 : (byte) 0); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/GuideModeOption.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/GuideModeOption.java index 92ede97bc9..1288ef0419 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/GuideModeOption.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide.options; +package io.github.thebusybiscuit.slimefun5.core.guide.options; import java.util.ArrayList; import java.util.List; @@ -9,17 +9,18 @@ import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; class GuideModeOption implements SlimefunGuideOption { @@ -52,7 +53,7 @@ public Optional getDisplayItem(Player p, ItemStack guide) { if (selectedMode == SlimefunGuideMode.SURVIVAL_MODE) { item.setType(Material.CHEST); } else { - item.setType(Material.COMMAND_BLOCK); + item.setType(XMaterial.COMMAND_BLOCK.parseMaterial()); } ItemMeta meta = item.getItemMeta(); @@ -116,3 +117,4 @@ public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideMode value } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/LearningAnimationOption.java similarity index 80% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/LearningAnimationOption.java index ee62bbbf07..3474588876 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/LearningAnimationOption.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.guide.options; +package io.github.thebusybiscuit.slimefun5.core.guide.options; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.util.List; import java.util.Optional; @@ -6,15 +8,15 @@ import javax.annotation.Nonnull; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.core.SlimefunRegistry; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * {@link LearningAnimationOption} represents a setting in the Slimefun guide book. @@ -65,13 +67,14 @@ public void onClick(@Nonnull Player p, @Nonnull ItemStack guide) { @Override public Optional getSelectedOption(@Nonnull Player p, @Nonnull ItemStack guide) { NamespacedKey key = getKey(); - boolean value = !PersistentDataAPI.hasByte(p, key) || PersistentDataAPI.getByte(p, key) == (byte) 1; + boolean value = !PdcCompat.hasByte(p, key) || PdcCompat.getByte(p, key) == (byte) 1; return Optional.of(value); } @Override public void setSelectedOption(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull Boolean value) { - PersistentDataAPI.setByte(p, getKey(), (byte) (value.booleanValue() ? 1 : 0)); + PdcCompat.setByte(p, getKey(), (byte) (value.booleanValue() ? 1 : 0)); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/PlayerLanguageOption.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/PlayerLanguageOption.java index 8633f17a54..2168eca392 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/PlayerLanguageOption.java @@ -1,25 +1,27 @@ -package io.github.thebusybiscuit.slimefun4.core.guide.options; +package io.github.thebusybiscuit.slimefun5.core.guide.options; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerLanguageChangeEvent; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerLanguageChangeEvent; +import io.github.thebusybiscuit.slimefun5.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -69,9 +71,9 @@ public Optional getSelectedOption(Player p, ItemStack guide) { @Override public void setSelectedOption(Player p, ItemStack guide, String value) { if (value == null) { - PersistentDataAPI.remove(p, getKey()); + PdcCompat.remove(p, getKey()); } else { - PersistentDataAPI.setString(p, getKey(), value); + PdcCompat.setString(p, getKey(), value); } } @@ -89,7 +91,7 @@ private void openLanguageSelection(Player p, ItemStack guide) { }); } else if (i == 7) { menu.addItem(7, CustomItemStack.create(SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"), "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.translations.lore")), (pl, slot, item, action) -> { - ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun"); + ChatUtils.sendURL(pl, "https://github.com/Slimefun5/Slimefun5/wiki/Translating-Slimefun"); pl.closeInventory(); return false; }); @@ -132,3 +134,4 @@ private void openLanguageSelection(Player p, ItemStack guide) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/SlimefunGuideOption.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/SlimefunGuideOption.java index 1caeb02826..c62a186756 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/SlimefunGuideOption.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.core.guide.options; +package io.github.thebusybiscuit.slimefun5.core.guide.options; import java.util.Optional; import javax.annotation.Nonnull; -import org.bukkit.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; /** * This interface represents an option in the {@link SlimefunGuide}. @@ -38,3 +38,4 @@ public interface SlimefunGuideOption extends Keyed { void setSelectedOption(Player p, ItemStack guide, T value); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/SlimefunGuideSettings.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/SlimefunGuideSettings.java index a1e310e4fc..b3b793be79 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/SlimefunGuideSettings.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide.options; +package io.github.thebusybiscuit.slimefun5.core.guide.options; import java.util.ArrayList; import java.util.List; @@ -10,22 +10,23 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.core.services.LocalizationService; +import io.github.thebusybiscuit.slimefun5.core.services.github.GitHubService; +import io.github.thebusybiscuit.slimefun5.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -109,7 +110,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { }); // @formatter:off - menu.addItem(4, CustomItemStack.create(Material.WRITABLE_BOOK, + menu.addItem(4, CustomItemStack.create(XMaterial.WRITABLE_BOOK.parseMaterial(), ChatColor.GREEN + locale.getMessage(p, "guide.title.versions"), "&7&o" + locale.getMessage(p, "guide.tooltips.versions-notice"), "", @@ -120,13 +121,13 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { // @formatter:on // @formatter:off - menu.addItem(6, CustomItemStack.create(Material.COMPARATOR, + menu.addItem(6, CustomItemStack.create(XMaterial.COMPARATOR.parseMaterial(), "&e" + locale.getMessage(p, "guide.title.source"), "", "&7Last Activity: &a" + NumberUtils.getElapsedTime(github.getLastUpdate()) + " ago", "&7Forks: &e" + github.getForks(), "&7Stars: &e" + github.getStars(), "", - "&7&oSlimefun 4 is a community project,", + "&7&oSlimefun is a community project,", "&7&othe source code is available on GitHub", "&7&oand if you want to keep this Plugin alive,", "&7&othen please consider contributing to it", @@ -136,12 +137,12 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { menu.addMenuClickHandler(6, (pl, slot, item, action) -> { pl.closeInventory(); - ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4"); + ChatUtils.sendURL(pl, "https://github.com/Slimefun5/Slimefun5"); return false; }); // @formatter:off - menu.addItem(8, CustomItemStack.create(Material.KNOWLEDGE_BOOK, + menu.addItem(8, CustomItemStack.create(XMaterial.KNOWLEDGE_BOOK.parseMaterial(), "&3" + locale.getMessage(p, "guide.title.wiki"), "", "&7Do you need help with an Item or machine?", "&7You cannot figure out what to do?", @@ -153,7 +154,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { menu.addMenuClickHandler(8, (pl, slot, item, action) -> { pl.closeInventory(); - ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki"); + ChatUtils.sendURL(pl, "https://github.com/Slimefun5/Slimefun5/wiki"); return false; }); @@ -167,18 +168,18 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { "", "&7Installed on this Server: &b" + Slimefun.getInstalledAddons().size(), "", - "&7\u21E8 &eClick to see all available addons for Slimefun4")); + "&7\u21E8 &eClick to see all available addons for Slimefun5")); // @formatter:on menu.addMenuClickHandler(47, (pl, slot, item, action) -> { pl.closeInventory(); - ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki/Addons"); + ChatUtils.sendURL(pl, "https://github.com/Slimefun5/Slimefun5/wiki/Addons"); return false; }); if (Slimefun.getUpdater().getBranch().isOfficial()) { // @formatter:off - menu.addItem(49, CustomItemStack.create(Material.REDSTONE_TORCH, + menu.addItem(49, CustomItemStack.create(XMaterial.REDSTONE_TORCH.parseMaterial(), "&4" + locale.getMessage(p, "guide.title.bugs"), "", "&7&oBug reports have to be made in English!", @@ -186,19 +187,19 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { "&7Open Issues: &a" + github.getOpenIssues(), "&7Pending Pull Requests: &a" + github.getPendingPullRequests(), "", - "&7\u21E8 &eClick to go to the Slimefun4 Bug Tracker")); + "&7\u21E8 &eClick to go to the Slimefun5 Bug Tracker")); // @formatter:on menu.addMenuClickHandler(49, (pl, slot, item, action) -> { pl.closeInventory(); - ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/issues"); + ChatUtils.sendURL(pl, "https://github.com/Slimefun5/Slimefun5/issues"); return false; }); } else { menu.addItem(49, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(51, CustomItemStack.create(Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> { + menu.addItem(51, CustomItemStack.create(XMaterial.TOTEM_OF_UNDYING.parseMaterial(), ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> { // Add something here return false; }); @@ -282,3 +283,4 @@ private static , V> V getOptionValue(@Nonnull P } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/package-info.java new file mode 100644 index 0000000000..4371090077 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/options/package-info.java @@ -0,0 +1,6 @@ +/** + * This package contains the Settings menu for the {@link io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide} as + * well as the interface {@link io.github.thebusybiscuit.slimefun5.core.guide.options.SlimefunGuideOption} for adding + * your own options + */ +package io.github.thebusybiscuit.slimefun5.core.guide.options; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/package-info.java similarity index 61% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/package-info.java index 0d47912f05..37c14ffb66 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/guide/package-info.java @@ -1,5 +1,5 @@ /** - * This package contains the core system for the {@link io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide}. + * This package contains the core system for the {@link io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide}. * Note that you can find the individual implementations of the guide, in the implementation package */ -package io.github.thebusybiscuit.slimefun4.core.guide; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.guide; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockBreakHandler.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockBreakHandler.java index 7bd704a509..6b8ce367c0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockBreakHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import java.util.List; @@ -10,10 +10,10 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; +import io.github.thebusybiscuit.slimefun5.api.events.AndroidMineEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.MinerAndroid; /** * The {@link BlockBreakHandler} is called when a {@link Block} is broken @@ -102,3 +102,4 @@ public final Class getIdentifier() { return BlockBreakHandler.class; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockDispenseHandler.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockDispenseHandler.java index 8f10c0fa97..cd9512179a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockDispenseHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import java.util.Optional; @@ -7,11 +7,11 @@ import org.bukkit.block.Dispenser; import org.bukkit.event.block.BlockDispenseEvent; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IncompatibleItemHandlerException; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.BlockPlacer; /** * This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to @@ -44,3 +44,4 @@ default Class getIdentifier() { return BlockDispenseHandler.class; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockPlaceHandler.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockPlaceHandler.java index e2cb771bfc..84300637a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockPlaceHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import javax.annotation.Nonnull; @@ -6,10 +6,10 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.BlockPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; +import io.github.thebusybiscuit.slimefun5.api.events.BlockPlacerPlaceEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.BlockPlacer; /** * This {@link ItemHandler} is called whenever a {@link Block} was placed. @@ -62,3 +62,4 @@ public final Class getIdentifier() { return BlockPlaceHandler.class; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockUseHandler.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockUseHandler.java index 0aeac6f4a9..1f12a19d27 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BlockUseHandler.java @@ -1,12 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import java.util.Optional; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IncompatibleItemHandlerException; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; @FunctionalInterface public interface BlockUseHandler extends ItemHandler { @@ -15,7 +16,7 @@ public interface BlockUseHandler extends ItemHandler { @Override default Optional validate(SlimefunItem item) { - if (item instanceof NotPlaceable || !item.getItem().getType().isBlock()) { + if (item instanceof NotPlaceable || !MaterialCompat.isPlaceableBlock(item.getItem().getType())) { return Optional.of(new IncompatibleItemHandlerException("Only blocks that are not marked as 'NotPlaceable' can have a BlockUseHandler.", item, this)); } @@ -28,3 +29,4 @@ default Class getIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BowShootHandler.java similarity index 77% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BowShootHandler.java index f2c5aa7df0..9d64cdf76f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/BowShootHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import java.util.Optional; @@ -6,10 +6,10 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SlimefunBow; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IncompatibleItemHandlerException; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.SlimefunBow; /** * This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to @@ -40,3 +40,4 @@ default Class getIdentifier() { return BowShootHandler.class; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/EntityInteractHandler.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/EntityInteractHandler.java index 1091d3a335..1b8e51aeba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/EntityInteractHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -7,10 +7,10 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.EntityInteractionListener; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.EntityInteractionListener; /** * This is triggered when a {@link Player} interacts with an {@link Entity}. @@ -42,4 +42,4 @@ public interface EntityInteractHandler extends ItemHandler { default Class getIdentifier() { return EntityInteractHandler.class; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/EntityKillHandler.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/EntityKillHandler.java index 21ec3c0179..9f39498ec0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/EntityKillHandler.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * If this {@link ItemHandler} is added to a {@link SlimefunItem} it will listen @@ -30,3 +30,4 @@ default Class getIdentifier() { return EntityKillHandler.class; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/GlobalItemHandler.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/GlobalItemHandler.java index df5f0a92e7..8a0451cfa0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/GlobalItemHandler.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import org.bukkit.event.Event; import org.bukkit.event.Listener; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * A {@link GlobalItemHandler} is a special type of {@link ItemHandler} @@ -19,3 +19,4 @@ public interface GlobalItemHandler extends ItemHandler { } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemConsumptionHandler.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemConsumptionHandler.java index 69a5d44089..51de762a26 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemConsumptionHandler.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.DietCookie; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.FortuneCookie; /** * This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to @@ -47,3 +47,4 @@ default Class getIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemDropHandler.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemDropHandler.java index a0e6efbb6a..464aa4600e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemDropHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerDropItemEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; /** * The {@link ItemDropHandler} is a {@link GlobalItemHandler} which listens to @@ -27,3 +27,4 @@ default Class getIdentifier() { return ItemDropHandler.class; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemUseHandler.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemUseHandler.java index e0ef00c672..99edbee5f6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ItemUseHandler.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to @@ -35,3 +35,4 @@ default Class getIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/MultiBlockInteractionHandler.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/MultiBlockInteractionHandler.java index 0ae90600bd..2d4e2c836a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/MultiBlockInteractionHandler.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import java.util.Optional; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IncompatibleItemHandlerException; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlock; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; /** * This {@link ItemHandler} is called whenever a {@link Player} interacts with @@ -43,3 +43,4 @@ default Class getIdentifier() { return MultiBlockInteractionHandler.class; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/RainbowTickHandler.java similarity index 55% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/RainbowTickHandler.java index 6fa656f6d0..c9a6855f5f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/RainbowTickHandler.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.Arrays; import java.util.List; @@ -8,16 +12,13 @@ import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.type.GlassPane; import io.github.bakedlibs.dough.collections.LoopIterator; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock; -import io.github.thebusybiscuit.slimefun4.utils.ColoredMaterial; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.RainbowBlock; +import io.github.thebusybiscuit.slimefun5.utils.ColoredMaterial; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -39,14 +40,25 @@ public class RainbowTickHandler extends BlockTicker { private Material material; public RainbowTickHandler(@Nonnull List materials) { - Validate.noNullElements(materials, "A RainbowTicker cannot have a Material that is null!"); + Validate.notNull(materials, "The materials List cannot be null!"); + + // Java-8 universal port: on legacy servers some coloured materials don't exist (XMaterial + // resolves them to null). Strip those out so the item still registers; if none remain, fall + // back to a single static material so the block simply doesn't cycle colours on that version. + List filtered = new java.util.ArrayList<>(); - if (materials.isEmpty()) { - throw new IllegalArgumentException("A RainbowTicker must have at least one Material associated with it!"); + for (Material mat : materials) { + if (mat != null) { + filtered.add(mat); + } } - glassPanes = containsGlassPanes(materials); - iterator = new LoopIterator<>(materials); + if (filtered.isEmpty()) { + filtered.add(Material.STONE); + } + + glassPanes = containsGlassPanes(filtered); + iterator = new LoopIterator<>(filtered); material = iterator.next(); } @@ -81,7 +93,7 @@ private boolean containsGlassPanes(@Nonnull List materials) { no impact on performance, in fact it should save performance as it preloads the data but also saves heavy calls for other Materials */ - if (type.createBlockData() instanceof GlassPane) { + if (BlockDataCompat.isInstance(BlockDataCompat.createBlockData(type), "org.bukkit.block.data.type.GlassPane")) { return true; } } @@ -91,7 +103,7 @@ private boolean containsGlassPanes(@Nonnull List materials) { @Override public void tick(Block b, SlimefunItem item, Config data) { - if (b.getType().isAir()) { + if (MaterialCompat.isAir(b.getType())) { /* The block was broken, setting the Material now would result in a duplication glitch @@ -100,20 +112,22 @@ public void tick(Block b, SlimefunItem item, Config data) { } if (glassPanes) { - BlockData blockData = b.getBlockData(); + Object previousData = BlockDataCompat.getBlockData(b); + + if (BlockDataCompat.isInstance(previousData, "org.bukkit.block.data.type.GlassPane")) { + Object block = BlockDataCompat.createBlockData(material, bd -> { + BlockDataCompat.set(bd, "setWaterlogged", BlockDataCompat.get(previousData, "isWaterlogged")); - if (blockData instanceof GlassPane previousData) { - BlockData block = material.createBlockData(bd -> { - if (bd instanceof GlassPane nextData) { - nextData.setWaterlogged(previousData.isWaterlogged()); + Object allowedFaces = BlockDataCompat.get(previousData, "getAllowedFaces"); - for (BlockFace face : previousData.getAllowedFaces()) { - nextData.setFace(face, previousData.hasFace(face)); + if (allowedFaces instanceof Iterable) { + for (Object face : (Iterable) allowedFaces) { + ReflectionCompat.invoke(bd, "setFace", face, ReflectionCompat.invoke(previousData, "hasFace", face)); } } }); - b.setBlockData(block, false); + BlockDataCompat.setBlockData(b, block, false); return; } } @@ -132,3 +146,4 @@ public boolean isSynchronized() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ToolUseHandler.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ToolUseHandler.java index 579b5f5749..59cad0bf48 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/ToolUseHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import java.util.List; @@ -7,8 +7,8 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This {@link ItemHandler} is called when a {@link Block} is broken with a {@link SlimefunItem} @@ -43,3 +43,4 @@ default Class getIdentifier() { return ToolUseHandler.class; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/WeaponUseHandler.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/WeaponUseHandler.java index 99fda746be..426c78eac4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/WeaponUseHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.handlers; +package io.github.thebusybiscuit.slimefun5.core.handlers; import javax.annotation.Nonnull; @@ -7,8 +7,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This is triggered when a {@link Player} attacks an {@link Entity}. @@ -37,3 +37,4 @@ default Class getIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/package-info.java similarity index 50% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/package-info.java index d3c439ec1e..a60e6043da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/handlers/package-info.java @@ -1,5 +1,5 @@ /** - * This package contains all variations of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemHandler} that - * can be assigned to a {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} + * This package contains all variations of {@link io.github.thebusybiscuit.slimefun5.api.items.ItemHandler} that + * can be assigned to a {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} */ -package io.github.thebusybiscuit.slimefun4.core.handlers; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.handlers; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/MachineOperation.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/MachineOperation.java index 3da6569b6c..0e9f08185d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/MachineOperation.java @@ -1,7 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.core.machines; +package io.github.thebusybiscuit.slimefun5.core.machines; import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder; +import io.github.thebusybiscuit.slimefun5.core.attributes.MachineProcessHolder; /** * This represents a {@link MachineOperation} which is handled @@ -65,3 +65,4 @@ default boolean isFinished() { default void onCancel(BlockPosition position) {} } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/MachineProcessor.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/MachineProcessor.java index 9ec92b578a..3d11393d81 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/MachineProcessor.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.machines; +package io.github.thebusybiscuit.slimefun5.core.machines; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -14,9 +14,9 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineOperationFinishEvent; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.events.AsyncMachineOperationFinishEvent; +import io.github.thebusybiscuit.slimefun5.core.attributes.MachineProcessHolder; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -259,3 +259,4 @@ public void updateProgressBar(@Nonnull BlockMenu inv, int slot, @Nonnull T opera } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/package-info.java new file mode 100644 index 0000000000..17cac4c7e2 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/machines/package-info.java @@ -0,0 +1,6 @@ +/** + * This package contains sources related to the + * {@link io.github.thebusybiscuit.slimefun5.core.machines.MachineProcessor} + * and any {@link io.github.thebusybiscuit.slimefun5.core.machines.MachineOperation}. + */ +package io.github.thebusybiscuit.slimefun5.core.machines; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/MultiBlock.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/MultiBlock.java index 4175b20527..e3e0767d01 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/MultiBlock.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.multiblocks; +package io.github.thebusybiscuit.slimefun5.core.multiblocks; import java.util.Arrays; import java.util.HashSet; @@ -10,13 +10,14 @@ import org.apache.commons.lang.Validate; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.World; import org.bukkit.block.BlockFace; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockInteractEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.MultiBlockInteractionHandler; /** * A {@link MultiBlock} represents a structure build in a {@link World}. @@ -126,10 +127,10 @@ private boolean compareBlocks(Material a, @Nullable Material b) { } // This ensures that the Industrial Miner is still recognized while operating - if (a == Material.PISTON) { - return b == Material.PISTON || b == Material.MOVING_PISTON; - } else if (b == Material.PISTON) { - return a == Material.MOVING_PISTON; + if (a == XMaterial.PISTON.parseMaterial()) { + return b == XMaterial.PISTON.parseMaterial() || b == XMaterial.MOVING_PISTON.parseMaterial(); + } else if (b == XMaterial.PISTON.parseMaterial()) { + return a == XMaterial.MOVING_PISTON.parseMaterial(); } if (b != a) { @@ -154,3 +155,4 @@ public String toString() { return "MultiBlock (" + item.getId() + ") {" + Arrays.toString(blocks) + "}"; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/MultiBlockMachine.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/MultiBlockMachine.java index d18f6ba2cd..8d5c95057d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/MultiBlockMachine.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.multiblocks; +package io.github.thebusybiscuit.slimefun5.core.multiblocks; import java.util.ArrayList; import java.util.Arrays; @@ -17,7 +17,6 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.Container; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -25,18 +24,18 @@ import io.github.bakedlibs.dough.inventory.InvUtils; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.MultiBlockInteractionHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.OutputChest; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * A {@link MultiBlockMachine} is a {@link SlimefunItem} that is built in the {@link World}. @@ -224,3 +223,4 @@ protected void handleCraftedItem(ItemStack outputItem, Block block, Inventory bl } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/package-info.java new file mode 100644 index 0000000000..569eb1026e --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds all core mechanics related to a + * {@link io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlock}, like that class itself. + */ +package io.github.thebusybiscuit.slimefun5.core.multiblocks; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/NetworkManager.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/NetworkManager.java index 14d88e121d..29cff5ab22 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/NetworkManager.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.networks; +package io.github.thebusybiscuit.slimefun5.core.networks; import java.util.ArrayList; import java.util.Collections; @@ -16,11 +16,11 @@ import io.github.bakedlibs.dough.blocks.BlockPosition; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.network.Network; +import io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.NetworkListener; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -215,3 +215,4 @@ public void updateAllNetworks(@Nonnull Location l) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/AbstractItemNetwork.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/AbstractItemNetwork.java index 2cce2bb796..24528bfdc1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/AbstractItemNetwork.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.networks.cargo; +package io.github.thebusybiscuit.slimefun5.core.networks.cargo; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -11,15 +12,14 @@ import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Directional; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.network.Network; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -52,14 +52,21 @@ protected Optional getAttachedBlock(@Nonnull Location l) { if (l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4)) { Block block = l.getBlock(); - if (block.getType() == Material.PLAYER_WALL_HEAD) { + if (block.getType() == XMaterial.PLAYER_WALL_HEAD.parseMaterial()) { BlockFace cached = connectorCache.get(l); if (cached != null) { return Optional.of(block.getRelative(cached)); } - BlockFace face = ((Directional) block.getBlockData()).getFacing().getOppositeFace(); + Object facingValue = BlockDataCompat.get(BlockDataCompat.getBlockData(block), "getFacing"); + + if (!(facingValue instanceof BlockFace)) { + // Legacy servers have no Directional block data; this connector can't be resolved. + return Optional.empty(); + } + + BlockFace face = ((BlockFace) facingValue).getOppositeFace(); connectorCache.put(l, face); return Optional.of(block.getRelative(face)); } @@ -133,3 +140,4 @@ private void filter(@Nullable ItemStack stack, List items, } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoNet.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoNet.java index 7ef1da5cdb..6fe54a89fa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoNet.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.networks.cargo; +package io.github.thebusybiscuit.slimefun5.core.networks.cargo; import java.util.HashMap; import java.util.HashSet; @@ -17,10 +17,10 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.network.Network; +import io.github.thebusybiscuit.slimefun5.api.network.NetworkComponent; +import io.github.thebusybiscuit.slimefun5.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -94,14 +94,18 @@ public NetworkComponent classifyLocation(@Nonnull Location l) { return null; } - return switch (id) { - case "CARGO_MANAGER" -> NetworkComponent.REGULATOR; - case "CARGO_NODE" -> NetworkComponent.CONNECTOR; - case "CARGO_NODE_INPUT", - "CARGO_NODE_OUTPUT", - "CARGO_NODE_OUTPUT_ADVANCED" -> NetworkComponent.TERMINUS; - default -> null; - }; + switch (id) { + case "CARGO_MANAGER": + return NetworkComponent.REGULATOR; + case "CARGO_NODE": + return NetworkComponent.CONNECTOR; + case "CARGO_NODE_INPUT": + case "CARGO_NODE_OUTPUT": + case "CARGO_NODE_OUTPUT_ADVANCED": + return NetworkComponent.TERMINUS; + default: + return null; + } } @Override @@ -116,10 +120,15 @@ public void onClassificationChange(Location l, NetworkComponent from, NetworkCom if (to == NetworkComponent.TERMINUS) { String id = BlockStorage.checkID(l); switch (id) { - case "CARGO_NODE_INPUT" -> inputNodes.add(l); - case "CARGO_NODE_OUTPUT", - "CARGO_NODE_OUTPUT_ADVANCED" -> outputNodes.add(l); - default -> {} + case "CARGO_NODE_INPUT": + inputNodes.add(l); + break; + case "CARGO_NODE_OUTPUT": + case "CARGO_NODE_OUTPUT_ADVANCED": + outputNodes.add(l); + break; + default: + break; } } } @@ -230,3 +239,4 @@ private static int getFrequency(@Nonnull Location node) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoNetworkTask.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoNetworkTask.java index 35b5fe225f..5ab3f0cc53 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoNetworkTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.networks.cargo; +package io.github.thebusybiscuit.slimefun5.core.networks.cargo; import java.util.ArrayDeque; import java.util.ArrayList; @@ -20,13 +20,13 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.networks.NetworkManager; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -212,3 +212,4 @@ private void roundRobinSort(int index, Deque outputNodes) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoUtils.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoUtils.java index ff8da96d0a..55c5dc0fa5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/CargoUtils.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.networks.cargo; +package io.github.thebusybiscuit.slimefun5.core.networks.cargo; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.Map; @@ -7,7 +9,8 @@ import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.inventory.BrewerInventory; @@ -17,12 +20,12 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.inventory.InvUtils; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.core.debug.Debug; +import io.github.thebusybiscuit.slimefun5.core.debug.TestCase; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -75,7 +78,7 @@ static boolean hasInventory(@Nullable Block block) { @Nonnull static int[] getInputSlotRange(@Nonnull Inventory inv, @Nullable ItemStack item) { if (inv instanceof FurnaceInventory) { - if (item != null && item.getType().isFuel()) { + if (item != null && MaterialCompat.isFuel(item.getType())) { if (isSmeltable(item, true)) { // Any non-smeltable items should not land in the upper slot return new int[] { 0, 2 }; @@ -130,8 +133,8 @@ static ItemStack withdraw(AbstractItemNetwork network, Map BlockState state = PaperLib.getBlockState(target, false).getState(); - if (state instanceof InventoryHolder inventoryHolder) { - inventory = inventoryHolder.getInventory(); + if (state instanceof InventoryHolder) { + InventoryHolder inventoryHolder = (InventoryHolder) state; inventory = inventoryHolder.getInventory(); inventories.put(target.getLocation(), inventory); return withdrawFromVanillaInventory(network, node, template, inventory); } @@ -173,7 +176,7 @@ static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block for (int slot = minSlot; slot < maxSlot; slot++) { // Changes to these ItemStacks are synchronized with the Item in the Inventory ItemStack itemInSlot = contents[slot]; - if (itemInSlot == null || itemInSlot.getType().isAir()) { + if (itemInSlot == null || MaterialCompat.isAir(itemInSlot.getType())) { continue; } @@ -215,8 +218,8 @@ static ItemStackAndInteger withdraw(AbstractItemNetwork network, Map in BlockState state = PaperLib.getBlockState(target, false).getState(); - if (state instanceof InventoryHolder inventoryHolder) { - inventory = inventoryHolder.getInventory(); + if (state instanceof InventoryHolder) { + InventoryHolder inventoryHolder = (InventoryHolder) state; inventory = inventoryHolder.getInventory(); inventories.put(target.getLocation(), inventory); return insertIntoVanillaInventory(stack, wrapper, smartFill, inventory); } @@ -405,7 +408,7 @@ private static boolean isSmeltable(@Nullable ItemStack stack, boolean lazy) { private static boolean isPotion(@Nullable ItemStack item) { if (item != null) { Material type = item.getType(); - return type == Material.POTION || type == Material.SPLASH_POTION || type == Material.LINGERING_POTION; + return type == Material.POTION || type == XMaterial.SPLASH_POTION.parseMaterial() || type == XMaterial.LINGERING_POTION.parseMaterial(); } else { return false; } @@ -422,3 +425,4 @@ public static int[] getFilteringSlots() { return FILTER_SLOTS; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/ItemFilter.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/ItemFilter.java index 1de4b4a4a4..8fe3f9a076 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/ItemFilter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.networks.cargo; +package io.github.thebusybiscuit.slimefun5.core.networks.cargo; import java.util.ArrayList; import java.util.List; @@ -11,12 +11,12 @@ import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoNode; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.debug.Debug; +import io.github.thebusybiscuit.slimefun5.core.debug.TestCase; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.CargoNode; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -216,3 +216,4 @@ public boolean test(@Nonnull ItemStack item) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/ItemStackAndInteger.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/ItemStackAndInteger.java index d149efdc79..21884d6981 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/ItemStackAndInteger.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.core.networks.cargo; +package io.github.thebusybiscuit.slimefun5.core.networks.cargo; import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; class ItemStackAndInteger { @@ -51,3 +51,4 @@ private void initializeItem() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/package-info.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/package-info.java index 96c7abbb70..271b90b7f4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/cargo/package-info.java @@ -1,5 +1,5 @@ /** - * This package holds an implementation of {@link io.github.thebusybiscuit.slimefun4.api.network.Network} + * This package holds an implementation of {@link io.github.thebusybiscuit.slimefun5.api.network.Network} * that is responsible for item transportation. */ -package io.github.thebusybiscuit.slimefun4.core.networks.cargo; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.networks.cargo; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/EnergyNet.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/EnergyNet.java index cb7c2c910c..74e98b8b39 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/EnergyNet.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.networks.energy; +package io.github.thebusybiscuit.slimefun5.core.networks.energy; import java.util.Collections; import java.util.HashMap; @@ -16,16 +16,16 @@ import org.bukkit.Material; import org.bukkit.block.Block; -import io.github.thebusybiscuit.slimefun4.api.ErrorReport; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.ErrorReport; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.network.Network; +import io.github.thebusybiscuit.slimefun5.api.network.NetworkComponent; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetProvider; +import io.github.thebusybiscuit.slimefun5.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -103,13 +103,16 @@ public NetworkComponent classifyLocation(@Nonnull Location l) { if (component == null) { return null; } else { - return switch (component.getEnergyComponentType()) { - case CONNECTOR, - CAPACITOR -> NetworkComponent.CONNECTOR; - case CONSUMER, - GENERATOR -> NetworkComponent.TERMINUS; - default -> null; - }; + switch (component.getEnergyComponentType()) { + case CONNECTOR: + case CAPACITOR: + return NetworkComponent.CONNECTOR; + case CONSUMER: + case GENERATOR: + return NetworkComponent.TERMINUS; + default: + return null; + } } } @@ -131,10 +134,10 @@ public void onClassificationChange(Location l, NetworkComponent from, NetworkCom consumers.put(l, component); break; case GENERATOR: - if (component instanceof EnergyNetProvider provider) { - generators.put(l, provider); - } else if (component instanceof SlimefunItem item) { - item.warn("This Item is marked as a GENERATOR but does not implement the interface EnergyNetProvider!"); + if (component instanceof EnergyNetProvider) { + EnergyNetProvider provider = (EnergyNetProvider) component; generators.put(l, provider); + } else if (component instanceof SlimefunItem) { + SlimefunItem item = (SlimefunItem) component; item.warn("This Item is marked as a GENERATOR but does not implement the interface EnergyNetProvider!"); } break; default: @@ -302,8 +305,8 @@ private void updateHologram(@Nonnull Block b, double supply, double demand) { private static EnergyNetComponent getComponent(@Nonnull Location l) { SlimefunItem item = BlockStorage.check(l); - if (item instanceof EnergyNetComponent component) { - return component; + if (item instanceof EnergyNetComponent) { + EnergyNetComponent component = (EnergyNetComponent) item; return component; } return null; @@ -345,3 +348,4 @@ public static EnergyNet getNetworkFromLocationOrCreate(@Nonnull Location l) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/EnergyNetComponentType.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/EnergyNetComponentType.java index 8340260dcb..b259585096 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/EnergyNetComponentType.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.core.networks.energy; +package io.github.thebusybiscuit.slimefun5.core.networks.energy; import org.bukkit.block.Block; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.Capacitor; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.EnergyConnector; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.Reactor; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -53,4 +53,4 @@ public enum EnergyNetComponentType { */ NONE; -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/package-info.java similarity index 52% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/package-info.java index d5061d1036..0b47fe310e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/energy/package-info.java @@ -1,5 +1,5 @@ /** - * This package holds an implementation of {@link io.github.thebusybiscuit.slimefun4.api.network.Network} + * This package holds an implementation of {@link io.github.thebusybiscuit.slimefun5.api.network.Network} * that is responsible for transmitting energy. */ -package io.github.thebusybiscuit.slimefun4.core.networks.energy; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.networks.energy; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/package-info.java new file mode 100644 index 0000000000..6ba1db6ba6 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/networks/package-info.java @@ -0,0 +1,6 @@ +/** + * This package provides the core functionality for the {@link io.github.thebusybiscuit.slimefun5.api.network.Network} + * class, such as the {@link io.github.thebusybiscuit.slimefun5.core.networks.NetworkManager} and also the subpackages + * for actual implementations of the {@link io.github.thebusybiscuit.slimefun5.api.network.Network} class. + */ +package io.github.thebusybiscuit.slimefun5.core.networks; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/package-info.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/package-info.java index 4a303ab0e0..4a588050a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/package-info.java @@ -2,4 +2,4 @@ * This package holds the core systems of Slimefun, these are not necessarily used as an API * but rather provide the core functionality of this {@link org.bukkit.plugin.Plugin}. */ -package io.github.thebusybiscuit.slimefun4.core; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AnalyticsService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/AnalyticsService.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AnalyticsService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/AnalyticsService.java index b0afd40657..fc57242b75 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AnalyticsService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/AnalyticsService.java @@ -1,9 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; +import java.io.IOException; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; @@ -14,10 +15,11 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.debug.Debug; +import io.github.thebusybiscuit.slimefun5.core.debug.TestCase; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This class represents an analytics service that sends data. @@ -33,7 +35,6 @@ public class AnalyticsService { private static final String API_URL = "https://analytics.slimefun.dev/ingest"; private final JavaPlugin plugin; - private final HttpClient client = HttpClient.newHttpClient(); private boolean enabled; @@ -114,25 +115,25 @@ private void send(String id, double[] doubles, String[] blobs) { JsonObject object = new JsonObject(); // Up to 1 index JsonArray indexes = new JsonArray(); - indexes.add(id); + indexes.add(new JsonPrimitive(id)); object.add("indexes", indexes); // Up to 20 doubles (including the version) JsonArray doublesArray = new JsonArray(); - doublesArray.add(VERSION); + doublesArray.add(new JsonPrimitive(VERSION)); if (doubles != null) { for (double d : doubles) { - doublesArray.add(d); + doublesArray.add(new JsonPrimitive(d)); } } object.add("doubles", doublesArray); // Up to 20 blobs (including the version) JsonArray blobsArray = new JsonArray(); - blobsArray.add(Slimefun.getVersion()); + blobsArray.add(new JsonPrimitive(Slimefun.getVersion())); if (blobs != null) { for (String s : blobs) { - blobsArray.add(s); + blobsArray.add(new JsonPrimitive(s)); } } object.add("blobs", blobsArray); @@ -140,19 +141,44 @@ private void send(String id, double[] doubles, String[] blobs) { Debug.log(TestCase.ANALYTICS, "Sending analytics data for " + id); Debug.log(TestCase.ANALYTICS, object.toString()); - // Send async, we do not care about the result. If it fails, that's fine. - client.sendAsync(HttpRequest.newBuilder() - .uri(URI.create(API_URL)) - .header("User-Agent", "Mozilla/5.0 Slimefun4 AnalyticsService") - .POST(HttpRequest.BodyPublishers.ofString(object.toString())) - .build(), - HttpResponse.BodyHandlers.discarding() - ).thenAcceptAsync((res) -> { - if (res.statusCode() == 200) { + // Java 8: dispatch the POST on an async task so we don't block the calling thread. + // We do not care about the result. If it fails, that's fine. + String payload = object.toString(); + plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> postAnalytics(id, payload)); + } + + // Performs the actual HTTP POST using Java 8's HttpURLConnection (the universal jar targets + // Java 8, so the Java 11 HttpClient is unavailable). Must be called off the main thread. + private void postAnalytics(@Nonnull String id, @Nonnull String payload) { + HttpURLConnection connection = null; + + try { + connection = (HttpURLConnection) new URL(API_URL).openConnection(); + connection.setRequestMethod("POST"); + connection.setConnectTimeout(10_000); + connection.setReadTimeout(10_000); + connection.setDoOutput(true); + connection.setRequestProperty("User-Agent", "Mozilla/5.0 Slimefun5 AnalyticsService"); + connection.setRequestProperty("Content-Type", "application/json"); + + try (OutputStream output = connection.getOutputStream()) { + output.write(payload.getBytes(StandardCharsets.UTF_8)); + } + + int statusCode = connection.getResponseCode(); + + if (statusCode == 200) { Debug.log(TestCase.ANALYTICS, "Analytics data for " + id + " sent successfully"); } else { - Debug.log(TestCase.ANALYTICS, "Analytics data for " + id + " failed to send - " + res.statusCode()); + Debug.log(TestCase.ANALYTICS, "Analytics data for " + id + " failed to send - " + statusCode); + } + } catch (IOException e) { + Debug.log(TestCase.ANALYTICS, "Analytics data for " + id + " failed to send - " + e.getMessage()); + } finally { + if (connection != null) { + connection.disconnect(); } - }); + } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/AutoSavingService.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/AutoSavingService.java index 060ce0d772..65b0733179 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/AutoSavingService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.util.HashSet; import java.util.Iterator; @@ -12,10 +12,10 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.debug.Debug; +import io.github.thebusybiscuit.slimefun5.core.debug.TestCase; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -115,3 +115,4 @@ private void saveAllBlocks() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/BackupService.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/BackupService.java index 80ce5b999b..e29637da9f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/BackupService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.io.File; import java.io.FileInputStream; @@ -19,7 +19,7 @@ import org.apache.commons.lang.Validate; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This Service creates a Backup of your Slimefun world data on every server shutdown. @@ -149,3 +149,4 @@ private void purgeBackups(@Nonnull List backups) throws IOException { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/BlockDataService.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/BlockDataService.java index 69c9579286..a2cb9597f0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/BlockDataService.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.Optional; import java.util.logging.Level; @@ -6,21 +10,17 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; -import org.bukkit.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.block.BlockState; -import org.bukkit.block.TileState; -import org.bukkit.persistence.PersistentDataContainer; -import org.bukkit.persistence.PersistentDataHolder; -import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import io.papermc.lib.PaperLib; /** @@ -34,8 +34,20 @@ */ public class BlockDataService implements Keyed { + // org.bukkit.block.TileState is 1.14+; resolve it reflectively so this class still loads on older + // servers, where block identity is handled entirely by the file-based BlockStorage instead. + private static final Class TILE_STATE = resolveTileState(); + private final NamespacedKey namespacedKey; + private static Class resolveTileState() { + try { + return Class.forName("org.bukkit.block.TileState"); + } catch (Throwable ignored) { + return null; + } + } + /** * This creates a new {@link BlockDataService} for the given {@link Plugin}. * The {@link Plugin} and key will together form a {@link NamespacedKey} used to store @@ -73,10 +85,9 @@ public void setBlockData(@Nonnull Block b, @Nonnull String value) { */ BlockState state = b.getState(); - if (state instanceof TileState tileState) { + if (TILE_STATE != null && TILE_STATE.isInstance(state)) { try { - PersistentDataContainer container = tileState.getPersistentDataContainer(); - container.set(namespacedKey, PersistentDataType.STRING, value); + PdcCompat.set(state, namespacedKey, "STRING", value); state.update(); } catch (Exception x) { Slimefun.logger().log(Level.SEVERE, "Please check if your Server Software is up to date!"); @@ -101,24 +112,14 @@ public Optional getBlockData(@Nonnull Block b) { Validate.notNull(b, "The block cannot be null!"); BlockState state = PaperLib.getBlockState(b, false).getState(); - PersistentDataContainer container = getPersistentDataContainer(state); - if (container != null) { - return Optional.ofNullable(container.get(namespacedKey, PersistentDataType.STRING)); + if (TILE_STATE != null && TILE_STATE.isInstance(state)) { + return Optional.ofNullable((String) PdcCompat.get(state, namespacedKey, "STRING")); } else { return Optional.empty(); } } - @Nullable - private PersistentDataContainer getPersistentDataContainer(@Nonnull BlockState state) { - if (state instanceof TileState tileState) { - return tileState.getPersistentDataContainer(); - } else { - return null; - } - } - /** * This method checks whether the given {@link Material} is a Tile Entity. * This is used to determine whether the {@link Block} produced by this {@link Material} @@ -133,7 +134,7 @@ private PersistentDataContainer getPersistentDataContainer(@Nonnull BlockState s * @return Whether the given {@link Material} is considered a Tile Entity */ public boolean isTileEntity(@Nullable Material type) { - if (type == null || type.isAir()) { + if (type == null || MaterialCompat.isAir(type)) { // Cannot store data on air return false; } @@ -141,4 +142,4 @@ public boolean isTileEntity(@Nullable Material type) { return SlimefunTag.TILE_ENTITIES.isTagged(type); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/CustomItemDataService.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/CustomItemDataService.java index e9617b7eec..70eefb518f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/CustomItemDataService.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.NbtItemCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.util.Optional; @@ -6,17 +9,15 @@ import javax.annotation.Nullable; import org.apache.commons.lang.Validate; -import org.bukkit.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.persistence.PersistentDataContainer; -import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; /** * This Service is responsible for applying NBT data to a {@link SlimefunItemStack}. @@ -85,8 +86,12 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) { Validate.notNull(meta, "The ItemMeta cannot be null!"); Validate.notNull(id, "Cannot store null on an ItemMeta!"); - PersistentDataContainer container = meta.getPersistentDataContainer(); - container.set(namespacedKey, PersistentDataType.STRING, id); + if (PdcCompat.isSupported()) { + PdcCompat.set(meta, namespacedKey, "STRING", id); + } else { + // Pre-1.14 has no PDC; fall back to storing the id in real item NBT. + NbtItemCompat.setString(meta, namespacedKey.toString(), id); + } } /** @@ -119,8 +124,11 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) { public @Nonnull Optional getItemData(@Nonnull ItemMeta meta) { Validate.notNull(meta, "Cannot read data from null!"); - PersistentDataContainer container = meta.getPersistentDataContainer(); - return Optional.ofNullable(container.get(namespacedKey, PersistentDataType.STRING)); + String value = PdcCompat.isSupported() + ? (String) PdcCompat.get(meta, namespacedKey, "STRING") + : NbtItemCompat.getString(meta, namespacedKey.toString()); + + return Optional.ofNullable(value); } /** @@ -159,3 +167,4 @@ public boolean hasEqualItemData(@Nonnull ItemMeta meta1, @Nonnull ItemMeta meta2 } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/CustomTextureService.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/CustomTextureService.java index 7c84a1de2a..a5b13046fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/CustomTextureService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.io.BufferedReader; import java.io.InputStream; @@ -17,9 +17,10 @@ import org.bukkit.inventory.meta.ItemMeta; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ItemMetaCompat; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This Service is responsible for applying custom model data to any {@link SlimefunItemStack} @@ -167,7 +168,8 @@ public void setTexture(@Nonnull ItemMeta im, @Nonnull String id) { Validate.notNull(id, "Cannot store null on an ItemMeta!"); int data = getModelData(id); - im.setCustomModelData(data == 0 ? null : data); + ItemMetaCompat.setCustomModelData(im, data == 0 ? null : data); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/LocalizationService.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/LocalizationService.java index 39b533335a..1eb7033c83 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/LocalizationService.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.io.BufferedReader; import java.io.IOException; @@ -17,7 +19,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.Server; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; @@ -26,12 +28,12 @@ import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.core.services.localization.LanguageFile; -import io.github.thebusybiscuit.slimefun4.core.services.localization.SlimefunLocalization; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; +import io.github.thebusybiscuit.slimefun5.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun5.core.services.localization.LanguageFile; +import io.github.thebusybiscuit.slimefun5.core.services.localization.SlimefunLocalization; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.utils.PatternUtils; /** * As the name suggests, this Service is responsible for Localization. @@ -154,8 +156,7 @@ public Language getDefaultLanguage() { public Language getLanguage(@Nonnull Player p) { Validate.notNull(p, "Player cannot be null!"); - PersistentDataContainer container = p.getPersistentDataContainer(); - String language = container.get(languageKey, PersistentDataType.STRING); + String language = (String) PdcCompat.get(p, languageKey, "STRING"); if (language != null) { Language lang = languages.get(language); @@ -282,3 +283,4 @@ public double calculateProgress(@Nonnull Language lang) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/MetricsService.java similarity index 52% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/MetricsService.java index 1c6d456692..8f28c00481 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/MetricsService.java @@ -1,26 +1,26 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.net.URI; +import java.net.HttpURLConnection; import java.net.URL; import java.net.URLClassLoader; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; -import java.net.http.HttpResponse.BodyHandler; -import java.net.http.HttpResponse.BodySubscriber; -import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.StandardCopyOption; -import java.time.Duration; -import java.util.List; -import java.util.concurrent.CompletionStage; -import java.util.concurrent.Flow.Subscription; import java.util.logging.Level; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -31,8 +31,8 @@ import com.google.gson.JsonParseException; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.JsonUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.JsonUtils; /** * This Class represents a Metrics Service that sends data to https://bstats.org/ @@ -53,29 +53,33 @@ public class MetricsService { /** * The Name of our repository - Version 2 of this repo (due to big breaking changes) */ - private static final String REPO_NAME = "MetricsModule2"; + private static final String REPO_NAME = "SlimefunMetrics"; /** * The name of the metrics jar file. */ - private static final String JAR_NAME = "MetricsModule"; + private static final String JAR_NAME = "SlimefunMetrics"; /** * The URL pointing towards the /releases/ endpoint of our * Metrics repository */ - private static final String RELEASES_URL = API_URL + "repos/Slimefun/" + REPO_NAME + "/releases/latest"; + private static final String RELEASES_URL = API_URL + "repos/Slimefun5/" + REPO_NAME + "/releases/latest"; /** * The URL pointing towards the download location for a * GitHub release of our Metrics repository */ - private static final String DOWNLOAD_URL = "https://github.com/Slimefun/" + REPO_NAME + "/releases/download"; + private static final String DOWNLOAD_URL = "https://github.com/Slimefun5/" + REPO_NAME + "/releases/download"; + + /** + * The connect/read timeout (in milliseconds) for our GitHub requests. + */ + private static final int TIMEOUT = 5_000; private final Slimefun plugin; private final File parentFolder; private final File metricsModuleFile; - private final HttpClient client = HttpClient.newHttpClient(); private URLClassLoader moduleClassLoader; private String metricVersion = null; @@ -83,7 +87,7 @@ public class MetricsService { /** * This constructs a new instance of our {@link MetricsService}. - * + * * @param plugin * Our {@link Slimefun} instance */ @@ -105,7 +109,8 @@ public void start() { if (!metricsModuleFile.exists()) { plugin.getLogger().info(JAR_NAME + " does not exist, downloading..."); - if (!download(getLatestVersion())) { + // Fall back to the bundled copy when GitHub has no release to download (avoids a 404). + if (!download(getLatestVersion()) && !extractBundledModule()) { plugin.getLogger().warning("Failed to start metrics as the file could not be downloaded."); return; } @@ -116,6 +121,8 @@ public void start() { * Load the jar file into a child class loader using the Slimefun * PluginClassLoader as a parent. */ + // The module is built against the upstream slimefun4 package; rewrite it to our slimefun5 one. + relocateToSlimefun5(metricsModuleFile); moduleClassLoader = URLClassLoader.newInstance(new URL[] { metricsModuleFile.toURI().toURL() }, plugin.getClass().getClassLoader()); Class metricsClass = moduleClassLoader.loadClass("dev.walshy.sfmetrics.MetricsModule"); @@ -151,6 +158,82 @@ public void start() { } } + // Rewrites slimefun4 -> slimefun5 in each .class entry (equal length, so a direct byte swap). Idempotent. + private void relocateToSlimefun5(@Nonnull File jar) throws IOException { + byte[] from = "slimefun4".getBytes(StandardCharsets.UTF_8); + byte[] to = "slimefun5".getBytes(StandardCharsets.UTF_8); + File temp = new File(jar.getParentFile(), jar.getName() + ".tmp"); + boolean changed = false; + + try (ZipInputStream in = new ZipInputStream(new FileInputStream(jar)); + ZipOutputStream out = new ZipOutputStream(new FileOutputStream(temp))) { + ZipEntry entry; + while ((entry = in.getNextEntry()) != null) { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + byte[] chunk = new byte[8192]; + int read; + while ((read = in.read(chunk)) != -1) { + buffer.write(chunk, 0, read); + } + byte[] data = buffer.toByteArray(); + if (entry.getName().endsWith(".class") && replaceBytes(data, from, to)) { + changed = true; + } + out.putNextEntry(new ZipEntry(entry.getName())); + out.write(data); + out.closeEntry(); + } + } + + if (changed) { + Files.move(temp.toPath(), jar.toPath(), StandardCopyOption.REPLACE_EXISTING); + } else { + temp.delete(); + } + } + + private boolean replaceBytes(@Nonnull byte[] data, @Nonnull byte[] from, @Nonnull byte[] to) { + boolean replaced = false; + for (int i = 0; i <= data.length - from.length; i++) { + boolean match = true; + for (int j = 0; j < from.length; j++) { + if (data[i + j] != from[j]) { + match = false; + break; + } + } + if (match) { + System.arraycopy(to, 0, data, i, to.length); + replaced = true; + } + } + return replaced; + } + + /** + * Extracts the metrics module that is bundled inside the Slimefun jar to the cache folder. + *

+ * This is the offline fallback used when the module could not be downloaded from GitHub (for + * example when no release is published on the Metrics repository), so that bStats metrics still + * work without any manual setup. + * + * @return Whether the bundled module was successfully extracted. + */ + private boolean extractBundledModule() { + try (InputStream input = Slimefun.class.getClassLoader().getResourceAsStream(JAR_NAME + ".jar")) { + if (input == null) { + return false; + } + + Files.copy(input, metricsModuleFile.toPath(), StandardCopyOption.REPLACE_EXISTING); + plugin.getLogger().info("Using bundled " + JAR_NAME + " module (offline fallback)."); + return true; + } catch (IOException e) { + plugin.getLogger().log(Level.WARNING, "Failed to extract the bundled metrics module: {0}", e.getMessage()); + return false; + } + } + /** * This will close the child {@link ClassLoader} and mark all the resources held under this no longer * in use, they will be cleaned up the next GC run. @@ -171,7 +254,7 @@ public void cleanUp() { * * @param currentVersion * The current version which is being used. - * + * * @return if there is an update available. */ public boolean checkForUpdate(@Nullable String currentVersion) { @@ -197,19 +280,26 @@ public boolean checkForUpdate(@Nullable String currentVersion) { * @return The latest version as an integer or -1 if it failed to fetch. */ private int getLatestVersion() { + HttpURLConnection connection = null; + try { - HttpResponse response = client.send(buildBaseRequest(URI.create(RELEASES_URL)), HttpResponse.BodyHandlers.ofString()); + connection = openConnection(RELEASES_URL); + int statusCode = connection.getResponseCode(); - if (response.statusCode() < 200 || response.statusCode() >= 300) { + if (statusCode < 200 || statusCode >= 300) { return -1; } - JsonElement element = JsonUtils.parseString(response.body()); + JsonElement element = JsonUtils.parseString(readBody(connection)); return element.getAsJsonObject().get("tag_name").getAsInt(); - } catch (IOException | InterruptedException | JsonParseException e) { + } catch (IOException | JsonParseException e) { plugin.getLogger().log(Level.WARNING, "Failed to fetch latest builds for Metrics: {0}", e.getMessage()); return -1; + } finally { + if (connection != null) { + connection.disconnect(); + } } } @@ -221,6 +311,7 @@ private int getLatestVersion() { */ private boolean download(int version) { File file = new File(parentFolder, "Metrics-" + version + ".jar"); + HttpURLConnection connection = null; try { plugin.getLogger().log(Level.INFO, "# Starting download of MetricsModule build: #{0}", version); @@ -230,12 +321,12 @@ private boolean download(int version) { Files.delete(file.toPath()); } - HttpResponse response = client.send( - buildBaseRequest(URI.create(DOWNLOAD_URL + "/" + version + "/" + JAR_NAME + ".jar")), - downloadMonitor(HttpResponse.BodyHandlers.ofFile(file.toPath())) - ); + connection = openConnection(DOWNLOAD_URL + "/" + version + "/" + JAR_NAME + ".jar"); + int statusCode = connection.getResponseCode(); + + if (statusCode >= 200 && statusCode < 300) { + downloadToFile(connection, file); - if (response.statusCode() >= 200 && response.statusCode() < 300) { plugin.getLogger().log(Level.INFO, "Successfully downloaded {0} build: #{1}", new Object[] { JAR_NAME, version }); // Replace the metric file with the new one @@ -246,12 +337,16 @@ private boolean download(int version) { hasDownloadedUpdate = true; return true; } else { - plugin.getLogger().log(Level.WARNING, "Failed to download the latest jar file from GitHub. Response code: {0}", response.statusCode()); + plugin.getLogger().log(Level.WARNING, "Failed to download the latest jar file from GitHub. Response code: {0}", statusCode); } - } catch (InterruptedException | JsonParseException e) { + } catch (JsonParseException e) { plugin.getLogger().log(Level.WARNING, "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down? Response: {0}", e.getMessage()); } catch (IOException e) { plugin.getLogger().log(Level.WARNING, "Failed to replace the old metric file with the new one. Please do this manually! Error: {0}", e.getMessage()); + } finally { + if (connection != null) { + connection.disconnect(); + } } return false; @@ -278,57 +373,65 @@ public boolean hasAutoUpdates() { return Slimefun.instance().getConfig().getBoolean("metrics.auto-update"); } - private HttpRequest buildBaseRequest(@Nonnull URI uri) { - return HttpRequest.newBuilder() - .uri(uri) - .timeout(Duration.ofSeconds(5)) - .header("User-Agent", "MetricsModule Auto-Updater") - .header("Accept", "application/vnd.github.v3+json") - .build(); + /** + * Opens a configured {@link HttpURLConnection} to the given URL. + *

+ * Java 8: we use {@link HttpURLConnection} instead of the Java 11 {@link java.net.http.HttpClient} + * so the universal jar runs on legacy (1.8+) servers running Java 8. + */ + @Nonnull + private HttpURLConnection openConnection(@Nonnull String url) throws IOException { + HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); + connection.setConnectTimeout(TIMEOUT); + connection.setReadTimeout(TIMEOUT); + connection.setRequestProperty("User-Agent", "MetricsModule Auto-Updater"); + connection.setRequestProperty("Accept", "application/vnd.github.v3+json"); + return connection; } - private BodyHandler downloadMonitor(BodyHandler h) { - return info -> new BodySubscriber() { - - private BodySubscriber delegateSubscriber = h.apply(info); - private int lastPercentPosted = 0; - private long bytesWritten = 0; - - @Override - public void onSubscribe(Subscription subscription) { - delegateSubscriber.onSubscribe(subscription); + /** + * Reads the full response body from the given connection as a UTF-8 String. + */ + @Nonnull + private static String readBody(@Nonnull HttpURLConnection connection) throws IOException { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { + StringBuilder builder = new StringBuilder(); + String line; + + while ((line = reader.readLine()) != null) { + builder.append(line); } - @Override - public void onNext(List item) { - bytesWritten += item.stream().mapToLong(ByteBuffer::capacity).sum(); - long totalBytes = info.headers().firstValue("Content-Length").map(Long::parseLong).orElse(-1L); - - int percent = (int) (20 * (Math.round((((double) bytesWritten / totalBytes) * 100) / 20))); + return builder.toString(); + } + } - if (percent != 0 && percent != lastPercentPosted) { - plugin.getLogger().info("# Downloading... " + percent + "% " + "(" + bytesWritten + "/" + totalBytes + " bytes)"); - lastPercentPosted = percent; + /** + * Streams the response body of the given connection to the target file, logging download + * progress in ~20% increments (mirrors the previous {@code BodySubscriber}-based progress monitor). + */ + private void downloadToFile(@Nonnull HttpURLConnection connection, @Nonnull File file) throws IOException { + long totalBytes = connection.getContentLengthLong(); + long bytesWritten = 0; + int lastPercentPosted = 0; + + try (InputStream input = connection.getInputStream(); OutputStream output = new FileOutputStream(file)) { + byte[] buffer = new byte[8192]; + int read; + + while ((read = input.read(buffer)) != -1) { + output.write(buffer, 0, read); + bytesWritten += read; + + if (totalBytes > 0) { + int percent = (int) (20 * Math.round((((double) bytesWritten / totalBytes) * 100) / 20)); + + if (percent != 0 && percent != lastPercentPosted) { + plugin.getLogger().info("# Downloading... " + percent + "% (" + bytesWritten + "/" + totalBytes + " bytes)"); + lastPercentPosted = percent; + } } - - delegateSubscriber.onNext(item); } - - @Override - public void onError(Throwable throwable) { - delegateSubscriber.onError(throwable); - - } - - @Override - public void onComplete() { - delegateSubscriber.onComplete(); - } - - @Override - public CompletionStage getBody() { - return delegateSubscriber.getBody(); - } - }; + } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/MinecraftRecipeService.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/MinecraftRecipeService.java index c9137ed242..9678f2d326 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/MinecraftRecipeService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.util.Collection; import java.util.HashMap; @@ -10,10 +10,13 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.RecipeCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; + import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; -import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.Server; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; @@ -24,7 +27,7 @@ import io.github.bakedlibs.dough.recipes.MinecraftRecipe; import io.github.bakedlibs.dough.recipes.RecipeSnapshot; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.guide.SurvivalSlimefunGuide; /** * This Service is responsible for accessing a {@link RecipeSnapshot}. @@ -70,6 +73,12 @@ public MinecraftRecipeService(@Nonnull Plugin plugin) { * This method refreshes the {@link RecipeSnapshot} that is used by the {@link MinecraftRecipeService}. */ public void refresh() { + // RecipeSnapshot relies on org.bukkit.Keyed (1.12+); on older servers it cannot be built, so the + // recipe service is left empty - every getter already tolerates a null snapshot. + if (!classExists("org.bukkit.Keyed")) { + return; + } + snapshot = new RecipeSnapshot(plugin); for (Consumer subscriber : subscriptions) { @@ -77,6 +86,15 @@ public void refresh() { } } + private static boolean classExists(@Nonnull String name) { + try { + Class.forName(name); + return true; + } catch (Throwable ignored) { + return false; + } + } + /** * This method subscribes to the underlying {@link RecipeSnapshot}. * When the {@link Server} has finished loading and a {@link Collection} of all @@ -134,14 +152,14 @@ public boolean isSmeltable(@Nullable ItemStack input) { public @Nonnull RecipeChoice[] getRecipeShape(@Nonnull Recipe recipe) { Validate.notNull(recipe, "Recipe must not be null!"); - if (recipe instanceof ShapedRecipe shapedRecipe) { - List choices = new LinkedList<>(); + if (recipe instanceof ShapedRecipe) { + ShapedRecipe shapedRecipe = (ShapedRecipe) recipe; List choices = new LinkedList<>(); for (String row : shapedRecipe.getShape()) { int columns = row.toCharArray().length; for (char key : row.toCharArray()) { - choices.add(shapedRecipe.getChoiceMap().get(key)); + choices.add(RecipeCompat.getChoiceMap(shapedRecipe).get(key)); } while (columns < 3) { @@ -187,12 +205,17 @@ public boolean isSmeltable(@Nullable ItemStack input) { public @Nullable Recipe getRecipe(@Nonnull NamespacedKey key) { Validate.notNull(key, "The NamespacedKey should not be null"); + // Recipe keys are a 1.12+ concept; convert our own key to the real org.bukkit.NamespacedKey + // at this boundary (null on legacy, where this lookup is not meaningfully used). + Object bukkitKey = io.github.thebusybiscuit.slimefun5.utils.compatibility.BukkitKeys.toBukkit(key); + if (snapshot != null) { // We operate on a cached HashMap which is much faster than Bukkit's method. - return snapshot.getRecipe(key); + return snapshot.getRecipe((org.bukkit.NamespacedKey) bukkitKey); } else { - return Bukkit.getRecipe(key); + return (Recipe) ReflectionCompat.invokeStatic(Bukkit.class, "getRecipe", bukkitKey); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/PerWorldSettingsService.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/PerWorldSettingsService.java index a0dc615d30..90022cb034 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/PerWorldSettingsService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.io.File; import java.util.Collections; @@ -19,10 +19,10 @@ import io.github.bakedlibs.dough.collections.OptionalMap; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This Service is responsible for disabling a {@link SlimefunItem} in a certain {@link World}. @@ -254,3 +254,4 @@ private Config getConfig(@Nonnull World world) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/PermissionsService.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/PermissionsService.java index de92df6d87..0d486a49c9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/PermissionsService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.io.File; import java.util.Collections; @@ -16,8 +16,8 @@ import org.bukkit.permissions.Permission; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This Service is responsible for handling the {@link Permission} of a @@ -154,4 +154,4 @@ public void save() { return config.getStringList(item.getId() + ".lore"); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/ThreadService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/ThreadService.java similarity index 98% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/ThreadService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/ThreadService.java index a5aa0c58e0..3bb4cabe8d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/ThreadService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/ThreadService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -97,3 +97,4 @@ public static String getCaller() { return element.getClassName() + "." + element.getMethodName() + ":" + element.getLineNumber(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/UpdaterService.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/UpdaterService.java index ac21007fce..f942dfc120 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/UpdaterService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.io.File; import java.util.concurrent.ExecutionException; @@ -12,8 +12,8 @@ import io.github.bakedlibs.dough.config.Config; import io.github.bakedlibs.dough.updater.PluginUpdater; import io.github.bakedlibs.dough.versions.PrefixedVersion; -import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.SlimefunBranch; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This Class represents our {@link PluginUpdater} Service. @@ -62,7 +62,7 @@ public UpdaterService(@Nonnull Slimefun plugin, @Nonnull String version, @Nonnul } else if (version.startsWith("Dev - ")) { // If we are using a development build, we want to switch to our custom try { - autoUpdater = new BlobBuildUpdater(plugin, file, "Slimefun4", "Dev"); + autoUpdater = new BlobBuildUpdater(plugin, file, "Slimefun5", "Dev"); } catch (Exception x) { plugin.getLogger().log(Level.SEVERE, "Failed to create AutoUpdater", x); } @@ -71,7 +71,7 @@ public UpdaterService(@Nonnull Slimefun plugin, @Nonnull String version, @Nonnul } else if (version.startsWith("RC - ")) { // If we are using a "stable" build, we want to switch to our custom try { - autoUpdater = new BlobBuildUpdater(plugin, file, "Slimefun4", "RC"); + autoUpdater = new BlobBuildUpdater(plugin, file, "Slimefun5", "RC"); } catch (Exception x) { plugin.getLogger().log(Level.SEVERE, "Failed to create AutoUpdater", x); } @@ -182,3 +182,4 @@ private void printBorder() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ActivityCallback.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ActivityCallback.java index e02236e392..879c588cfb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ActivityCallback.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.time.LocalDateTime; @@ -20,3 +20,4 @@ interface ActivityCallback { void accept(int forks, int stars, @Nonnull LocalDateTime date); } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/CommitsConnector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/CommitsConnector.java new file mode 100644 index 0000000000..80a61fcadb --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/CommitsConnector.java @@ -0,0 +1,151 @@ +package io.github.thebusybiscuit.slimefun5.core.services.github; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; + +/** + * This {@link GitHubConnector} aggregates the commit authors of a specific branch via the + * {@code /commits} endpoint, rather than the repository's default branch like + * {@link ContributionsConnector} does through {@code /contributors}. + *

+ * GitHub's {@code /contributors} endpoint only reports authors of the default branch, so + * anyone whose work lives on a feature/development branch (a very common situation for forks) is + * never credited. This connector walks the commit history of a configured development branch so + * that everyone who contributes to this fork is shown in the credits, not just the + * original upstream contributors. + * + * @author intisy + * + * @see ContributionsConnector + * @see GitHubService + */ +class CommitsConnector extends GitHubConnector { + + /** + * GitHub Bots and invalid accounts that should not be counted as contributors. + */ + private final List ignoredAccounts = new ArrayList<>(); + + private final String prefix; + private final String role; + private final String branch; + private final int page; + + private boolean finished = false; + + @ParametersAreNonnullByDefault + CommitsConnector(GitHubService github, String prefix, int page, String repository, String branch, ContributorRole role) { + super(github, repository); + + this.prefix = prefix; + this.page = page; + this.branch = branch; + this.role = role.getId(); + + ignoredAccounts.add("invalid-email-address"); + ignoredAccounts.add("renovate"); + ignoredAccounts.add("renovate-bot"); + ignoredAccounts.add("renovate[bot]"); + ignoredAccounts.add("TheBusyBot"); + ignoredAccounts.add("ImgBotApp"); + ignoredAccounts.add("imgbot"); + ignoredAccounts.add("imgbot[bot]"); + ignoredAccounts.add("github-actions[bot]"); + ignoredAccounts.add("gitlocalize-app"); + ignoredAccounts.add("gitlocalize-app[bot]"); + ignoredAccounts.add("mt-gitlocalize"); + } + + /** + * This returns whether this {@link CommitsConnector} has finished its task. + * + * @return Whether it is finished + */ + public boolean hasFinished() { + return finished; + } + + @Override + public void onSuccess(@Nonnull JsonElement response) { + finished = true; + + if (response.isJsonArray()) { + computeContributors(response.getAsJsonArray()); + } else { + Slimefun.logger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); + } + } + + @Override + public void onFailure() { + finished = true; + } + + @Override + public String getFileName() { + return prefix + "_contributors"; + } + + @Override + public String getEndpoint() { + return "/commits"; + } + + @Override + public Map getParameters() { + Map parameters = new HashMap<>(); + parameters.put("sha", branch); + parameters.put("per_page", 100); + parameters.put("page", page); + return parameters; + } + + private void computeContributors(@Nonnull JsonArray array) { + // The /commits endpoint returns one entry per commit, so we aggregate the commit count per + // author within this page before crediting them. Each page sets the count exactly once, + // which keeps the hourly refresh idempotent (no double-counting across runs). + Map commitsByAuthor = new LinkedHashMap<>(); + Map profileByAuthor = new HashMap<>(); + + for (JsonElement element : array) { + JsonObject commit = element.getAsJsonObject(); + JsonElement authorElement = commit.get("author"); + + // "author" is null when the commit's email is not linked to a GitHub account. + if (authorElement == null || authorElement.isJsonNull()) { + continue; + } + + JsonObject author = authorElement.getAsJsonObject(); + String name = author.get("login").getAsString(); + + if (ignoredAccounts.contains(name)) { + continue; + } + + commitsByAuthor.merge(name, 1, Integer::sum); + profileByAuthor.putIfAbsent(name, author.get("html_url").getAsString()); + } + + for (Map.Entry entry : commitsByAuthor.entrySet()) { + String name = entry.getKey(); + + // FORK_DEVELOPER is a distinct role, so this adds to the total instead of overwriting the + // contributor's authoritative /contributors count. + github.addContributor(name, profileByAuthor.get(name), role, entry.getValue()); + } + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ContributionsConnector.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ContributionsConnector.java index 4eb9d92637..9c19e96f0a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ContributionsConnector.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.util.ArrayList; import java.util.HashMap; @@ -13,7 +13,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class ContributionsConnector extends GitHubConnector { @@ -138,3 +138,4 @@ private void computeContributors(@Nonnull JsonArray array) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/Contributor.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/Contributor.java index 03173056bd..ebd23a2da1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/Contributor.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.util.ArrayList; import java.util.Comparator; @@ -16,8 +16,8 @@ import org.bukkit.ChatColor; import io.github.bakedlibs.dough.data.TriStateOptional; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; /** * Represents a {@link Contributor} who contributed to a GitHub repository. @@ -257,3 +257,4 @@ public int getPosition() { return -getTotalContributions(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributorRole.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ContributorRole.java similarity index 61% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributorRole.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ContributorRole.java index 3df962189c..9b86bf3114 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributorRole.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/ContributorRole.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import javax.annotation.Nonnull; @@ -16,6 +16,12 @@ enum ContributorRole { DEVELOPER("developer"), + /** + * Credit for commits made on this fork's development branch (see {@link CommitsConnector}). + * The id starts with '&' so it is rendered as a literal label instead of being looked up as a + * translation key, which keeps fork-specific crediting self-contained (no language files needed). + */ + FORK_DEVELOPER("&aFork Developer"), RESOURCEPACK_ARTIST("resourcepack"), TRANSLATOR("translator"), WIKI_EDITOR("wiki"); @@ -32,3 +38,4 @@ String getId() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubActivityConnector.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubActivityConnector.java index 60697f1345..00ea3fc2ea 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubActivityConnector.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.time.LocalDateTime; import java.util.HashMap; @@ -10,7 +10,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; class GitHubActivityConnector extends GitHubConnector { @@ -48,3 +48,4 @@ public Map getParameters() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubConnector.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubConnector.java index 6b7d89e1ea..765e5ea760 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubConnector.java @@ -1,17 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.logging.Level; @@ -22,22 +21,21 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParseException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.JsonUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.JsonUtils; /** * The {@link GitHubConnector} is used to connect to the GitHub API service. * It can be extended by subclasses, this just serves as an abstract super class for * other connectors. - * + * * @author TheBusyBiscuit * @author Walshy */ abstract class GitHubConnector { private static final String API_URL = "https://api.github.com/"; - private static final String USER_AGENT = "Slimefun4 (https://github.com/Slimefun)"; - private static final HttpClient client = HttpClient.newHttpClient(); + private static final String USER_AGENT = "Slimefun5 (https://github.com/Slimefun)"; protected final GitHubService github; private final String url; @@ -45,7 +43,7 @@ abstract class GitHubConnector { /** * This creates a new {@link GitHubConnector} for the given repository. - * + * * @param github * Our instance of {@link GitHubService} * @param repository @@ -58,7 +56,7 @@ abstract class GitHubConnector { /** * This returns the name of our cache {@link File}. - * + * * @return The cache {@link File} name */ @Nonnull @@ -67,7 +65,7 @@ abstract class GitHubConnector { /** * This is our {@link URL} endpoint. * It is the suffix of the {@link URL} we want to connect to. - * + * * @return Our endpoint */ @Nonnull @@ -75,7 +73,7 @@ abstract class GitHubConnector { /** * This {@link Map} contains the query parameters for our {@link URL}. - * + * * @return A {@link Map} with our query parameters */ @Nonnull @@ -83,7 +81,7 @@ abstract class GitHubConnector { /** * This method is called when the connection finished successfully. - * + * * @param response * The response */ @@ -114,20 +112,24 @@ void download() { .reduce((p1, p2) -> p1 + "&" + p2) .map(s -> "?" + s) .orElse(""); - URI uri = new URI(url + params); + URL endpoint = new URI(url + params).toURL(); - HttpResponse response = client.send( - HttpRequest.newBuilder(uri).header("User-Agent", USER_AGENT).build(), - HttpResponse.BodyHandlers.ofString() - ); - JsonElement element = JsonUtils.parseString(response.body()); + // Java 8: use HttpURLConnection instead of the Java 11 HttpClient so the universal jar + // runs on legacy (1.8+) servers running Java 8. + HttpURLConnection connection = (HttpURLConnection) endpoint.openConnection(); + connection.setRequestProperty("User-Agent", USER_AGENT); + connection.setConnectTimeout(10_000); + connection.setReadTimeout(10_000); - if (response.statusCode() >= 200 && response.statusCode() < 300) { + int statusCode = connection.getResponseCode(); + JsonElement element = JsonUtils.parseString(readBody(connection, statusCode)); + + if (statusCode >= 200 && statusCode < 300) { onSuccess(element); writeCacheFile(element); } else { if (github.isLoggingEnabled()) { - Slimefun.logger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { url, response.statusCode(), element }); + Slimefun.logger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { url, statusCode, element }); } // It has the cached file, let's just read that then @@ -139,7 +141,7 @@ void download() { } } } - } catch (IOException | InterruptedException | JsonParseException | URISyntaxException e) { + } catch (IOException | JsonParseException | URISyntaxException e) { if (github.isLoggingEnabled()) { Slimefun.logger().log(Level.WARNING, "Could not connect to GitHub in time.", e); } @@ -159,6 +161,30 @@ void download() { } } + /** + * Reads the full response body from the given connection as a UTF-8 String. For non-2xx responses + * the error stream is read instead (matching the previous behaviour of always parsing the body). + */ + @Nonnull + private static String readBody(@Nonnull HttpURLConnection connection, int statusCode) throws IOException { + InputStream stream = (statusCode >= 200 && statusCode < 300) ? connection.getInputStream() : connection.getErrorStream(); + + if (stream == null) { + return ""; + } + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) { + StringBuilder builder = new StringBuilder(); + String line; + + while ((line = reader.readLine()) != null) { + builder.append(line); + } + + return builder.toString(); + } + } + @Nullable private JsonElement readCacheFile() { try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubIssuesConnector.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubIssuesConnector.java index 96a4237e1e..2bf4eba7a0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubIssuesConnector.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.util.HashMap; import java.util.Map; @@ -11,7 +11,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; class GitHubIssuesConnector extends GitHubConnector { @@ -65,3 +65,4 @@ public Map getParameters() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubService.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubService.java index 17d158d27f..e558605fd0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.io.File; import java.time.LocalDateTime; @@ -17,8 +17,8 @@ import org.apache.commons.lang.Validate; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; /** * This Service is responsible for grabbing every {@link Contributor} to this project @@ -30,6 +30,15 @@ */ public class GitHubService { + /** + * This fork's primary development branch. GitHub's {@code /contributors} endpoint only reports + * authors of the default branch, so commits that live on a feature branch of this fork are never + * credited. We additionally aggregate this branch's commit history (see {@link CommitsConnector}) + * so every fork contributor is shown. Maintainers should set this to the branch their fork work + * lives on; it must be pushed to the fork repository for GitHub to return its commits. + */ + private static final String DEVELOPMENT_BRANCH = "feature/java8-universal-jar"; + private final String repository; private final Set connectors; private final ConcurrentMap contributors; @@ -132,15 +141,19 @@ private void loadConnectors(boolean logging) { this.logging = logging; addDefaultContributors(); - // TheBusyBiscuit/Slimefun4 (multiple times because there may me multiple pages) + // TheBusyBiscuit/Slimefun5 (multiple times because there may me multiple pages) connectors.add(new ContributionsConnector(this, "code", 1, repository, ContributorRole.DEVELOPER)); connectors.add(new ContributionsConnector(this, "code2", 2, repository, ContributorRole.DEVELOPER)); connectors.add(new ContributionsConnector(this, "code3", 3, repository, ContributorRole.DEVELOPER)); - // TheBusyBiscuit/Slimefun4-Wiki + // /contributors only lists default-branch authors; aggregate the dev branch's commits too. + connectors.add(new CommitsConnector(this, "branch_commits", 1, repository, DEVELOPMENT_BRANCH, ContributorRole.FORK_DEVELOPER)); + connectors.add(new CommitsConnector(this, "branch_commits2", 2, repository, DEVELOPMENT_BRANCH, ContributorRole.FORK_DEVELOPER)); + + // TheBusyBiscuit/Slimefun5-Wiki connectors.add(new ContributionsConnector(this, "wiki", 1, "Slimefun/Wiki", ContributorRole.WIKI_EDITOR)); - // TheBusyBiscuit/Slimefun4-Resourcepack + // TheBusyBiscuit/Slimefun5-Resourcepack connectors.add(new ContributionsConnector(this, "resourcepack", 1, "Slimefun/Resourcepack", ContributorRole.RESOURCEPACK_ARTIST)); // Issues and Pull Requests @@ -202,7 +215,7 @@ public int getOpenIssues() { } /** - * Returns the id of Slimefun's GitHub Repository. (e.g. "Slimefun/Slimefun4"). + * Returns the id of Slimefun's GitHub Repository. (e.g. "Slimefun5/Slimefun5"). * * @return The id of our GitHub Repository */ @@ -262,3 +275,4 @@ protected void saveCache() { return texturesCache.getString(username); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubTask.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubTask.java index 8b065e3ff4..109f1c89ec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/GitHubTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.io.File; import java.util.HashMap; @@ -16,9 +16,8 @@ import org.bukkit.Bukkit; -import io.github.bakedlibs.dough.skins.PlayerSkin; -import io.github.bakedlibs.dough.skins.UUIDLookup; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPlayerHead; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link GitHubTask} represents a {@link Runnable} that is run every X minutes. @@ -82,8 +81,8 @@ private void grabTextures() { } for (GitHubConnector connector : gitHubService.getConnectors()) { - if (connector instanceof ContributionsConnector contributionsConnector && !contributionsConnector.hasFinished()) { - return; + if (connector instanceof ContributionsConnector && !((ContributionsConnector) connector).hasFinished()) { + ContributionsConnector contributionsConnector = (ContributionsConnector) connector; return; } } @@ -133,7 +132,7 @@ private int requestTexture(@Nonnull Contributor contributor, @Nonnull Map uuid = contributor.getUniqueId(); if (!uuid.isPresent()) { - CompletableFuture future = UUIDLookup.getUuidFromUsername(Slimefun.instance(), contributor.getMinecraftName()); + CompletableFuture future = VersionedPlayerHead.lookupUUID(contributor.getMinecraftName()); // Fixes #3241 - Do not wait for more than 30 seconds uuid = Optional.ofNullable(future.get(30, TimeUnit.SECONDS)); @@ -141,13 +140,16 @@ private int requestTexture(@Nonnull Contributor contributor, @Nonnull Map future = PlayerSkin.fromPlayerUUID(Slimefun.instance(), uuid.get()); - Optional skin = Optional.of(future.get().getProfile().getBase64Texture()); - skins.put(contributor.getMinecraftName(), skin.orElse("")); - return skin.orElse(null); + CompletableFuture future = VersionedPlayerHead.fetchSkinTexture(uuid.get()); + String texture = future.get(30, TimeUnit.SECONDS); + if (texture != null) { + skins.put(contributor.getMinecraftName(), texture); + } + return texture; } else { return null; } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesCallback.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/IssuesCallback.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesCallback.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/IssuesCallback.java index 7d32f72da8..40df098664 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/IssuesCallback.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/IssuesCallback.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; @FunctionalInterface interface IssuesCallback { @@ -14,3 +14,4 @@ interface IssuesCallback { void accept(int issues, int pullRequests); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/TranslatorsReader.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/TranslatorsReader.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/TranslatorsReader.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/TranslatorsReader.java index c6683186c0..1a7f76433c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/TranslatorsReader.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/TranslatorsReader.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.github; +package io.github.thebusybiscuit.slimefun5.core.services.github; import java.io.BufferedReader; import java.io.InputStream; @@ -14,8 +14,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.JsonUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.JsonUtils; /** * This class reads all translators of this project. @@ -60,3 +60,4 @@ public void load() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/package-info.java similarity index 55% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/package-info.java index ce09970210..546a38090d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/github/package-info.java @@ -1,4 +1,4 @@ /** * This package contains everything related to GitHub and contributors. */ -package io.github.thebusybiscuit.slimefun4.core.services.github; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.services.github; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/Hologram.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/Hologram.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/Hologram.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/Hologram.java index b69e71d534..5a84bee51a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/Hologram.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/Hologram.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.holograms; +package io.github.thebusybiscuit.slimefun5.core.services.holograms; import java.util.Objects; import java.util.UUID; @@ -8,6 +8,7 @@ import javax.annotation.Nullable; import org.bukkit.Bukkit; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; @@ -60,10 +61,10 @@ class Hologram { */ @Nullable ArmorStand getArmorStand() { - Entity n = Bukkit.getEntity(uniqueId); + Entity n = (Entity) ReflectionCompat.invokeStatic(Bukkit.class, "getEntity", uniqueId); - if (n instanceof ArmorStand armorStand && n.isValid()) { - this.lastAccess = System.currentTimeMillis(); + if (n instanceof ArmorStand && n.isValid()) { + ArmorStand armorStand = (ArmorStand) n; this.lastAccess = System.currentTimeMillis(); return armorStand; } else { this.lastAccess = 0; @@ -133,3 +134,4 @@ void remove() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/HologramsService.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/HologramsService.java index 2673dd9b91..43a3f01c21 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/HologramsService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/HologramsService.java @@ -1,5 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.core.services.holograms; +package io.github.thebusybiscuit.slimefun5.core.services.holograms; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; @@ -14,7 +18,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.Server; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; @@ -25,8 +29,8 @@ import org.bukkit.util.Vector; import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This service is responsible for handling holograms. @@ -139,22 +143,20 @@ private Hologram getHologram(@Nonnull Location loc, boolean createIfNoneExists) } // Scan all nearby entities which could be possible holograms - Collection holograms = loc.getWorld().getNearbyEntities(loc, RADIUS, RADIUS, RADIUS, this::isHologram); + Collection holograms = EntityCompat.getNearbyEntities(loc.getWorld(), loc, RADIUS, RADIUS, RADIUS, this::isHologram); for (Entity n : holograms) { if (n instanceof ArmorStand) { - PersistentDataContainer container = n.getPersistentDataContainer(); - /* * Any hologram we created will have a persistent data key for identification. * Make sure that the value matches our BlockPosition. */ - if (hasHologramData(container, position)) { + if (hasHologramData(n, position)) { if (hologram != null) { // Fixes #2927 - Remove any duplicates we find n.remove(); } else { - hologram = getAsHologram(position, n, container); + hologram = getAsHologram(position, n); } } } @@ -163,18 +165,17 @@ private Hologram getHologram(@Nonnull Location loc, boolean createIfNoneExists) if (hologram == null && createIfNoneExists) { // Spawn a new ArmorStand ArmorStand armorstand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND); - PersistentDataContainer container = armorstand.getPersistentDataContainer(); - return getAsHologram(position, armorstand, container); + return getAsHologram(position, armorstand); } else { return hologram; } } @ParametersAreNonnullByDefault - private boolean hasHologramData(PersistentDataContainer container, BlockPosition position) { - if (container.has(persistentDataKey, PersistentDataType.LONG)) { - long value = container.get(persistentDataKey, PersistentDataType.LONG); + private boolean hasHologramData(Entity holder, BlockPosition position) { + if (PdcCompat.has(holder, persistentDataKey, "LONG")) { + long value = (Long) PdcCompat.get(holder, persistentDataKey, "LONG"); return value == position.getPosition(); } else { return false; @@ -191,9 +192,9 @@ private boolean hasHologramData(PersistentDataContainer container, BlockPosition * @return Whether this could be a hologram */ private boolean isHologram(@Nonnull Entity n) { - if (n instanceof ArmorStand armorStand) { - // The absolute minimum requirements to count as a hologram - return !armorStand.isVisible() && armorStand.isSilent() && !armorStand.hasGravity(); + if (n instanceof ArmorStand) { + ArmorStand armorStand = (ArmorStand) n; // The absolute minimum requirements to count as a hologram + return !armorStand.isVisible() && Boolean.TRUE.equals(ReflectionCompat.invoke(armorStand, "isSilent")) && !armorStand.hasGravity(); } else { return false; } @@ -213,18 +214,18 @@ private boolean isHologram(@Nonnull Entity n) { * @return The {@link Hologram} */ @Nullable - private Hologram getAsHologram(@Nonnull BlockPosition position, @Nonnull Entity entity, @Nonnull PersistentDataContainer container) { - if (entity instanceof ArmorStand armorStand) { - armorStand.setVisible(false); - armorStand.setInvulnerable(true); - armorStand.setSilent(true); + private Hologram getAsHologram(@Nonnull BlockPosition position, @Nonnull Entity entity) { + if (entity instanceof ArmorStand) { + ArmorStand armorStand = (ArmorStand) entity; armorStand.setVisible(false); + ReflectionCompat.invoke(armorStand, "setInvulnerable", true); + ReflectionCompat.invoke(armorStand, "setSilent", true); armorStand.setMarker(true); - armorStand.setAI(false); + ReflectionCompat.invoke(armorStand, "setAI", false); armorStand.setGravity(false); armorStand.setRemoveWhenFarAway(false); // Set a persistent tag to re-identify the correct hologram later - container.set(persistentDataKey, PersistentDataType.LONG, position.getPosition()); + PdcCompat.set(entity, persistentDataKey, "LONG", position.getPosition()); // Store in cache for faster access Hologram hologram = new Hologram(armorStand.getUniqueId()); @@ -322,3 +323,4 @@ public void setHologramLabel(@Nonnull Location loc, @Nullable String label) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/package-info.java new file mode 100644 index 0000000000..7d4bf00745 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/holograms/package-info.java @@ -0,0 +1,5 @@ +/** + * This package contains everything related to the + * {@link io.github.thebusybiscuit.slimefun5.core.services.holograms.HologramsService}. + */ +package io.github.thebusybiscuit.slimefun5.core.services.holograms; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/Language.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/Language.java index 0db0125e2e..86ec33d494 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/Language.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.localization; +package io.github.thebusybiscuit.slimefun5.core.services.localization; import java.util.Arrays; import java.util.EnumMap; @@ -14,10 +14,10 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.services.LocalizationService; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This Class represents a {@link Language} that Slimefun can recognize and use. @@ -141,3 +141,4 @@ FileConfiguration[] getFiles() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/LanguageFile.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/LanguageFile.java index 67f90dfb60..f6c8de7892 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/LanguageFile.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.localization; +package io.github.thebusybiscuit.slimefun5.core.services.localization; import javax.annotation.Nonnull; @@ -41,3 +41,4 @@ public String getFilePath(@Nonnull String languageId) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/LanguagePreset.java similarity index 98% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/LanguagePreset.java index 6b5e4bc09d..f0efcad4fc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/LanguagePreset.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.localization; +package io.github.thebusybiscuit.slimefun5.core.services.localization; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -129,3 +129,4 @@ boolean isReadyForRelease() { return textDirection; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/SlimefunLocalization.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/SlimefunLocalization.java index a146a9f620..feafb6665b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/localization/SlimefunLocalization.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.localization; +package io.github.thebusybiscuit.slimefun5.core.services.localization; import java.util.Arrays; import java.util.Collection; @@ -13,24 +13,25 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; -import org.bukkit.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.config.Config; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedItemFlag; +import io.github.thebusybiscuit.slimefun5.api.SlimefunBranch; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.LocalizationService; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; @@ -337,8 +338,8 @@ protected void loadEmbeddedLanguages() { meta.setLore(lore); } - meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); + VersionedItemFlag.addFlags(meta, VersionedItemFlag.HIDE_ATTRIBUTES); + VersionedItemFlag.addFlags(meta, VersionedItemFlag.HIDE_ENCHANTS); }); } @@ -348,8 +349,8 @@ public void sendMessage(@Nonnull CommandSender recipient, @Nonnull String key, b String prefix = addPrefix ? getChatPrefix() : ""; - if (recipient instanceof Player player) { - recipient.sendMessage(ChatColors.color(prefix + getMessage(player, key))); + if (recipient instanceof Player) { + Player player = (Player) recipient; recipient.sendMessage(ChatColors.color(prefix + getMessage(player, key))); } else { recipient.sendMessage(ChatColor.stripColor(ChatColors.color(prefix + getMessage(key)))); } @@ -363,7 +364,8 @@ public void sendActionbarMessage(@Nonnull Player player, @Nonnull String key, bo String message = ChatColors.color(prefix + getMessage(player, key)); BaseComponent[] components = TextComponent.fromLegacyText(message); - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components); + // The (ChatMessageType, BaseComponent[]) sendMessage overload is post-1.8; reached reflectively. + ReflectionCompat.invoke(player.spigot(), "sendMessage", ChatMessageType.ACTION_BAR, components); } public void sendMessage(@Nonnull CommandSender recipient, @Nonnull String key) { @@ -383,8 +385,8 @@ public void sendMessage(CommandSender recipient, String key, boolean addPrefix, String prefix = addPrefix ? getChatPrefix() : ""; - if (recipient instanceof Player player) { - recipient.sendMessage(ChatColors.color(prefix + function.apply(getMessage(player, key)))); + if (recipient instanceof Player) { + Player player = (Player) recipient; recipient.sendMessage(ChatColors.color(prefix + function.apply(getMessage(player, key)))); } else { recipient.sendMessage(ChatColor.stripColor(ChatColors.color(prefix + function.apply(getMessage(key))))); } @@ -393,8 +395,8 @@ public void sendMessage(CommandSender recipient, String key, boolean addPrefix, public void sendMessages(@Nonnull CommandSender recipient, @Nonnull String key) { String prefix = getChatPrefix(); - if (recipient instanceof Player player) { - for (String translation : getMessages(player, key)) { + if (recipient instanceof Player) { + Player player = (Player) recipient; for (String translation : getMessages(player, key)) { String message = ChatColors.color(prefix + translation); recipient.sendMessage(message); } @@ -410,8 +412,8 @@ public void sendMessages(@Nonnull CommandSender recipient, @Nonnull String key) public void sendMessages(CommandSender recipient, String key, boolean addPrefix, UnaryOperator function) { String prefix = addPrefix ? getChatPrefix() : ""; - if (recipient instanceof Player player) { - for (String translation : getMessages(player, key)) { + if (recipient instanceof Player) { + Player player = (Player) recipient; for (String translation : getMessages(player, key)) { String message = ChatColors.color(prefix + function.apply(translation)); recipient.sendMessage(message); } @@ -442,3 +444,4 @@ public void sendMessages(CommandSender recipient, String key, UnaryOperator> results = inspector.getOrderType().sort(profiler, entrySet); String prefix = count + " " + name + (count != 1 ? 's' : ""); - if (inspector instanceof PlayerPerformanceInspector playerPerformanceInspector) { - TextComponent component = summarizeAsTextComponent(count, prefix, results, formatter); + if (inspector instanceof PlayerPerformanceInspector) { + PlayerPerformanceInspector playerPerformanceInspector = (PlayerPerformanceInspector) inspector; TextComponent component = summarizeAsTextComponent(count, prefix, results, formatter); playerPerformanceInspector.sendMessage(component); } else { String text = summarizeAsString(inspector, count, prefix, results, formatter); @@ -134,8 +132,9 @@ private TextComponent summarizeAsTextComponent(int count, String prefix, List> sort(SlimefunProfiler profiler, Set= 0, "The volume cannot be a negative number."); + Preconditions.checkArgument(pitch >= 0.5, "A pitch below 0.5 has no effect on the sound."); + + this.defaultSound = sound; + this.defaultVolume = volume; + this.defaultPitch = pitch; + } + + private @Nullable SoundConfiguration getConfiguration() { + SoundConfiguration config = Slimefun.getSoundService().getConfiguration(this); + + if (config == null) { + // This should not happen. But if it does... send a warning + Slimefun.logger().log(Level.WARNING, "Could not find any sound configuration for: {0}", name()); + } + + return config; + } + + /** + * This method will play this {@link SoundEffect} only to the given {@link Player} using the + * eye {@link Location} of the {@link Player} and the {@link SoundCategory} {@code PLAYERS}. + * + * @param player The {@link Player} which to play the {@link Sound} to. + */ + public void playFor(@Nonnull Player player) { + Preconditions.checkNotNull(player, "Cannot play sounds to a Player that is null!"); + SoundConfiguration config = getConfiguration(); + + if (config != null) { + SoundCompat.playFor(player, player.getEyeLocation(), config.getSoundId(), SoundCategory.PLAYERS, config.getVolume(), config.getPitch()); + } + } + + /** + * This method will play this {@link SoundEffect} at the given {@link Location} using the + * provided {@link SoundCategory}. + * + * @param loc The {@link Location} at which to play the {@link SoundEffect}. + * @param category The {@link SoundCategory} that should be used. + */ + public void playAt(@Nonnull Location loc, @Nonnull SoundCategory category) { + Preconditions.checkNotNull(loc, "The location should not be null."); + SoundConfiguration config = getConfiguration(); + + if (config != null && loc.getWorld() != null) { + SoundCompat.playAt(loc, config.getSoundId(), category, config.getVolume(), config.getPitch()); + } + } + + /** + * This method will play this {@link SoundEffect} at the {@link Location} of the given {@link Block}, + * the used {@link SoundCategory} will be {@code BLOCKS}. + * + * @param block The {@link Block} at which to play the {@link SoundEffect} + */ + public void playAt(@Nonnull Block block) { + Preconditions.checkNotNull(block, "The block cannot be null."); + playAt(block.getLocation(), SoundCategory.BLOCKS); + } + + /** + * This returns the default sound id. + * + * @return The default sound id. + */ + public @Nonnull String getDefaultSoundId() { + return defaultSound; + } + + /** + * This returns the default volume. + * + * @return The default volume. + */ + public float getDefaultVolume() { + return defaultVolume; + } + + /** + * This returns the default pitch. + * + * @return The default pitch. + */ + public float getDefaultPitch() { + return defaultPitch; + } +} + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/sounds/SoundService.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/sounds/SoundService.java index 1c1d1133a8..1e7718b7ea 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/sounds/SoundService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.sounds; +package io.github.thebusybiscuit.slimefun5.core.services.sounds; import java.util.EnumMap; import java.util.Map; @@ -8,7 +8,7 @@ import javax.annotation.Nullable; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import com.google.common.base.Preconditions; @@ -107,3 +107,4 @@ private void reloadSound(@Nonnull SoundEffect sound) { return soundMap.get(sound); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/sounds/package-info.java similarity index 60% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/sounds/package-info.java index c14c511439..cb2d95789e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/core/services/sounds/package-info.java @@ -1,7 +1,7 @@ /** * This package holds classes related to the - * {@link io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundService}. + * {@link io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundService}. * This service is responsible for our sound management and allowing server owners to fully customize * their sound experience. */ -package io.github.thebusybiscuit.slimefun4.core.services.sounds; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.core.services.sounds; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/Slimefun.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/Slimefun.java index 1be851ba17..2ff362a77c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/Slimefun.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation; +package io.github.thebusybiscuit.slimefun5.implementation; import java.io.File; import java.util.ArrayList; @@ -14,8 +14,8 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.thebusybiscuit.slimefun4.storage.Storage; -import io.github.thebusybiscuit.slimefun4.storage.backend.legacy.LegacyStorage; +import io.github.thebusybiscuit.slimefun5.storage.Storage; +import io.github.thebusybiscuit.slimefun5.storage.backend.legacy.LegacyStorage; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; @@ -32,103 +32,103 @@ import io.github.bakedlibs.dough.config.Config; import io.github.bakedlibs.dough.protection.ProtectionManager; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; -import io.github.thebusybiscuit.slimefun4.core.services.AnalyticsService; -import io.github.thebusybiscuit.slimefun4.core.services.AutoSavingService; -import io.github.thebusybiscuit.slimefun4.core.services.BackupService; -import io.github.thebusybiscuit.slimefun4.core.services.BlockDataService; -import io.github.thebusybiscuit.slimefun4.core.services.CustomItemDataService; -import io.github.thebusybiscuit.slimefun4.core.services.CustomTextureService; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.core.services.MetricsService; -import io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService; -import io.github.thebusybiscuit.slimefun4.core.services.PerWorldSettingsService; -import io.github.thebusybiscuit.slimefun4.core.services.PermissionsService; -import io.github.thebusybiscuit.slimefun4.core.services.ThreadService; -import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService; -import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService; -import io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.SlimefunProfiler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundService; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.BeeWings; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AutoCrafterListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeWingsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ButcherAndroidListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraImpactListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.HopperListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemDropListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.JoinListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.MiddleClickListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.MiningAndroidListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.RadioactivityListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SeismicAxeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunGuideListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemConsumeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemHitListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemInteractListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.VillagerTradingListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.AnvilListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.BrewingStandListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CartographyTableListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CauldronListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CraftingTableListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.SmithingTableListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.BeeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.EntityInteractionListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.FireworksListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.IronGolemListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.MobDropListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.PiglinListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.WitherListener; -import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup; -import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; -import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; -import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RainbowArmorTask; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SlimefunArmorTask; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SolarHelmetTask; -import io.github.thebusybiscuit.slimefun4.integrations.IntegrationsManager; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.gps.GPSNetwork; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.SlimefunRegistry; +import io.github.thebusybiscuit.slimefun5.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun5.core.networks.NetworkManager; +import io.github.thebusybiscuit.slimefun5.core.services.AnalyticsService; +import io.github.thebusybiscuit.slimefun5.core.services.AutoSavingService; +import io.github.thebusybiscuit.slimefun5.core.services.BackupService; +import io.github.thebusybiscuit.slimefun5.core.services.BlockDataService; +import io.github.thebusybiscuit.slimefun5.core.services.CustomItemDataService; +import io.github.thebusybiscuit.slimefun5.core.services.CustomTextureService; +import io.github.thebusybiscuit.slimefun5.core.services.LocalizationService; +import io.github.thebusybiscuit.slimefun5.core.services.MetricsService; +import io.github.thebusybiscuit.slimefun5.core.services.MinecraftRecipeService; +import io.github.thebusybiscuit.slimefun5.core.services.PerWorldSettingsService; +import io.github.thebusybiscuit.slimefun5.core.services.PermissionsService; +import io.github.thebusybiscuit.slimefun5.core.services.ThreadService; +import io.github.thebusybiscuit.slimefun5.core.services.UpdaterService; +import io.github.thebusybiscuit.slimefun5.core.services.github.GitHubService; +import io.github.thebusybiscuit.slimefun5.core.services.holograms.HologramsService; +import io.github.thebusybiscuit.slimefun5.core.services.profiler.SlimefunProfiler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundService; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientAltar; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.Cooler; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.BeeWings; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GrapplingHook; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.SeismicAxe; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.AncientAltarListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.AutoCrafterListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BackpackListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BeeWingsListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BlockListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BlockPhysicsListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.ButcherAndroidListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.CargoNodeListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.CoolerListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.DeathpointListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.DebugFishListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.DispenserListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.ElytraImpactListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.EnhancedFurnaceListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.ExplosionsListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.GadgetsListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.GrapplingHookListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.HopperListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.ItemDropListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.ItemPickupListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.JoinListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.MiddleClickListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.MiningAndroidListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.MultiBlockListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.NetworkListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.PlayerProfileListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.RadioactivityListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SeismicAxeListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SlimefunBootsListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SlimefunBowListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SlimefunGuideListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SlimefunItemConsumeListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SlimefunItemHitListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SlimefunItemInteractListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SoulboundListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.TalismanListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.VillagerTradingListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.AnvilListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.BrewingStandListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.CartographyTableListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.CauldronListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.CraftingTableListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.GrindstoneListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.SmithingTableListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.BeeListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.EntityInteractionListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.FireworksListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.IronGolemListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.MobDropListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.PiglinListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.WitherListener; +import io.github.thebusybiscuit.slimefun5.implementation.resources.GEOResourcesSetup; +import io.github.thebusybiscuit.slimefun5.implementation.setup.PostSetup; +import io.github.thebusybiscuit.slimefun5.implementation.setup.ResearchSetup; +import io.github.thebusybiscuit.slimefun5.implementation.setup.SlimefunItemSetup; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.SlimefunStartupTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.TickerTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.RadiationTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.RainbowArmorTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.SlimefunArmorTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.SolarHelmetTask; +import io.github.thebusybiscuit.slimefun5.integrations.IntegrationsManager; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.MenuListener; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -174,7 +174,7 @@ public class Slimefun extends JavaPlugin implements SlimefunAddon { private final CustomItemDataService itemDataService = new CustomItemDataService(this, "slimefun_item"); private final BlockDataService blockDataService = new BlockDataService(this, "slimefun_block"); private final CustomTextureService textureService = new CustomTextureService(new Config(this, "item-models.yml")); - private final GitHubService gitHubService = new GitHubService("Slimefun/Slimefun4"); + private final GitHubService gitHubService = new GitHubService("Slimefun5/Slimefun5"); private final UpdaterService updaterService = new UpdaterService(this, getDescription().getVersion(), getFile()); private final MetricsService metricsService = new MetricsService(this); private final AutoSavingService autoSavingService = new AutoSavingService(); @@ -218,7 +218,8 @@ public Slimefun() { // Check that we got loaded by MockBukkit rather than Bukkit's loader // TODO: This is very much a hack and we can hopefully move to a more native way in the future - if (getClassLoader().getClass().getPackageName().startsWith("be.seeseemelk.mockbukkit")) { + String classLoaderPackage = getClassLoader().getClass().getPackage().getName(); + if (classLoaderPackage.startsWith("be.seeseemelk.mockbukkit") || classLoaderPackage.startsWith("org.mockbukkit.mockbukkit")) { minecraftVersion = MinecraftVersion.UNIT_TEST; } } @@ -399,7 +400,7 @@ public JavaPlugin getJavaPlugin() { @Override public String getBugTrackerURL() { - return "https://github.com/Slimefun/Slimefun4/issues"; + return "https://github.com/Slimefun5/Slimefun5/issues"; } /** @@ -523,9 +524,19 @@ private boolean isVersionUnsupported() { return true; } + // Now check the actual Version of Minecraft int version = PaperLib.getMinecraftVersion(); int patchVersion = PaperLib.getMinecraftPatchVersion(); + + if (version == 0) { + java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("MC: (\\d+)\\.(\\d+)").matcher(Bukkit.getVersion()); + if (matcher.find()) { + version = Integer.parseInt(matcher.group(1)); + patchVersion = Integer.parseInt(matcher.group(2)); + } + } + if (version > 0) { // Check all supported versions of Minecraft @@ -611,65 +622,85 @@ private void createDirectories() { */ private void registerListeners() { // Old deprecated CS-CoreLib Listener - new MenuListener(this); - - new SlimefunBootsListener(this); - new SlimefunItemInteractListener(this); - new SlimefunItemConsumeListener(this); - new BlockPhysicsListener(this); - new CargoNodeListener(this); - new MultiBlockListener(this); - new GadgetsListener(this); - new DispenserListener(this); - new BlockListener(this); - new EnhancedFurnaceListener(this); - new ItemPickupListener(this); - new ItemDropListener(this); - new DeathpointListener(this); - new ExplosionsListener(this); - new DebugFishListener(this); - new FireworksListener(this); - new WitherListener(this); - new IronGolemListener(this); - new EntityInteractionListener(this); - new MobDropListener(this); - new VillagerTradingListener(this); - new ElytraImpactListener(this); - new CraftingTableListener(this); - new AnvilListener(this); - new BrewingStandListener(this); - new CauldronListener(this); - new GrindstoneListener(this); - new CartographyTableListener(this); - new ButcherAndroidListener(this); - new MiningAndroidListener(this); - new NetworkListener(this, networkManager); - new HopperListener(this); - new TalismanListener(this); - new SoulboundListener(this); - new AutoCrafterListener(this); - new SlimefunItemHitListener(this); - new MiddleClickListener(this); - new BeeListener(this); - new BeeWingsListener(this, (BeeWings) SlimefunItems.BEE_WINGS.getItem()); - new PiglinListener(this); - new SmithingTableListener(this); - new JoinListener(this); + register(() -> new MenuListener(this)); + + register(() -> new SlimefunBootsListener(this)); + register(() -> new SlimefunItemInteractListener(this)); + register(() -> new SlimefunItemConsumeListener(this)); + register(() -> new BlockPhysicsListener(this)); + register(() -> new CargoNodeListener(this)); + register(() -> new MultiBlockListener(this)); + register(() -> new GadgetsListener(this)); + register(() -> new DispenserListener(this)); + register(() -> new BlockListener(this)); + register(() -> new EnhancedFurnaceListener(this)); + register(() -> new ItemPickupListener(this)); + register(() -> new ItemDropListener(this)); + register(() -> new DeathpointListener(this)); + register(() -> new ExplosionsListener(this)); + register(() -> new DebugFishListener(this)); + register(() -> new FireworksListener(this)); + register(() -> new WitherListener(this)); + register(() -> new IronGolemListener(this)); + register(() -> new EntityInteractionListener(this)); + register(() -> new MobDropListener(this)); + register(() -> new VillagerTradingListener(this)); + register(() -> new ElytraImpactListener(this)); + register(() -> new CraftingTableListener(this)); + register(() -> new AnvilListener(this)); + register(() -> new BrewingStandListener(this)); + register(() -> new CauldronListener(this)); + register(() -> new GrindstoneListener(this)); + register(() -> new CartographyTableListener(this)); + register(() -> new ButcherAndroidListener(this)); + register(() -> new MiningAndroidListener(this)); + register(() -> new NetworkListener(this, networkManager)); + register(() -> new HopperListener(this)); + register(() -> new TalismanListener(this)); + register(() -> new SoulboundListener(this)); + register(() -> new AutoCrafterListener(this)); + register(() -> new SlimefunItemHitListener(this)); + register(() -> new MiddleClickListener(this)); + if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { + register(() -> new BeeListener(this)); + register(() -> new BeeWingsListener(this, (BeeWings) SlimefunItems.BEE_WINGS.getItem())); + } + register(() -> new PiglinListener(this)); + register(() -> new SmithingTableListener(this)); + register(() -> new JoinListener(this)); // Item-specific Listeners - new CoolerListener(this, (Cooler) SlimefunItems.COOLER.getItem()); - new SeismicAxeListener(this, (SeismicAxe) SlimefunItems.SEISMIC_AXE.getItem()); - new RadioactivityListener(this); - new AncientAltarListener(this, (AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem(), (AncientPedestal) SlimefunItems.ANCIENT_PEDESTAL.getItem()); - grapplingHookListener.register(this, (GrapplingHook) SlimefunItems.GRAPPLING_HOOK.getItem()); - bowListener.register(this); - backpackListener.register(this); + register(() -> new CoolerListener(this, (Cooler) SlimefunItems.COOLER.getItem())); + register(() -> new SeismicAxeListener(this, (SeismicAxe) SlimefunItems.SEISMIC_AXE.getItem())); + register(() -> new RadioactivityListener(this)); + register(() -> new AncientAltarListener(this, (AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem(), (AncientPedestal) SlimefunItems.ANCIENT_PEDESTAL.getItem())); + register(() -> grapplingHookListener.register(this, (GrapplingHook) SlimefunItems.GRAPPLING_HOOK.getItem())); + register(() -> bowListener.register(this)); + register(() -> backpackListener.register(this)); // Handle Slimefun Guide being given on Join - new SlimefunGuideListener(this, config.getBoolean("guide.receive-on-first-join")); + register(() -> new SlimefunGuideListener(this, config.getBoolean("guide.receive-on-first-join"))); // Clear the Slimefun Guide History upon Player Leaving - new PlayerProfileListener(this); + register(() -> new PlayerProfileListener(this)); + } + + /** + * Registers a single {@link Listener}, tolerating failures caused by the universal Java-8 jar + * running on a legacy server. A {@link Listener} whose event types or items only exist on newer + * Minecraft versions throws {@link NoClassDefFoundError} (or another {@link LinkageError}) when + * Bukkit inspects its handler methods; on modern servers this never triggers, but on legacy we + * log and skip that one listener instead of aborting the whole plugin enable. + * + * @param listenerInit + * The action that constructs and registers the {@link Listener} + */ + private void register(@Nonnull Runnable listenerInit) { + try { + listenerInit.run(); + } catch (LinkageError | RuntimeException e) { + getLogger().log(Level.WARNING, e, () -> "Skipped a listener that is unavailable on this Minecraft version"); + } } /** @@ -1096,3 +1127,4 @@ public static boolean isNewlyInstalled() { return instance().threadService; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/SlimefunItems.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/SlimefunItems.java index 62bc4d59e9..e0a5c73129 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/SlimefunItems.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation; +package io.github.thebusybiscuit.slimefun5.implementation; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ItemMetaCompat; import java.util.ArrayList; import java.util.HashMap; @@ -8,22 +10,23 @@ import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineTier; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.StormStaff; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ColoredFireworkStar; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.core.attributes.MachineTier; +import io.github.thebusybiscuit.slimefun5.core.attributes.MachineType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactivity; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves.StormStaff; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.LoreBuilder; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEnchantment; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedItemFlag; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ColoredFireworkStar; /** * This class holds a static references to every {@link SlimefunItemStack} @@ -38,17 +41,17 @@ private SlimefunItems() {} public static final SlimefunItemStack PORTABLE_CRAFTER = new SlimefunItemStack("PORTABLE_CRAFTER", HeadTexture.PORTABLE_CRAFTER, "&6Portable Crafter", "&a&oA portable Crafting Table", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); public static final SlimefunItemStack PORTABLE_DUSTBIN = new SlimefunItemStack("PORTABLE_DUSTBIN", HeadTexture.TRASH_CAN, "&6Portable Dustbin", "&fYour portable Item-Destroyer", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); public static final SlimefunItemStack ENDER_BACKPACK = new SlimefunItemStack("ENDER_BACKPACK", HeadTexture.ENDER_BACKPACK, "&6Ender Backpack", "&a&oA portable Ender Chest", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack MAGIC_EYE_OF_ENDER = new SlimefunItemStack("MAGIC_EYE_OF_ENDER", Material.ENDER_EYE, "&6&lMagic Eye of Ender", "&4&lRequires full Ender Armor", "", "&7&eRight Click&7 to shoot an Ender Pearl"); - public static final SlimefunItemStack BROKEN_SPAWNER = new SlimefunItemStack("BROKEN_SPAWNER", Material.SPAWNER, "&cBroken Spawner", "&7Type: &b", "", "&cFractured, must be repaired in an Ancient Altar"); - public static final SlimefunItemStack REPAIRED_SPAWNER = new SlimefunItemStack("REINFORCED_SPAWNER", Material.SPAWNER, "&bReinforced Spawner", "&7Type: &b"); - public static final SlimefunItemStack INFERNAL_BONEMEAL = new SlimefunItemStack("INFERNAL_BONEMEAL", Material.BONE_MEAL, "&4Infernal Bonemeal", "", "&cSpeeds up the Growth of", "&cNether Warts as well"); + public static final SlimefunItemStack MAGIC_EYE_OF_ENDER = new SlimefunItemStack("MAGIC_EYE_OF_ENDER", XMaterial.ENDER_EYE.parseMaterial(), "&6&lMagic Eye of Ender", "&4&lRequires full Ender Armor", "", "&7&eRight Click&7 to shoot an Ender Pearl"); + public static final SlimefunItemStack BROKEN_SPAWNER = new SlimefunItemStack("BROKEN_SPAWNER", XMaterial.SPAWNER.parseMaterial(), "&cBroken Spawner", "&7Type: &b", "", "&cFractured, must be repaired in an Ancient Altar"); + public static final SlimefunItemStack REPAIRED_SPAWNER = new SlimefunItemStack("REINFORCED_SPAWNER", XMaterial.SPAWNER.parseMaterial(), "&bReinforced Spawner", "&7Type: &b"); + public static final SlimefunItemStack INFERNAL_BONEMEAL = new SlimefunItemStack("INFERNAL_BONEMEAL", XMaterial.BONE_MEAL.parseMaterial(), "&4Infernal Bonemeal", "", "&cSpeeds up the Growth of", "&cNether Warts as well"); public static final SlimefunItemStack TAPE_MEASURE = new SlimefunItemStack("TAPE_MEASURE", "180d5c43a6cf5bb7769fd0c8240e1e70d2ae38ef9d78a1db401aca6a2cb36f65", "&6Tape Measure", "", "&eCrouch & Right Click &7to set an anchor", "&eRight Click &7to measure"); /* Gadgets */ public static final SlimefunItemStack GOLD_PAN = new SlimefunItemStack("GOLD_PAN", Material.BOWL, "&6Gold Pan", "", "&eRight Click&7 to collect resources", "&7from Gravel"); public static final SlimefunItemStack NETHER_GOLD_PAN = new SlimefunItemStack("NETHER_GOLD_PAN", Material.BOWL, "&4Nether Gold Pan", "", "&eRight Click&7 to collect resources", "&7from Soul Sand"); public static final SlimefunItemStack PARACHUTE = new SlimefunItemStack("PARACHUTE", Material.LEATHER_CHESTPLATE, Color.WHITE, "&f&lParachute", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack GRAPPLING_HOOK = new SlimefunItemStack("GRAPPLING_HOOK", Material.LEAD, "&6Grappling Hook", "", LoreBuilder.RIGHT_CLICK_TO_USE); + public static final SlimefunItemStack GRAPPLING_HOOK = new SlimefunItemStack("GRAPPLING_HOOK", XMaterial.LEAD.parseMaterial(), "&6Grappling Hook", "", LoreBuilder.RIGHT_CLICK_TO_USE); public static final SlimefunItemStack SOLAR_HELMET = new SlimefunItemStack("SOLAR_HELMET", Material.IRON_HELMET, "&bSolar Helmet", "", "&a&oCharges held Items and Armor"); public static final SlimefunItemStack CLOTH = new SlimefunItemStack("CLOTH", Material.PAPER, "&bCloth"); public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&bReinforced Cloth", "", "&fThis cloth has been reinforced", "&fwith &bLead &fto protect against", "&fradioactive substances"); @@ -60,12 +63,12 @@ private SlimefunItems() {} public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&cRag", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE); public static final SlimefunItemStack BANDAGE = new SlimefunItemStack("BANDAGE", Material.PAPER, "&cBandage", "", "&aLevel II - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE); public static final SlimefunItemStack SPLINT = new SlimefunItemStack("SPLINT", Material.STICK, "&cSplint", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "", LoreBuilder.RIGHT_CLICK_TO_USE); - public static final SlimefunItemStack VITAMINS = new SlimefunItemStack("VITAMINS", Material.NETHER_WART, "&cVitamins", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation", "", LoreBuilder.RIGHT_CLICK_TO_USE); + public static final SlimefunItemStack VITAMINS = new SlimefunItemStack("VITAMINS", XMaterial.NETHER_WART.parseMaterial(), "&cVitamins", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation", "", LoreBuilder.RIGHT_CLICK_TO_USE); public static final SlimefunItemStack MEDICINE = new SlimefunItemStack("MEDICINE", Material.POTION, Color.RED, "&cMedicine", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation"); - public static final SlimefunItemStack MAGICAL_ZOMBIE_PILLS = new SlimefunItemStack("MAGICAL_ZOMBIE_PILLS", Material.NETHER_WART, "&6Magical Zombie Pills", "", "&eRight Click &7a Zombified Villager", "&eor &7a Zombified Piglin to", "&7instantly cure it from its curse"); + public static final SlimefunItemStack MAGICAL_ZOMBIE_PILLS = new SlimefunItemStack("MAGICAL_ZOMBIE_PILLS", XMaterial.NETHER_WART.parseMaterial(), "&6Magical Zombie Pills", "", "&eRight Click &7a Zombified Villager", "&eor &7a Zombified Piglin to", "&7instantly cure it from its curse"); public static final SlimefunItemStack FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FLASK_OF_KNOWLEDGE", Material.GLASS_BOTTLE, "&cFlask of Knowledge", "", "&fAllows you to store some of", "&fyour Experience in a Bottle", "&7Cost: &a1 Level"); - public static final SlimefunItemStack FILLED_FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FILLED_FLASK_OF_KNOWLEDGE", Material.EXPERIENCE_BOTTLE, "&aFlask of Knowledge"); + public static final SlimefunItemStack FILLED_FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FILLED_FLASK_OF_KNOWLEDGE", XMaterial.EXPERIENCE_BOTTLE.parseMaterial(), "&aFlask of Knowledge"); /* Backpacks */ private static final String BACKPACK_ID = "&7ID: "; @@ -111,31 +114,31 @@ private SlimefunItems() {} static { ItemMeta duralumin = DURALUMIN_MULTI_TOOL.getItemMeta(); - duralumin.setUnbreakable(true); + ItemMetaCompat.setUnbreakable(duralumin, true); DURALUMIN_MULTI_TOOL.setItemMeta(duralumin); ItemMeta solder = SOLDER_MULTI_TOOL.getItemMeta(); - solder.setUnbreakable(true); + ItemMetaCompat.setUnbreakable(solder, true); SOLDER_MULTI_TOOL.setItemMeta(solder); ItemMeta billon = BILLON_MULTI_TOOL.getItemMeta(); - billon.setUnbreakable(true); + ItemMetaCompat.setUnbreakable(billon, true); BILLON_MULTI_TOOL.setItemMeta(billon); ItemMeta steel = STEEL_MULTI_TOOL.getItemMeta(); - steel.setUnbreakable(true); + ItemMetaCompat.setUnbreakable(steel, true); STEEL_MULTI_TOOL.setItemMeta(steel); ItemMeta damascus = DAMASCUS_STEEL_MULTI_TOOL.getItemMeta(); - damascus.setUnbreakable(true); + ItemMetaCompat.setUnbreakable(damascus, true); DAMASCUS_STEEL_MULTI_TOOL.setItemMeta(damascus); ItemMeta reinforced = REINFORCED_ALLOY_MULTI_TOOL.getItemMeta(); - reinforced.setUnbreakable(true); + ItemMetaCompat.setUnbreakable(reinforced, true); REINFORCED_ALLOY_MULTI_TOOL.setItemMeta(reinforced); ItemMeta carbonado = CARBONADO_MULTI_TOOL.getItemMeta(); - carbonado.setUnbreakable(true); + ItemMetaCompat.setUnbreakable(carbonado, true); CARBONADO_MULTI_TOOL.setItemMeta(carbonado); } @@ -153,11 +156,11 @@ private SlimefunItems() {} public static final SlimefunItemStack GOLDEN_APPLE_JUICE = new SlimefunItemStack("GOLDEN_APPLE_JUICE", Color.YELLOW, new PotionEffect(PotionEffectType.ABSORPTION, 20 * 20, 0), "&bGolden Apple Juice"); public static final SlimefunItemStack BEEF_JERKY = new SlimefunItemStack("BEEF_JERKY", Material.COOKED_BEEF, "&6Beef Jerky", "", "&fExtra saturating!"); - public static final SlimefunItemStack PORK_JERKY = new SlimefunItemStack("PORK_JERKY", Material.COOKED_PORKCHOP, "&6Pork Jerky", "", "&fExtra saturating!"); + public static final SlimefunItemStack PORK_JERKY = new SlimefunItemStack("PORK_JERKY", XMaterial.COOKED_PORKCHOP.parseMaterial(), "&6Pork Jerky", "", "&fExtra saturating!"); public static final SlimefunItemStack CHICKEN_JERKY = new SlimefunItemStack("CHICKEN_JERKY", Material.COOKED_CHICKEN, "&6Chicken Jerky", "", "&fExtra saturating!"); public static final SlimefunItemStack MUTTON_JERKY = new SlimefunItemStack("MUTTON_JERKY", Material.COOKED_MUTTON, "&6Mutton Jerky", "", "&fExtra saturating!"); public static final SlimefunItemStack RABBIT_JERKY = new SlimefunItemStack("RABBIT_JERKY", Material.COOKED_RABBIT, "&6Rabbit Jerky", "", "&fExtra saturating!"); - public static final SlimefunItemStack FISH_JERKY = new SlimefunItemStack("FISH_JERKY", Material.COOKED_COD, "&6Fish Jerky", "", "&fExtra saturating!"); + public static final SlimefunItemStack FISH_JERKY = new SlimefunItemStack("FISH_JERKY", XMaterial.COOKED_COD.parseMaterial(), "&6Fish Jerky", "", "&fExtra saturating!"); public static final SlimefunItemStack KELP_COOKIE = new SlimefunItemStack("KELP_COOKIE", Material.COOKIE, "&2Kelp Cookie"); @@ -185,7 +188,7 @@ private SlimefunItems() {} public static final SlimefunItemStack GRANDMAS_WALKING_STICK = new SlimefunItemStack("GRANDMAS_WALKING_STICK", Material.STICK, "&7Grandmas Walking Stick"); public static final SlimefunItemStack GRANDPAS_WALKING_STICK = new SlimefunItemStack("GRANDPAS_WALKING_STICK", Material.STICK, "&7Grandpas Walking Stick"); public static final SlimefunItemStack SWORD_OF_BEHEADING = new SlimefunItemStack("SWORD_OF_BEHEADING", Material.IRON_SWORD, "&6Sword of Beheading", "&7Beheading II", "", "&fHas a chance to behead Mobs", "&f(even a higher chance for Wither Skeletons)"); - public static final SlimefunItemStack BLADE_OF_VAMPIRES = new SlimefunItemStack("BLADE_OF_VAMPIRES", Material.GOLDEN_SWORD, "&cBlade of Vampires", "&7Life Steal I", "", "&fEverytime you attack something", "&fyou have a 45% chance to", "&frecover 2 Hearts of your Health"); + public static final SlimefunItemStack BLADE_OF_VAMPIRES = new SlimefunItemStack("BLADE_OF_VAMPIRES", XMaterial.GOLDEN_SWORD.parseMaterial(), "&cBlade of Vampires", "&7Life Steal I", "", "&fEverytime you attack something", "&fyou have a 45% chance to", "&frecover 2 Hearts of your Health"); public static final SlimefunItemStack SEISMIC_AXE = new SlimefunItemStack("SEISMIC_AXE", Material.IRON_AXE, "&aSeismic Axe", "", "&7&oA portable Earthquake...", "", LoreBuilder.RIGHT_CLICK_TO_USE); static { @@ -206,7 +209,7 @@ private SlimefunItems() {} public static final SlimefunItemStack LUMBER_AXE = new SlimefunItemStack("LUMBER_AXE", Material.DIAMOND_AXE, "&6Lumber Axe", "&a&oCuts down the whole Tree..."); public static final SlimefunItemStack PICKAXE_OF_CONTAINMENT = new SlimefunItemStack("PICKAXE_OF_CONTAINMENT", Material.IRON_PICKAXE, "&cPickaxe of Containment", "", "&9Can pickup Spawners"); public static final SlimefunItemStack EXPLOSIVE_PICKAXE = new SlimefunItemStack("EXPLOSIVE_PICKAXE", Material.DIAMOND_PICKAXE, "&eExplosive Pickaxe", "", "&fAllows you to mine a good bit", "&fof Blocks at once...", "", "&9Works with Fortune"); - public static final SlimefunItemStack EXPLOSIVE_SHOVEL = new SlimefunItemStack("EXPLOSIVE_SHOVEL", Material.DIAMOND_SHOVEL, "&eExplosive Shovel", "", "&fAllows you to mine a good bit", "&fof diggable Blocks at once..."); + public static final SlimefunItemStack EXPLOSIVE_SHOVEL = new SlimefunItemStack("EXPLOSIVE_SHOVEL", XMaterial.DIAMOND_SHOVEL.parseMaterial(), "&eExplosive Shovel", "", "&fAllows you to mine a good bit", "&fof diggable Blocks at once..."); public static final SlimefunItemStack PICKAXE_OF_THE_SEEKER = new SlimefunItemStack("PICKAXE_OF_THE_SEEKER", Material.DIAMOND_PICKAXE, "&aPickaxe of the Seeker", "&fWill always point you to the nearest Ore", "&fbut might get damaged when doing it", "", "&7&eRight Click&7 to be pointed to the nearest Ore"); public static final SlimefunItemStack COBALT_PICKAXE = new SlimefunItemStack("COBALT_PICKAXE", Material.IRON_PICKAXE, "&9Cobalt Pickaxe"); public static final SlimefunItemStack PICKAXE_OF_VEIN_MINING = new SlimefunItemStack("PICKAXE_OF_VEIN_MINING", Material.DIAMOND_PICKAXE, "&ePickaxe of Vein Mining", "", "&fThis Pickaxe will dig out", "&fwhole Veins of Ores..."); @@ -280,15 +283,15 @@ private SlimefunItems() {} HAZMAT_CHESTPLATE.setItemMeta(chestplateMeta); } - public static final SlimefunItemStack GILDED_IRON_HELMET = new SlimefunItemStack("GILDED_IRON_HELMET", Material.GOLDEN_HELMET, "&6Gilded Iron Helmet"); - public static final SlimefunItemStack GILDED_IRON_CHESTPLATE = new SlimefunItemStack("GILDED_IRON_CHESTPLATE", Material.GOLDEN_CHESTPLATE, "&6Gilded Iron Chestplate"); - public static final SlimefunItemStack GILDED_IRON_LEGGINGS = new SlimefunItemStack("GILDED_IRON_LEGGINGS", Material.GOLDEN_LEGGINGS, "&6Gilded Iron Leggings"); - public static final SlimefunItemStack GILDED_IRON_BOOTS = new SlimefunItemStack("GILDED_IRON_BOOTS", Material.GOLDEN_BOOTS, "&6Gilded Iron Boots"); + public static final SlimefunItemStack GILDED_IRON_HELMET = new SlimefunItemStack("GILDED_IRON_HELMET", XMaterial.GOLDEN_HELMET.parseMaterial(), "&6Gilded Iron Helmet"); + public static final SlimefunItemStack GILDED_IRON_CHESTPLATE = new SlimefunItemStack("GILDED_IRON_CHESTPLATE", XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&6Gilded Iron Chestplate"); + public static final SlimefunItemStack GILDED_IRON_LEGGINGS = new SlimefunItemStack("GILDED_IRON_LEGGINGS", XMaterial.GOLDEN_LEGGINGS.parseMaterial(), "&6Gilded Iron Leggings"); + public static final SlimefunItemStack GILDED_IRON_BOOTS = new SlimefunItemStack("GILDED_IRON_BOOTS", XMaterial.GOLDEN_BOOTS.parseMaterial(), "&6Gilded Iron Boots"); - public static final SlimefunItemStack GOLDEN_HELMET_12K = new SlimefunItemStack("GOLD_12K_HELMET", Material.GOLDEN_HELMET, "&6Golden Helmet &7(12-Carat)"); - public static final SlimefunItemStack GOLDEN_CHESTPLATE_12K = new SlimefunItemStack("GOLD_12K_CHESTPLATE", Material.GOLDEN_CHESTPLATE, "&6Golden Chestplate &7(12-Carat)"); - public static final SlimefunItemStack GOLDEN_LEGGINGS_12K = new SlimefunItemStack("GOLD_12K_LEGGINGS", Material.GOLDEN_LEGGINGS, "&6Golden Leggings &7(12-Carat)"); - public static final SlimefunItemStack GOLDEN_BOOTS_12K = new SlimefunItemStack("GOLD_12K_BOOTS", Material.GOLDEN_BOOTS, "&6Golden Boots &7(12-Carat)"); + public static final SlimefunItemStack GOLDEN_HELMET_12K = new SlimefunItemStack("GOLD_12K_HELMET", XMaterial.GOLDEN_HELMET.parseMaterial(), "&6Golden Helmet &7(12-Carat)"); + public static final SlimefunItemStack GOLDEN_CHESTPLATE_12K = new SlimefunItemStack("GOLD_12K_CHESTPLATE", XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&6Golden Chestplate &7(12-Carat)"); + public static final SlimefunItemStack GOLDEN_LEGGINGS_12K = new SlimefunItemStack("GOLD_12K_LEGGINGS", XMaterial.GOLDEN_LEGGINGS.parseMaterial(), "&6Golden Leggings &7(12-Carat)"); + public static final SlimefunItemStack GOLDEN_BOOTS_12K = new SlimefunItemStack("GOLD_12K_BOOTS", XMaterial.GOLDEN_BOOTS.parseMaterial(), "&6Golden Boots &7(12-Carat)"); public static final SlimefunItemStack SLIME_HELMET_STEEL = new SlimefunItemStack("SLIME_STEEL_HELMET", Material.IRON_HELMET, "&a&lSlime Helmet", "&7&oReinforced", "", "&a&oBouncy Feeling"); public static final SlimefunItemStack SLIME_CHESTPLATE_STEEL = new SlimefunItemStack("SLIME_STEEL_CHESTPLATE", Material.IRON_CHESTPLATE, "&a&lSlime Chestplate", "&7&oReinforced", "", "&a&oBouncy Feeling"); @@ -297,10 +300,10 @@ private SlimefunItems() {} public static final SlimefunItemStack BOOTS_OF_THE_STOMPER = new SlimefunItemStack("BOOTS_OF_THE_STOMPER", Material.LEATHER_BOOTS, Color.AQUA, "&bBoots of the Stomper", "", "&9All Fall Damage you receive", "&9will be applied to nearby Mobs/Players", "", "&9+ No Fall Damage"); - public static final SlimefunItemStack BEE_HELMET = new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&lBee Helmet", " ", "&fBzzzzzzz"); - public static final SlimefunItemStack BEE_WINGS = new SlimefunItemStack("BEE_WINGS", Material.ELYTRA, "&e&lBee Wings", " ", "&fBzzzzzzz", " ", "&9Activates Slow falling", "&9when approaching the ground"); - public static final SlimefunItemStack BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&lBee Leggings", " ", "&fBzzzzzzz"); - public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&lBee Boots", "", "&fBzzzzzzz", "", "&9+ Jump Boost", "&9+ No Fall Damage"); + public static final SlimefunItemStack BEE_HELMET = new SlimefunItemStack("BEE_HELMET", XMaterial.GOLDEN_HELMET.parseMaterial(), "&e&lBee Helmet", " ", "&fBzzzzzzz"); + public static final SlimefunItemStack BEE_WINGS = new SlimefunItemStack("BEE_WINGS", XMaterial.ELYTRA.parseMaterial(), "&e&lBee Wings", " ", "&fBzzzzzzz", " ", "&9Activates Slow falling", "&9when approaching the ground"); + public static final SlimefunItemStack BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", XMaterial.GOLDEN_LEGGINGS.parseMaterial(), "&e&lBee Leggings", " ", "&fBzzzzzzz"); + public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", XMaterial.GOLDEN_BOOTS.parseMaterial(), "&e&lBee Boots", "", "&fBzzzzzzz", "", "&9+ Jump Boost", "&9+ No Fall Damage"); static { Map cactusEnchs = new HashMap<>(); @@ -371,8 +374,8 @@ private SlimefunItems() {} public static final SlimefunItemStack ENDER_LUMP_2 = new SlimefunItemStack("ENDER_LUMP_2", Material.GOLD_NUGGET, "&5Ender Lump &7- &eII", "", "&c&oTier: II"); public static final SlimefunItemStack ENDER_LUMP_3 = new SlimefunItemStack("ENDER_LUMP_3", Material.GOLD_NUGGET, "&5Ender Lump &7- &eIII", "", "&c&oTier: III"); public static final SlimefunItemStack MAGICAL_BOOK_COVER = new SlimefunItemStack("MAGICAL_BOOK_COVER", Material.PAPER, "&6Magical Book Cover", "", "&a&oUsed for various Magic Books"); - public static final SlimefunItemStack MAGICAL_GLASS = new SlimefunItemStack("MAGICAL_GLASS", Material.GLASS_PANE, "&6Magical Glass", "", "&a&oUsed for various Magical Gadgets"); - public static final SlimefunItemStack SYNTHETIC_SHULKER_SHELL = new SlimefunItemStack("SYNTHETIC_SHULKER_SHELL", Material.SHULKER_SHELL, "&dSynthetic Shulker Shell", "", "&fThis item can be used in a", "&fworkbench like a normal Shulker Shell"); + public static final SlimefunItemStack MAGICAL_GLASS = new SlimefunItemStack("MAGICAL_GLASS", XMaterial.GLASS_PANE.parseMaterial(), "&6Magical Glass", "", "&a&oUsed for various Magical Gadgets"); + public static final SlimefunItemStack SYNTHETIC_SHULKER_SHELL = new SlimefunItemStack("SYNTHETIC_SHULKER_SHELL", XMaterial.SHULKER_SHELL.parseMaterial(), "&dSynthetic Shulker Shell", "", "&fThis item can be used in a", "&fworkbench like a normal Shulker Shell"); /* Technical components */ public static final SlimefunItemStack BASIC_CIRCUIT_BOARD = new SlimefunItemStack("BASIC_CIRCUIT_BOARD", Material.ACTIVATOR_RAIL, "&bBasic Circuit Board"); @@ -387,17 +390,17 @@ private SlimefunItems() {} public static final SlimefunItemStack POWER_CRYSTAL = new SlimefunItemStack("POWER_CRYSTAL", HeadTexture.POWER_CRYSTAL, "&c&lPower Crystal"); public static final SlimefunItemStack CHAIN = new SlimefunItemStack("CHAIN", Material.STRING, "&bChain"); public static final SlimefunItemStack HOOK = new SlimefunItemStack("HOOK", Material.FLINT, "&bHook"); - public static final SlimefunItemStack SIFTED_ORE = new SlimefunItemStack("SIFTED_ORE", Material.GUNPOWDER, "&6Sifted Ore"); + public static final SlimefunItemStack SIFTED_ORE = new SlimefunItemStack("SIFTED_ORE", XMaterial.GUNPOWDER.parseMaterial(), "&6Sifted Ore"); public static final SlimefunItemStack STONE_CHUNK = new SlimefunItemStack("STONE_CHUNK", HeadTexture.STONE_CHUNK, "&6Stone Chunk"); public static final SlimefunItemStack LAVA_CRYSTAL = new SlimefunItemStack("LAVA_CRYSTAL", HeadTexture.LAVA_CRYSTAL, "&4Lava Crystal"); public static final SlimefunItemStack SALT = new SlimefunItemStack("SALT", Material.SUGAR, "&fSalt"); public static final SlimefunItemStack CHEESE = new SlimefunItemStack("CHEESE", HeadTexture.CHEESE, "&fCheese"); public static final SlimefunItemStack BUTTER = new SlimefunItemStack("BUTTER", HeadTexture.BUTTER, "&fButter"); public static final SlimefunItemStack DUCT_TAPE = new SlimefunItemStack("DUCT_TAPE", HeadTexture.DUCT_TAPE, "&8Duct Tape", "", "&fYou can repair Items using this", "&fin an Auto-Anvil"); - public static final SlimefunItemStack HEAVY_CREAM = new SlimefunItemStack("HEAVY_CREAM", Material.SNOWBALL, "&fHeavy Cream"); - public static final SlimefunItemStack CRUSHED_ORE = new SlimefunItemStack("CRUSHED_ORE", Material.GUNPOWDER, "&6Crushed Ore"); - public static final SlimefunItemStack PULVERIZED_ORE = new SlimefunItemStack("PULVERIZED_ORE", Material.GUNPOWDER, "&6Pulverized Ore"); - public static final SlimefunItemStack PURE_ORE_CLUSTER = new SlimefunItemStack("PURE_ORE_CLUSTER", Material.GUNPOWDER, "&6Pure Ore Cluster"); + public static final SlimefunItemStack HEAVY_CREAM = new SlimefunItemStack("HEAVY_CREAM", XMaterial.SNOWBALL.parseMaterial(), "&fHeavy Cream"); + public static final SlimefunItemStack CRUSHED_ORE = new SlimefunItemStack("CRUSHED_ORE", XMaterial.GUNPOWDER.parseMaterial(), "&6Crushed Ore"); + public static final SlimefunItemStack PULVERIZED_ORE = new SlimefunItemStack("PULVERIZED_ORE", XMaterial.GUNPOWDER.parseMaterial(), "&6Pulverized Ore"); + public static final SlimefunItemStack PURE_ORE_CLUSTER = new SlimefunItemStack("PURE_ORE_CLUSTER", XMaterial.GUNPOWDER.parseMaterial(), "&6Pure Ore Cluster"); public static final SlimefunItemStack SMALL_URANIUM = new SlimefunItemStack("SMALL_URANIUM", HeadTexture.URANIUM, "&cSmall Chunk of Uranium", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED); public static final SlimefunItemStack TINY_URANIUM = new SlimefunItemStack("TINY_URANIUM", HeadTexture.URANIUM, "&cTiny Pile of Uranium", "", LoreBuilder.radioactive(Radioactivity.LOW)); public static final SlimefunItemStack SOLAR_PANEL = new SlimefunItemStack("SOLAR_PANEL", Material.DAYLIGHT_DETECTOR, "&9Photovoltaic Cell", "", "&7Important component for", "&7crafting a &bSolar Generator"); @@ -405,8 +408,8 @@ private SlimefunItems() {} public static final SlimefunItemStack MAGNET = new SlimefunItemStack("MAGNET", HeadTexture.MAGNET, "&cMagnet"); public static final SlimefunItemStack NECROTIC_SKULL = new SlimefunItemStack("NECROTIC_SKULL", HeadTexture.NECROTIC_SKULL, "&cNecrotic Skull"); - public static final SlimefunItemStack ESSENCE_OF_AFTERLIFE = new SlimefunItemStack("ESSENCE_OF_AFTERLIFE", Material.GUNPOWDER, "&4Essence of Afterlife"); - public static final SlimefunItemStack STRANGE_NETHER_GOO = new SlimefunItemStack("STRANGE_NETHER_GOO", Material.PURPLE_DYE, "&5Strange Nether Goo", "", "&fA strange bio matter that", "&fcan be acquired from", "&fbartering with Piglins"); + public static final SlimefunItemStack ESSENCE_OF_AFTERLIFE = new SlimefunItemStack("ESSENCE_OF_AFTERLIFE", XMaterial.GUNPOWDER.parseMaterial(), "&4Essence of Afterlife"); + public static final SlimefunItemStack STRANGE_NETHER_GOO = new SlimefunItemStack("STRANGE_NETHER_GOO", XMaterial.PURPLE_DYE.parseMaterial(), "&5Strange Nether Goo", "", "&fA strange bio matter that", "&fcan be acquired from", "&fbartering with Piglins"); public static final SlimefunItemStack ELECTRO_MAGNET = new SlimefunItemStack("ELECTRO_MAGNET", HeadTexture.MAGNET, "&cElectromagnet"); public static final SlimefunItemStack HEATING_COIL = new SlimefunItemStack("HEATING_COIL", HeadTexture.HEATING_COIL, "&cHeating Coil"); public static final SlimefunItemStack COOLING_UNIT = new SlimefunItemStack("COOLING_UNIT", HeadTexture.COOLING_UNIT, "&bCooling Unit"); @@ -414,46 +417,46 @@ private SlimefunItems() {} public static final SlimefunItemStack CARGO_MOTOR = new SlimefunItemStack("CARGO_MOTOR", HeadTexture.CARGO_MOTOR, "&3Cargo Motor", "", "&7Important ingredient for items", "&7related to Cargo Management"); public static final SlimefunItemStack SCROLL_OF_DIMENSIONAL_TELEPOSITION = new SlimefunItemStack("SCROLL_OF_DIMENSIONAL_TELEPOSITION", Material.PAPER, "&6Scroll of Dimensional Teleposition", "", "&cThis Scroll is capable of creating", "&ca temporary black Hole which pulls", "&cnearby Entities into itself and sends", "&cthem into another Dimension where", "&ceverything is turned around", "", "&fIn other words: Makes Entities turn by 180 Degrees"); public static final SlimefunItemStack TOME_OF_KNOWLEDGE_SHARING = new SlimefunItemStack("TOME_OF_KNOWLEDGE_SHARING", Material.ENCHANTED_BOOK, "&6Tome of Knowledge Sharing", "&7Owner: &bNone", "", "&eRight Click&7 to bind this Tome to yourself", "", "", "&eRight Click&7 to obtain all Researches by", "&7the previously assigned Owner"); - public static final SlimefunItemStack HARDENED_GLASS = new SlimefunItemStack("HARDENED_GLASS", Material.LIGHT_GRAY_STAINED_GLASS, "&7Hardened Glass", "", "&fWithstands Explosions"); + public static final SlimefunItemStack HARDENED_GLASS = new SlimefunItemStack("HARDENED_GLASS", XMaterial.LIGHT_GRAY_STAINED_GLASS.parseMaterial(), "&7Hardened Glass", "", "&fWithstands Explosions"); public static final SlimefunItemStack WITHER_PROOF_OBSIDIAN = new SlimefunItemStack("WITHER_PROOF_OBSIDIAN", Material.OBSIDIAN, "&5Wither-Proof Obsidian", "", "&fWithstands Explosions", "&fWithstands Wither Bosses"); - public static final SlimefunItemStack WITHER_PROOF_GLASS = new SlimefunItemStack("WITHER_PROOF_GLASS", Material.PURPLE_STAINED_GLASS, "&5Wither-Proof Glass", "", "&fWithstands Explosions", "&fWithstands Wither Bosses"); + public static final SlimefunItemStack WITHER_PROOF_GLASS = new SlimefunItemStack("WITHER_PROOF_GLASS", XMaterial.PURPLE_STAINED_GLASS.parseMaterial(), "&5Wither-Proof Glass", "", "&fWithstands Explosions", "&fWithstands Wither Bosses"); public static final SlimefunItemStack REINFORCED_PLATE = new SlimefunItemStack("REINFORCED_PLATE", Material.PAPER, "&7Reinforced Plate"); public static final SlimefunItemStack ANCIENT_PEDESTAL = new SlimefunItemStack("ANCIENT_PEDESTAL", Material.DISPENSER, "&dAncient Pedestal", "", "&5Part of the Ancient Altar"); - public static final SlimefunItemStack ANCIENT_ALTAR = new SlimefunItemStack("ANCIENT_ALTAR", Material.ENCHANTING_TABLE, "&dAncient Altar", "", "&5Multi-Block Altar for", "&5magical Crafting Processes"); + public static final SlimefunItemStack ANCIENT_ALTAR = new SlimefunItemStack("ANCIENT_ALTAR", XMaterial.ENCHANTING_TABLE.parseMaterial(), "&dAncient Altar", "", "&5Multi-Block Altar for", "&5magical Crafting Processes"); public static final SlimefunItemStack COPPER_WIRE = new SlimefunItemStack("COPPER_WIRE", Material.STRING, "&6Copper Wire", "", "&6Crucial component in electric modules"); public static final SlimefunItemStack CRAFTING_MOTOR = new SlimefunItemStack("CRAFTING_MOTOR", HeadTexture.CRAFTING_MOTOR, "&6Crafting Motor", "", "&7Important component of Auto-Crafters"); /* Rainbow blocks */ - public static final SlimefunItemStack RAINBOW_WOOL = new SlimefunItemStack("RAINBOW_WOOL", Material.WHITE_WOOL, "&5Rainbow Wool", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_GLASS = new SlimefunItemStack("RAINBOW_GLASS", Material.WHITE_STAINED_GLASS, "&5Rainbow Glass", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_CLAY = new SlimefunItemStack("RAINBOW_CLAY", Material.WHITE_TERRACOTTA, "&5Rainbow Clay", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_GLASS_PANE = new SlimefunItemStack("RAINBOW_GLASS_PANE", Material.WHITE_STAINED_GLASS_PANE, "&5Rainbow Glass Pane", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_CONCRETE = new SlimefunItemStack("RAINBOW_CONCRETE", Material.WHITE_CONCRETE, "&5Rainbow Concrete", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA", Material.WHITE_GLAZED_TERRACOTTA, "&5Rainbow Glazed Terracotta", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_WOOL = new SlimefunItemStack("RAINBOW_WOOL", XMaterial.WHITE_WOOL.parseMaterial(), "&5Rainbow Wool", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_GLASS = new SlimefunItemStack("RAINBOW_GLASS", XMaterial.WHITE_STAINED_GLASS.parseMaterial(), "&5Rainbow Glass", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_CLAY = new SlimefunItemStack("RAINBOW_CLAY", XMaterial.WHITE_TERRACOTTA.parseMaterial(), "&5Rainbow Clay", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_GLASS_PANE = new SlimefunItemStack("RAINBOW_GLASS_PANE", XMaterial.WHITE_STAINED_GLASS_PANE.parseMaterial(), "&5Rainbow Glass Pane", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_CONCRETE = new SlimefunItemStack("RAINBOW_CONCRETE", XMaterial.WHITE_CONCRETE.parseMaterial(), "&5Rainbow Concrete", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA", XMaterial.WHITE_GLAZED_TERRACOTTA.parseMaterial(), "&5Rainbow Glazed Terracotta", "", LoreBuilder.RAINBOW); /* Seasonal */ private static final String CHRISTMAS = ChatUtils.christmas("[Christmas Edition]"); - public static final SlimefunItemStack RAINBOW_WOOL_XMAS = new SlimefunItemStack("RAINBOW_WOOL_XMAS", Material.WHITE_WOOL, "&5Rainbow Wool &7(Christmas)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_GLASS_XMAS = new SlimefunItemStack("RAINBOW_GLASS_XMAS", Material.WHITE_STAINED_GLASS, "&5Rainbow Glass &7(Christmas)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_CLAY_XMAS = new SlimefunItemStack("RAINBOW_CLAY_XMAS", Material.WHITE_TERRACOTTA, "&5Rainbow Clay &7(Christmas)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_GLASS_PANE_XMAS = new SlimefunItemStack("RAINBOW_GLASS_PANE_XMAS", Material.WHITE_STAINED_GLASS_PANE, "&5Rainbow Glass Pane &7(Christmas)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_CONCRETE_XMAS = new SlimefunItemStack("RAINBOW_CONCRETE_XMAS", Material.WHITE_CONCRETE, "&5Rainbow Concrete &7(Christmas)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_XMAS = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_XMAS", Material.WHITE_GLAZED_TERRACOTTA, "&5Rainbow Glazed Terracotta &7(Christmas)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_WOOL_XMAS = new SlimefunItemStack("RAINBOW_WOOL_XMAS", XMaterial.WHITE_WOOL.parseMaterial(), "&5Rainbow Wool &7(Christmas)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_GLASS_XMAS = new SlimefunItemStack("RAINBOW_GLASS_XMAS", XMaterial.WHITE_STAINED_GLASS.parseMaterial(), "&5Rainbow Glass &7(Christmas)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_CLAY_XMAS = new SlimefunItemStack("RAINBOW_CLAY_XMAS", XMaterial.WHITE_TERRACOTTA.parseMaterial(), "&5Rainbow Clay &7(Christmas)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_GLASS_PANE_XMAS = new SlimefunItemStack("RAINBOW_GLASS_PANE_XMAS", XMaterial.WHITE_STAINED_GLASS_PANE.parseMaterial(), "&5Rainbow Glass Pane &7(Christmas)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_CONCRETE_XMAS = new SlimefunItemStack("RAINBOW_CONCRETE_XMAS", XMaterial.WHITE_CONCRETE.parseMaterial(), "&5Rainbow Concrete &7(Christmas)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_XMAS = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_XMAS", XMaterial.WHITE_GLAZED_TERRACOTTA.parseMaterial(), "&5Rainbow Glazed Terracotta &7(Christmas)", "", CHRISTMAS); private static final String VALENTINES_DAY = "&5[&dValentine's Day Edition&5]"; - public static final SlimefunItemStack RAINBOW_WOOL_VALENTINE = new SlimefunItemStack("RAINBOW_WOOL_VALENTINE", Material.PINK_WOOL, "&5Rainbow Wool &7(Valentine's Day)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_GLASS_VALENTINE = new SlimefunItemStack("RAINBOW_GLASS_VALENTINE", Material.PINK_STAINED_GLASS, "&5Rainbow Glass &7(Valentine's Day)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_CLAY_VALENTINE = new SlimefunItemStack("RAINBOW_CLAY_VALENTINE", Material.PINK_TERRACOTTA, "&5Rainbow Clay &7(Valentine's Day)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_GLASS_PANE_VALENTINE = new SlimefunItemStack("RAINBOW_GLASS_PANE_VALENTINE", Material.PINK_STAINED_GLASS_PANE, "&5Rainbow Glass Pane &7(Valentine's Day)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_CONCRETE_VALENTINE = new SlimefunItemStack("RAINBOW_CONCRETE_VALENTINE", Material.PINK_CONCRETE, "&5Rainbow Concrete &7(Valentine's Day)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_VALENTINE = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_VALENTINE", Material.PINK_GLAZED_TERRACOTTA, "&5Rainbow Glazed Terracotta &7(Valentine's Day)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_WOOL_VALENTINE = new SlimefunItemStack("RAINBOW_WOOL_VALENTINE", XMaterial.PINK_WOOL.parseMaterial(), "&5Rainbow Wool &7(Valentine's Day)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_GLASS_VALENTINE = new SlimefunItemStack("RAINBOW_GLASS_VALENTINE", XMaterial.PINK_STAINED_GLASS.parseMaterial(), "&5Rainbow Glass &7(Valentine's Day)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_CLAY_VALENTINE = new SlimefunItemStack("RAINBOW_CLAY_VALENTINE", XMaterial.PINK_TERRACOTTA.parseMaterial(), "&5Rainbow Clay &7(Valentine's Day)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_GLASS_PANE_VALENTINE = new SlimefunItemStack("RAINBOW_GLASS_PANE_VALENTINE", XMaterial.PINK_STAINED_GLASS_PANE.parseMaterial(), "&5Rainbow Glass Pane &7(Valentine's Day)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_CONCRETE_VALENTINE = new SlimefunItemStack("RAINBOW_CONCRETE_VALENTINE", XMaterial.PINK_CONCRETE.parseMaterial(), "&5Rainbow Concrete &7(Valentine's Day)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_VALENTINE = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_VALENTINE", XMaterial.PINK_GLAZED_TERRACOTTA.parseMaterial(), "&5Rainbow Glazed Terracotta &7(Valentine's Day)", "", VALENTINES_DAY); private static final String HALLOWEEN = "&c[&6Halloween Edition&c]"; - public static final SlimefunItemStack RAINBOW_WOOL_HALLOWEEN = new SlimefunItemStack("RAINBOW_WOOL_HALLOWEEN", Material.ORANGE_WOOL, "&5Rainbow Wool &7(Halloween)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_GLASS_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLASS_HALLOWEEN", Material.ORANGE_STAINED_GLASS, "&5Rainbow Glass &7(Halloween)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_CLAY_HALLOWEEN = new SlimefunItemStack("RAINBOW_CLAY_HALLOWEEN", Material.ORANGE_TERRACOTTA, "&5Rainbow Clay &7(Halloween)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_GLASS_PANE_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLASS_PANE_HALLOWEEN", Material.ORANGE_STAINED_GLASS_PANE, "&5Rainbow Glass Pane &7(Halloween)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_CONCRETE_HALLOWEEN = new SlimefunItemStack("RAINBOW_CONCRETE_HALLOWEEN", Material.ORANGE_CONCRETE, "&5Rainbow Concrete &7(Halloween)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN", Material.ORANGE_GLAZED_TERRACOTTA, "&5Rainbow Glazed Terracotta &7(Halloween)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_WOOL_HALLOWEEN = new SlimefunItemStack("RAINBOW_WOOL_HALLOWEEN", XMaterial.ORANGE_WOOL.parseMaterial(), "&5Rainbow Wool &7(Halloween)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_GLASS_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLASS_HALLOWEEN", XMaterial.ORANGE_STAINED_GLASS.parseMaterial(), "&5Rainbow Glass &7(Halloween)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_CLAY_HALLOWEEN = new SlimefunItemStack("RAINBOW_CLAY_HALLOWEEN", XMaterial.ORANGE_TERRACOTTA.parseMaterial(), "&5Rainbow Clay &7(Halloween)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_GLASS_PANE_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLASS_PANE_HALLOWEEN", XMaterial.ORANGE_STAINED_GLASS_PANE.parseMaterial(), "&5Rainbow Glass Pane &7(Halloween)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_CONCRETE_HALLOWEEN = new SlimefunItemStack("RAINBOW_CONCRETE_HALLOWEEN", XMaterial.ORANGE_CONCRETE.parseMaterial(), "&5Rainbow Concrete &7(Halloween)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN", XMaterial.ORANGE_GLAZED_TERRACOTTA.parseMaterial(), "&5Rainbow Glazed Terracotta &7(Halloween)", "", HALLOWEEN); /* Ingots */ public static final SlimefunItemStack COPPER_INGOT = new SlimefunItemStack("COPPER_INGOT", Material.BRICK, "&bCopper Ingot"); @@ -513,18 +516,18 @@ private SlimefunItems() {} public static final SlimefunItemStack GOLD_24K = new SlimefunItemStack("GOLD_24K", Material.GOLD_INGOT, "&fGold Ingot &7(24-Carat)"); /* Dusts */ - public static final SlimefunItemStack IRON_DUST = new SlimefunItemStack("IRON_DUST", Material.GUNPOWDER, "&6Iron Dust"); + public static final SlimefunItemStack IRON_DUST = new SlimefunItemStack("IRON_DUST", XMaterial.GUNPOWDER.parseMaterial(), "&6Iron Dust"); public static final SlimefunItemStack GOLD_DUST = new SlimefunItemStack("GOLD_DUST", Material.GLOWSTONE_DUST, "&6Gold Dust"); public static final SlimefunItemStack TIN_DUST = new SlimefunItemStack("TIN_DUST", Material.SUGAR, "&6Tin Dust"); public static final SlimefunItemStack COPPER_DUST = new SlimefunItemStack("COPPER_DUST", Material.GLOWSTONE_DUST, "&6Copper Dust"); public static final SlimefunItemStack SILVER_DUST = new SlimefunItemStack("SILVER_DUST", Material.SUGAR, "&6Silver Dust"); public static final SlimefunItemStack ALUMINUM_DUST = new SlimefunItemStack("ALUMINUM_DUST", Material.SUGAR, "&6Aluminum Dust"); - public static final SlimefunItemStack LEAD_DUST = new SlimefunItemStack("LEAD_DUST", Material.GUNPOWDER, "&6Lead Dust"); + public static final SlimefunItemStack LEAD_DUST = new SlimefunItemStack("LEAD_DUST", XMaterial.GUNPOWDER.parseMaterial(), "&6Lead Dust"); public static final SlimefunItemStack ZINC_DUST = new SlimefunItemStack("ZINC_DUST", Material.SUGAR, "&6Zinc Dust"); public static final SlimefunItemStack MAGNESIUM_DUST = new SlimefunItemStack("MAGNESIUM_DUST", Material.SUGAR, "&6Magnesium"); public static final SlimefunItemStack SULFATE = new SlimefunItemStack("SULFATE", Material.GLOWSTONE_DUST, "&6Sulfate"); - public static final SlimefunItemStack SILICON = new SlimefunItemStack("SILICON", Material.FIREWORK_STAR, "&6Silicon"); + public static final SlimefunItemStack SILICON = new SlimefunItemStack("SILICON", XMaterial.FIREWORK_STAR.parseMaterial(), "&6Silicon"); public static final SlimefunItemStack GOLD_24K_BLOCK = new SlimefunItemStack("GOLD_24K_BLOCK", Material.GOLD_BLOCK, "&fGold Block &7(24-Carat)"); /* Gems */ @@ -575,30 +578,30 @@ private SlimefunItems() {} } /* Multiblocks */ - public static final SlimefunItemStack ENHANCED_CRAFTING_TABLE = new SlimefunItemStack("ENHANCED_CRAFTING_TABLE", Material.CRAFTING_TABLE, "&eEnhanced Crafting Table", "", "&aA regular Crafting Table cannot", "&ahold this massive Amount of Power..."); + public static final SlimefunItemStack ENHANCED_CRAFTING_TABLE = new SlimefunItemStack("ENHANCED_CRAFTING_TABLE", XMaterial.CRAFTING_TABLE.parseMaterial(), "&eEnhanced Crafting Table", "", "&aA regular Crafting Table cannot", "&ahold this massive Amount of Power..."); public static final SlimefunItemStack GRIND_STONE = new SlimefunItemStack("GRIND_STONE", Material.DISPENSER, "&bGrind Stone", "", "&aGrinds items down into other items"); public static final SlimefunItemStack ARMOR_FORGE = new SlimefunItemStack("ARMOR_FORGE", Material.ANVIL, "&6Armor Forge", "", "&aGives you the ability to create powerful armor"); - public static final SlimefunItemStack MAKESHIFT_SMELTERY = new SlimefunItemStack("MAKESHIFT_SMELTERY", Material.BLAST_FURNACE, "&eMakeshift Smeltery", "", "&fImprovised version of the Smeltery", "&fthat only allows you to", "&fsmelt dusts into ingots"); + public static final SlimefunItemStack MAKESHIFT_SMELTERY = new SlimefunItemStack("MAKESHIFT_SMELTERY", XMaterial.BLAST_FURNACE.parseMaterial(), "&eMakeshift Smeltery", "", "&fImprovised version of the Smeltery", "&fthat only allows you to", "&fsmelt dusts into ingots"); public static final SlimefunItemStack SMELTERY = new SlimefunItemStack("SMELTERY", Material.FURNACE, "&6Smeltery", "", "&fA high-temperature furnace", "&fthat allows you to smelt dusts", "&finto ingots and create alloys."); public static final SlimefunItemStack ORE_CRUSHER = new SlimefunItemStack("ORE_CRUSHER", Material.DISPENSER, "&bOre Crusher", "", "&aCrushes ores to double them"); - public static final SlimefunItemStack COMPRESSOR = new SlimefunItemStack("COMPRESSOR", Material.PISTON, "&bCompressor", "", "&aCompresses Items"); + public static final SlimefunItemStack COMPRESSOR = new SlimefunItemStack("COMPRESSOR", XMaterial.PISTON.parseMaterial(), "&bCompressor", "", "&aCompresses Items"); public static final SlimefunItemStack PRESSURE_CHAMBER = new SlimefunItemStack("PRESSURE_CHAMBER", Material.GLASS, "&bPressure Chamber", "", "&aCompresses Items even further"); - public static final SlimefunItemStack MAGIC_WORKBENCH = new SlimefunItemStack("MAGIC_WORKBENCH", Material.CRAFTING_TABLE, "&6Magic Workbench", "", "&dInfuses Items with magical Energy"); + public static final SlimefunItemStack MAGIC_WORKBENCH = new SlimefunItemStack("MAGIC_WORKBENCH", XMaterial.CRAFTING_TABLE.parseMaterial(), "&6Magic Workbench", "", "&dInfuses Items with magical Energy"); public static final SlimefunItemStack ORE_WASHER = new SlimefunItemStack("ORE_WASHER", Material.CAULDRON, "&6Ore Washer", "", "&aWashes Sifted Ore to filter Ores", "&aand gives you small Stone Chunks"); - public static final SlimefunItemStack TABLE_SAW = new SlimefunItemStack("TABLE_SAW", Material.STONECUTTER, "&6Table Saw", "", "&aAllows you to get 8 planks from 1 Log", "&a(Works with all log types)"); + public static final SlimefunItemStack TABLE_SAW = new SlimefunItemStack("TABLE_SAW", XMaterial.STONECUTTER.parseMaterial(), "&6Table Saw", "", "&aAllows you to get 8 planks from 1 Log", "&a(Works with all log types)"); public static final SlimefunItemStack JUICER = new SlimefunItemStack("JUICER", Material.GLASS_BOTTLE, "&aJuicer", "", "&aAllows you to create delicious Juice"); public static final SlimefunItemStack AUTOMATED_PANNING_MACHINE = new SlimefunItemStack("AUTOMATED_PANNING_MACHINE", Material.BOWL, "&eAutomated Panning Machine", "", "&fA MultiBlock Version of the Gold Pan", "&fand Nether Gold Pan combined in one machine."); - public static final SlimefunItemStack INDUSTRIAL_MINER = new SlimefunItemStack("INDUSTRIAL_MINER", Material.GOLDEN_PICKAXE, "&bIndustrial Miner", "", "&fThis Multiblock will mine any Ores", "&fin a 7x7 area underneath it.", "&fPlace coal or similar in its chest", "&fto fuel this machine."); + public static final SlimefunItemStack INDUSTRIAL_MINER = new SlimefunItemStack("INDUSTRIAL_MINER", XMaterial.GOLDEN_PICKAXE.parseMaterial(), "&bIndustrial Miner", "", "&fThis Multiblock will mine any Ores", "&fin a 7x7 area underneath it.", "&fPlace coal or similar in its chest", "&fto fuel this machine."); public static final SlimefunItemStack ADVANCED_INDUSTRIAL_MINER = new SlimefunItemStack("ADVANCED_INDUSTRIAL_MINER", Material.DIAMOND_PICKAXE, "&cAdvanced Industrial Miner", "", "&fThis Multiblock will mine any Ores", "&fin a 11x11 area underneath it.", "&fPlace a bucket of fuel or lava in", "&fits chest to fuel this machine.", "", "&a+ Silk Touch"); static { ItemMeta meta = INDUSTRIAL_MINER.getItemMeta(); - meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + VersionedItemFlag.addFlags(meta, VersionedItemFlag.HIDE_ATTRIBUTES); INDUSTRIAL_MINER.setItemMeta(meta); ItemMeta meta2 = ADVANCED_INDUSTRIAL_MINER.getItemMeta(); - meta2.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + VersionedItemFlag.addFlags(meta2, VersionedItemFlag.HIDE_ATTRIBUTES); ADVANCED_INDUSTRIAL_MINER.setItemMeta(meta2); } @@ -607,7 +610,7 @@ private SlimefunItems() {} public static final SlimefunItemStack CRUCIBLE = new SlimefunItemStack("CRUCIBLE", Material.CAULDRON, "&cCrucible", "", "&a&oUsed to smelt Items into Liquids"); public static final SlimefunItemStack OUTPUT_CHEST = new SlimefunItemStack("OUTPUT_CHEST", Material.CHEST, "&4Output Chest", "", "&c&oA basic machine will try to put", "&c&oitems in this chest if it's placed", "&c&oadjacent to the dispenser."); public static final SlimefunItemStack IGNITION_CHAMBER = new SlimefunItemStack("IGNITION_CHAMBER", Material.DROPPER, "&4Automatic Ignition Chamber", "", "&fPrevents the Smeltery from using up fire.", "&fJust fill it up with \"Flint and Steel\"", "&fand place it adjacent to the Smeltery's dispenser"); - public static final SlimefunItemStack HOLOGRAM_PROJECTOR = new SlimefunItemStack("HOLOGRAM_PROJECTOR", Material.QUARTZ_SLAB, "&bHologram Projector", "", "&fProjects an Editable Hologram"); + public static final SlimefunItemStack HOLOGRAM_PROJECTOR = new SlimefunItemStack("HOLOGRAM_PROJECTOR", XMaterial.QUARTZ_SLAB.parseMaterial(), "&bHologram Projector", "", "&fProjects an Editable Hologram"); public static final SlimefunItemStack BLOCK_PLACER = new SlimefunItemStack("BLOCK_PLACER", Material.DISPENSER, "&aBlock Placer", "", "&fAll Blocks in this Dispenser", "&fwill automatically get placed"); /* Enhanced Furnaces */ @@ -630,9 +633,9 @@ private SlimefunItems() {} public static final SlimefunItemStack SOULBOUND_BOW = new SlimefunItemStack("SOULBOUND_BOW", Material.BOW, "&cSoulbound Bow"); public static final SlimefunItemStack SOULBOUND_PICKAXE = new SlimefunItemStack("SOULBOUND_PICKAXE", Material.DIAMOND_PICKAXE, "&cSoulbound Pickaxe"); public static final SlimefunItemStack SOULBOUND_AXE = new SlimefunItemStack("SOULBOUND_AXE", Material.DIAMOND_AXE, "&cSoulbound Axe"); - public static final SlimefunItemStack SOULBOUND_SHOVEL = new SlimefunItemStack("SOULBOUND_SHOVEL", Material.DIAMOND_SHOVEL, "&cSoulbound Shovel"); + public static final SlimefunItemStack SOULBOUND_SHOVEL = new SlimefunItemStack("SOULBOUND_SHOVEL", XMaterial.DIAMOND_SHOVEL.parseMaterial(), "&cSoulbound Shovel"); public static final SlimefunItemStack SOULBOUND_HOE = new SlimefunItemStack("SOULBOUND_HOE", Material.DIAMOND_HOE, "&cSoulbound Hoe"); - public static final SlimefunItemStack SOULBOUND_TRIDENT = new SlimefunItemStack("SOULBOUND_TRIDENT", Material.TRIDENT, "&cSoulbound Trident"); + public static final SlimefunItemStack SOULBOUND_TRIDENT = new SlimefunItemStack("SOULBOUND_TRIDENT", XMaterial.TRIDENT.parseMaterial(), "&cSoulbound Trident"); public static final SlimefunItemStack SOULBOUND_HELMET = new SlimefunItemStack("SOULBOUND_HELMET", Material.DIAMOND_HELMET, "&cSoulbound Helmet"); public static final SlimefunItemStack SOULBOUND_CHESTPLATE = new SlimefunItemStack("SOULBOUND_CHESTPLATE", Material.DIAMOND_CHESTPLATE, "&cSoulbound Chestplate"); @@ -674,19 +677,19 @@ private SlimefunItems() {} public static final SlimefunItemStack ELECTRIC_ORE_GRINDER_2 = new SlimefunItemStack("ELECTRIC_ORE_GRINDER_2", Material.FURNACE, "&cElectric Ore Grinder &7(&eII&7)", "", "&fWorks as an Ore Crusher and Grind Stone", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(4), LoreBuilder.powerPerSecond(30)); public static final SlimefunItemStack ELECTRIC_ORE_GRINDER_3 = new SlimefunItemStack("ELECTRIC_ORE_GRINDER_3", Material.FURNACE, "&cElectric Ore Grinder &7(&eIII&7)", "", "&fWorks as an Ore Crusher and Grind Stone", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(10), LoreBuilder.powerPerSecond(90)); public static final SlimefunItemStack ELECTRIC_INGOT_PULVERIZER = new SlimefunItemStack("ELECTRIC_INGOT_PULVERIZER", Material.FURNACE, "&cElectric Ingot Pulverizer", "", "&fPulverizes Ingots into Dust", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(14)); - public static final SlimefunItemStack AUTO_DRIER = new SlimefunItemStack("AUTO_DRIER", Material.SMOKER, "&6Auto Drier", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10)); - public static final SlimefunItemStack AUTO_ENCHANTER = new SlimefunItemStack("AUTO_ENCHANTER", Material.ENCHANTING_TABLE, "&5Auto Enchanter", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(18)); - public static final SlimefunItemStack AUTO_ENCHANTER_2 = new SlimefunItemStack("AUTO_ENCHANTER_2", Material.ENCHANTING_TABLE, "&5Auto Enchanter &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(48)); - public static final SlimefunItemStack AUTO_DISENCHANTER = new SlimefunItemStack("AUTO_DISENCHANTER", Material.ENCHANTING_TABLE, "&5Auto Disenchanter", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(18)); - public static final SlimefunItemStack AUTO_DISENCHANTER_2 = new SlimefunItemStack("AUTO_DISENCHANTER_2", Material.ENCHANTING_TABLE, "&5Auto Disenchanter &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(48)); + public static final SlimefunItemStack AUTO_DRIER = new SlimefunItemStack("AUTO_DRIER", XMaterial.SMOKER.parseMaterial(), "&6Auto Drier", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10)); + public static final SlimefunItemStack AUTO_ENCHANTER = new SlimefunItemStack("AUTO_ENCHANTER", XMaterial.ENCHANTING_TABLE.parseMaterial(), "&5Auto Enchanter", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(18)); + public static final SlimefunItemStack AUTO_ENCHANTER_2 = new SlimefunItemStack("AUTO_ENCHANTER_2", XMaterial.ENCHANTING_TABLE.parseMaterial(), "&5Auto Enchanter &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(48)); + public static final SlimefunItemStack AUTO_DISENCHANTER = new SlimefunItemStack("AUTO_DISENCHANTER", XMaterial.ENCHANTING_TABLE.parseMaterial(), "&5Auto Disenchanter", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(18)); + public static final SlimefunItemStack AUTO_DISENCHANTER_2 = new SlimefunItemStack("AUTO_DISENCHANTER_2", XMaterial.ENCHANTING_TABLE.parseMaterial(), "&5Auto Disenchanter &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(48)); public static final SlimefunItemStack AUTO_ANVIL = new SlimefunItemStack("AUTO_ANVIL", Material.IRON_BLOCK, "&7Auto Anvil", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &7Repair Factor: 10%", LoreBuilder.powerPerSecond(24)); public static final SlimefunItemStack AUTO_ANVIL_2 = new SlimefunItemStack("AUTO_ANVIL_2", Material.IRON_BLOCK, "&7Auto Anvil Mk.II", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Repair Factor: 25%", LoreBuilder.powerPerSecond(32)); - public static final SlimefunItemStack AUTO_BREWER = new SlimefunItemStack("AUTO_BREWER", Material.SMOKER, "&6Auto Brewer", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(12)); + public static final SlimefunItemStack AUTO_BREWER = new SlimefunItemStack("AUTO_BREWER", XMaterial.SMOKER.parseMaterial(), "&6Auto Brewer", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(12)); public static final SlimefunItemStack BOOK_BINDER = new SlimefunItemStack("BOOK_BINDER", Material.BOOKSHELF, "&6Book Binder", "", "&fBinds multiple enchanted books into one.", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.powerPerSecond(16)); - public static final SlimefunItemStack BIO_REACTOR = new SlimefunItemStack("BIO_REACTOR", Material.LIME_TERRACOTTA, "&2Bio Reactor", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(8)); - public static final SlimefunItemStack MULTIMETER = new SlimefunItemStack("MULTIMETER", Material.CLOCK, "&eMultimeter", "", "&fMeasures the Amount of stored", "&fEnergy in a Block"); + public static final SlimefunItemStack BIO_REACTOR = new SlimefunItemStack("BIO_REACTOR", XMaterial.LIME_TERRACOTTA.parseMaterial(), "&2Bio Reactor", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(8)); + public static final SlimefunItemStack MULTIMETER = new SlimefunItemStack("MULTIMETER", XMaterial.CLOCK.parseMaterial(), "&eMultimeter", "", "&fMeasures the Amount of stored", "&fEnergy in a Block"); public static final SlimefunItemStack SMALL_CAPACITOR = new SlimefunItemStack("SMALL_CAPACITOR", HeadTexture.CAPACITOR_25, "&aSmall Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.BASIC, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7128 J Capacity"); public static final SlimefunItemStack MEDIUM_CAPACITOR = new SlimefunItemStack("MEDIUM_CAPACITOR", HeadTexture.CAPACITOR_25, "&aMedium Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7512 J Capacity"); @@ -718,7 +721,7 @@ private SlimefunItems() {} public static final SlimefunItemStack GPS_TRANSMITTER_3 = new SlimefunItemStack("GPS_TRANSMITTER_3", HeadTexture.GPS_TRANSMITTER, "&4Carbonado GPS Transmitter", "", LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(22)); public static final SlimefunItemStack GPS_TRANSMITTER_4 = new SlimefunItemStack("GPS_TRANSMITTER_4", HeadTexture.GPS_TRANSMITTER, "&eEnergized GPS Transmitter", "", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(92)); - public static final SlimefunItemStack GPS_MARKER_TOOL = new SlimefunItemStack("GPS_MARKER_TOOL", Material.REDSTONE_TORCH, "&bGPS Marker Tool", "", "&fAllows you to set a Waypoint at", "&fthe Location you place this"); + public static final SlimefunItemStack GPS_MARKER_TOOL = new SlimefunItemStack("GPS_MARKER_TOOL", XMaterial.REDSTONE_TORCH.parseMaterial(), "&bGPS Marker Tool", "", "&fAllows you to set a Waypoint at", "&fthe Location you place this"); public static final SlimefunItemStack GPS_CONTROL_PANEL = new SlimefunItemStack("GPS_CONTROL_PANEL", HeadTexture.GPS_CONTROL_PANEL, "&bGPS Control Panel", "", "&fAllows you to track your Satellites", "&fand manage your Waypoints"); public static final SlimefunItemStack GPS_EMERGENCY_TRANSMITTER = new SlimefunItemStack("GPS_EMERGENCY_TRANSMITTER", HeadTexture.GPS_TRANSMITTER, "&cGPS Emergency Transmitter", "", "&fCarrying this in your Inventory", "&fautomatically sets a Waypoint", "&fat your Location when you die."); @@ -726,27 +729,27 @@ private SlimefunItems() {} public static final SlimefunItemStack ANDROID_INTERFACE_ITEMS = new SlimefunItemStack("ANDROID_INTERFACE_ITEMS", Material.DISPENSER, "&7Android Interface &9(Items)", "", "&fItems stored in an Android's Inventory", "&fwill be inserted into this Interface", "&fwhen its Script tells them to do so"); public static final SlimefunItemStack GPS_GEO_SCANNER = new SlimefunItemStack("GPS_GEO_SCANNER", HeadTexture.GEO_SCANNER, "&bGPS Geo-Scanner", "", "&fScans a Chunk for natural Resources", "&fsuch as &8Oil"); - public static final SlimefunItemStack PORTABLE_GEO_SCANNER = new SlimefunItemStack("PORTABLE_GEO_SCANNER", Material.CLOCK, "&bPortable Geo-Scanner", "", "&fScans a Chunk for natural Resources", "", "&eRight Click&7 to scan"); + public static final SlimefunItemStack PORTABLE_GEO_SCANNER = new SlimefunItemStack("PORTABLE_GEO_SCANNER", XMaterial.CLOCK.parseMaterial(), "&bPortable Geo-Scanner", "", "&fScans a Chunk for natural Resources", "", "&eRight Click&7 to scan"); public static final SlimefunItemStack GEO_MINER = new SlimefunItemStack("GEO_MINER", HeadTexture.GEO_MINER, "&6GEO Miner", "", "&eMines up resources from the chunk", "&eThese Resources cannot be mined with a pickaxe", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(48), "", "&c&l! &cMake sure to Geo-Scan the Chunk first"); public static final SlimefunItemStack OIL_PUMP = new SlimefunItemStack("OIL_PUMP", HeadTexture.OIL_PUMP, "&4Oil Pump", "", "&7Pumps up Oil and fills it into Buckets", "", "&c&l! &cMake sure to Geo-Scan the Chunk first"); public static final SlimefunItemStack OIL_BUCKET = new SlimefunItemStack("BUCKET_OF_OIL", HeadTexture.OIL_BUCKET, "&fBucket of Oil"); public static final SlimefunItemStack FUEL_BUCKET = new SlimefunItemStack("BUCKET_OF_FUEL", HeadTexture.FUEL_BUCKET, "&fBucket of Fuel"); - public static final SlimefunItemStack REFINERY = new SlimefunItemStack("REFINERY", Material.PISTON, "&cRefinery", "", "&fRefines Oil to create Fuel"); + public static final SlimefunItemStack REFINERY = new SlimefunItemStack("REFINERY", XMaterial.PISTON.parseMaterial(), "&cRefinery", "", "&fRefines Oil to create Fuel"); public static final SlimefunItemStack COMBUSTION_REACTOR = new SlimefunItemStack("COMBUSTION_REACTOR", HeadTexture.GENERATOR, "&cCombustion Reactor", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.GENERATOR), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(24)); public static final SlimefunItemStack ANDROID_MEMORY_CORE = new SlimefunItemStack("ANDROID_MEMORY_CORE", HeadTexture.ENERGY_REGULATOR, "&bAndroid Memory Core"); - public static final SlimefunItemStack GPS_TELEPORTER_PYLON = new SlimefunItemStack("GPS_TELEPORTER_PYLON", Material.PURPLE_STAINED_GLASS, "&5GPS Teleporter Pylon", "", "&7Teleporter Component"); + public static final SlimefunItemStack GPS_TELEPORTER_PYLON = new SlimefunItemStack("GPS_TELEPORTER_PYLON", XMaterial.PURPLE_STAINED_GLASS.parseMaterial(), "&5GPS Teleporter Pylon", "", "&7Teleporter Component"); public static final SlimefunItemStack GPS_TELEPORTATION_MATRIX = new SlimefunItemStack("GPS_TELEPORTATION_MATRIX", Material.IRON_BLOCK, "&bGPS Teleporter Matrix", "", "&fThis is your Teleporter's Main Component", "&fThis Matrix allows Players to choose from all", "&fWaypoints made by the Player who has placed", "&fthis Device."); - public static final SlimefunItemStack GPS_ACTIVATION_DEVICE_SHARED = new SlimefunItemStack("GPS_ACTIVATION_DEVICE_SHARED", Material.STONE_PRESSURE_PLATE, "&fGPS Activation Device &3(Shared)", "", "&fPlace this onto a Teleportation Matrix", "&fand step onto this Plate to activate", "&fthe Teleportation Process"); - public static final SlimefunItemStack GPS_ACTIVATION_DEVICE_PERSONAL = new SlimefunItemStack("GPS_ACTIVATION_DEVICE_PERSONAL", Material.STONE_PRESSURE_PLATE, "&fGPS Activation Device &a(Personal)", "", "&fPlace this onto a Teleportation Matrix", "&fand step onto this Plate to activate", "&fthe Teleportation Process", "", "&fThis Version only allows the Person who", "&fplaced this Device to use it"); + public static final SlimefunItemStack GPS_ACTIVATION_DEVICE_SHARED = new SlimefunItemStack("GPS_ACTIVATION_DEVICE_SHARED", XMaterial.STONE_PRESSURE_PLATE.parseMaterial(), "&fGPS Activation Device &3(Shared)", "", "&fPlace this onto a Teleportation Matrix", "&fand step onto this Plate to activate", "&fthe Teleportation Process"); + public static final SlimefunItemStack GPS_ACTIVATION_DEVICE_PERSONAL = new SlimefunItemStack("GPS_ACTIVATION_DEVICE_PERSONAL", XMaterial.STONE_PRESSURE_PLATE.parseMaterial(), "&fGPS Activation Device &a(Personal)", "", "&fPlace this onto a Teleportation Matrix", "&fand step onto this Plate to activate", "&fthe Teleportation Process", "", "&fThis Version only allows the Person who", "&fplaced this Device to use it"); public static final SlimefunItemStack PORTABLE_TELEPORTER = new SlimefunItemStack("PORTABLE_TELEPORTER", Material.COMPASS, "&bPortable Teleporter", "", "&fThis device allows you to teleport", "&fto your waypoints from anywhere", "", LoreBuilder.powerCharged(0, 50), "", "&eRight Click&7 to use"); - public static final SlimefunItemStack ELEVATOR_PLATE = new SlimefunItemStack("ELEVATOR_PLATE", Material.STONE_PRESSURE_PLATE, "&bElevator Plate", "", "&fPlace an Elevator Plate on every floor", "&fand you will be able to teleport between them.", "", "&eRight Click this Block &7to name it"); + public static final SlimefunItemStack ELEVATOR_PLATE = new SlimefunItemStack("ELEVATOR_PLATE", XMaterial.STONE_PRESSURE_PLATE.parseMaterial(), "&bElevator Plate", "", "&fPlace an Elevator Plate on every floor", "&fand you will be able to teleport between them.", "", "&eRight Click this Block &7to name it"); public static final SlimefunItemStack INFUSED_HOPPER = new SlimefunItemStack("INFUSED_HOPPER", Material.HOPPER, "&5Infused Hopper", "", "&fAutomatically picks up nearby Items in a 7x7x7", "&fRadius when placed."); - public static final SlimefunItemStack HEATED_PRESSURE_CHAMBER = new SlimefunItemStack("HEATED_PRESSURE_CHAMBER", Material.LIGHT_GRAY_STAINED_GLASS, "&cHeated Pressure Chamber", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10)); - public static final SlimefunItemStack HEATED_PRESSURE_CHAMBER_2 = new SlimefunItemStack("HEATED_PRESSURE_CHAMBER_2", Material.LIGHT_GRAY_STAINED_GLASS, "&cHeated Pressure Chamber &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(5), LoreBuilder.powerPerSecond(44)); + public static final SlimefunItemStack HEATED_PRESSURE_CHAMBER = new SlimefunItemStack("HEATED_PRESSURE_CHAMBER", XMaterial.LIGHT_GRAY_STAINED_GLASS.parseMaterial(), "&cHeated Pressure Chamber", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10)); + public static final SlimefunItemStack HEATED_PRESSURE_CHAMBER_2 = new SlimefunItemStack("HEATED_PRESSURE_CHAMBER_2", XMaterial.LIGHT_GRAY_STAINED_GLASS.parseMaterial(), "&cHeated Pressure Chamber &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(5), LoreBuilder.powerPerSecond(44)); public static final SlimefunItemStack ELECTRIC_SMELTERY = new SlimefunItemStack("ELECTRIC_SMELTERY", Material.FURNACE, "&cElectric Smeltery", "", "&4Alloys-Only, doesn't smelt Dust into Ingots", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(20)); public static final SlimefunItemStack ELECTRIC_SMELTERY_2 = new SlimefunItemStack("ELECTRIC_SMELTERY_2", Material.FURNACE, "&cElectric Smeltery &7- &eII", "", "&4Alloys-Only, doesn't smelt Dust into Ingots", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(40)); @@ -754,13 +757,13 @@ private SlimefunItems() {} public static final SlimefunItemStack ELECTRIC_PRESS = new SlimefunItemStack("ELECTRIC_PRESS", HeadTexture.ELECTRIC_PRESS, "&eElectric Press", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(16)); public static final SlimefunItemStack ELECTRIC_PRESS_2 = new SlimefunItemStack("ELECTRIC_PRESS_2", HeadTexture.ELECTRIC_PRESS, "&eElectric Press &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(40)); - public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE", Material.RED_TERRACOTTA, "&cElectrified Crucible", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(48)); - public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE_2 = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE_2", Material.RED_TERRACOTTA, "&cElectrified Crucible &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(2), LoreBuilder.powerPerSecond(80)); - public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE_3 = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE_3", Material.RED_TERRACOTTA, "&cElectrified Crucible &7- &eIII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(4), LoreBuilder.powerPerSecond(120)); + public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE", XMaterial.RED_TERRACOTTA.parseMaterial(), "&cElectrified Crucible", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(48)); + public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE_2 = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE_2", XMaterial.RED_TERRACOTTA.parseMaterial(), "&cElectrified Crucible &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(2), LoreBuilder.powerPerSecond(80)); + public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE_3 = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE_3", XMaterial.RED_TERRACOTTA.parseMaterial(), "&cElectrified Crucible &7- &eIII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(4), LoreBuilder.powerPerSecond(120)); - public static final SlimefunItemStack CARBON_PRESS = new SlimefunItemStack("CARBON_PRESS", Material.BLACK_STAINED_GLASS, "&cCarbon Press", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(20)); - public static final SlimefunItemStack CARBON_PRESS_2 = new SlimefunItemStack("CARBON_PRESS_2", Material.BLACK_STAINED_GLASS, "&cCarbon Press &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(50)); - public static final SlimefunItemStack CARBON_PRESS_3 = new SlimefunItemStack("CARBON_PRESS_3", Material.BLACK_STAINED_GLASS, "&cCarbon Press &7- &eIII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(15), LoreBuilder.powerPerSecond(180)); + public static final SlimefunItemStack CARBON_PRESS = new SlimefunItemStack("CARBON_PRESS", XMaterial.BLACK_STAINED_GLASS.parseMaterial(), "&cCarbon Press", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(20)); + public static final SlimefunItemStack CARBON_PRESS_2 = new SlimefunItemStack("CARBON_PRESS_2", XMaterial.BLACK_STAINED_GLASS.parseMaterial(), "&cCarbon Press &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(50)); + public static final SlimefunItemStack CARBON_PRESS_3 = new SlimefunItemStack("CARBON_PRESS_3", XMaterial.BLACK_STAINED_GLASS.parseMaterial(), "&cCarbon Press &7- &eIII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(15), LoreBuilder.powerPerSecond(180)); public static final SlimefunItemStack BLISTERING_INGOT = new SlimefunItemStack("BLISTERING_INGOT", Material.GOLD_INGOT, "&6Blistering Ingot &7(33%)", "", LoreBuilder.radioactive(Radioactivity.HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); public static final SlimefunItemStack BLISTERING_INGOT_2 = new SlimefunItemStack("BLISTERING_INGOT_2", Material.GOLD_INGOT, "&6Blistering Ingot &7(66%)", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); @@ -768,7 +771,7 @@ private SlimefunItems() {} public static final SlimefunItemStack ENERGY_REGULATOR = new SlimefunItemStack("ENERGY_REGULATOR", HeadTexture.ENERGY_REGULATOR, "&6Energy Regulator", "", "&fCore Component of an Energy Network"); public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.ENERGY_CONNECTOR, "&eEnergy Connector", LoreBuilder.range(6), "", "&fPlace this between machines", "&fand generators to connect them", "&fto your regulator."); - public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack("DEBUG_FISH", Material.SALMON, "&3How much is the Fish?", "", "&eRight Click &fany Block to view it's BlockData", "&eLeft Click &fto break a Block", "&eShift + Left Click &fany Block to erase it's BlockData", "&eShift + Right Click &fto place a Placeholder Block"); + public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack("DEBUG_FISH", XMaterial.SALMON.parseMaterial(), "&3How much is the Fish?", "", "&eRight Click &fany Block to view it's BlockData", "&eLeft Click &fto break a Block", "&eShift + Left Click &fany Block to erase it's BlockData", "&eShift + Right Click &fto place a Placeholder Block"); public static final SlimefunItemStack NETHER_ICE = new SlimefunItemStack("NETHER_ICE", HeadTexture.NETHER_ICE, "&eNether Ice", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED); public static final SlimefunItemStack ENRICHED_NETHER_ICE = new SlimefunItemStack("ENRICHED_NETHER_ICE", HeadTexture.ENRICHED_NETHER_ICE, "&eEnriched Nether Ice", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); @@ -812,41 +815,41 @@ private SlimefunItems() {} public static final SlimefunItemStack SEAGRASS_FERTILIZER = new SlimefunItemStack("FERTILIZER_SEAGRASS", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Seagrass"); public static final SlimefunItemStack ANIMAL_GROWTH_ACCELERATOR = new SlimefunItemStack("ANIMAL_GROWTH_ACCELERATOR", Material.HAY_BLOCK, "&bAnimal Growth Accelerator", "", "&fRuns on &aOrganic Food", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(28)); - public static final SlimefunItemStack CROP_GROWTH_ACCELERATOR = new SlimefunItemStack("CROP_GROWTH_ACCELERATOR", Material.LIME_TERRACOTTA, "&aCrop Growth Accelerator", "", "&fRuns on &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Radius: 7x7", "&8\u21E8 &7Speed: &a3/time", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(50)); - public static final SlimefunItemStack CROP_GROWTH_ACCELERATOR_2 = new SlimefunItemStack("CROP_GROWTH_ACCELERATOR_2", Material.LIME_TERRACOTTA, "&aCrop Growth Accelerator &7(&eII&7)", "", "&fRuns on &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Radius: 9x9", "&8\u21E8 &7Speed: &a4/time", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(60)); - public static final SlimefunItemStack TREE_GROWTH_ACCELERATOR = new SlimefunItemStack("TREE_GROWTH_ACCELERATOR", Material.BROWN_TERRACOTTA, "&aTree Growth Accelerator", "", "&fRuns on &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Radius: 9x9", "&8\u21E8 &7Speed: &a4/time", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(48)); + public static final SlimefunItemStack CROP_GROWTH_ACCELERATOR = new SlimefunItemStack("CROP_GROWTH_ACCELERATOR", XMaterial.LIME_TERRACOTTA.parseMaterial(), "&aCrop Growth Accelerator", "", "&fRuns on &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Radius: 7x7", "&8\u21E8 &7Speed: &a3/time", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(50)); + public static final SlimefunItemStack CROP_GROWTH_ACCELERATOR_2 = new SlimefunItemStack("CROP_GROWTH_ACCELERATOR_2", XMaterial.LIME_TERRACOTTA.parseMaterial(), "&aCrop Growth Accelerator &7(&eII&7)", "", "&fRuns on &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Radius: 9x9", "&8\u21E8 &7Speed: &a4/time", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(60)); + public static final SlimefunItemStack TREE_GROWTH_ACCELERATOR = new SlimefunItemStack("TREE_GROWTH_ACCELERATOR", XMaterial.BROWN_TERRACOTTA.parseMaterial(), "&aTree Growth Accelerator", "", "&fRuns on &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Radius: 9x9", "&8\u21E8 &7Speed: &a4/time", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(48)); - public static final SlimefunItemStack FOOD_FABRICATOR = new SlimefunItemStack("FOOD_FABRICATOR", Material.GREEN_STAINED_GLASS, "&cFood Fabricator", "", "&fProduces &aOrganic Food", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(14)); - public static final SlimefunItemStack FOOD_FABRICATOR_2 = new SlimefunItemStack("FOOD_FABRICATOR_2", Material.GREEN_STAINED_GLASS, "&cFood Fabricator &7(&eII&7)", "", "&fProduces &aOrganic Food", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(6), LoreBuilder.powerBuffer(512), LoreBuilder.powerPerSecond(48)); + public static final SlimefunItemStack FOOD_FABRICATOR = new SlimefunItemStack("FOOD_FABRICATOR", XMaterial.GREEN_STAINED_GLASS.parseMaterial(), "&cFood Fabricator", "", "&fProduces &aOrganic Food", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(14)); + public static final SlimefunItemStack FOOD_FABRICATOR_2 = new SlimefunItemStack("FOOD_FABRICATOR_2", XMaterial.GREEN_STAINED_GLASS.parseMaterial(), "&cFood Fabricator &7(&eII&7)", "", "&fProduces &aOrganic Food", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(6), LoreBuilder.powerBuffer(512), LoreBuilder.powerPerSecond(48)); - public static final SlimefunItemStack FOOD_COMPOSTER = new SlimefunItemStack("FOOD_COMPOSTER", Material.GREEN_TERRACOTTA, "&cFood Composter", "", "&fProduces &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(16)); - public static final SlimefunItemStack FOOD_COMPOSTER_2 = new SlimefunItemStack("FOOD_COMPOSTER_2", Material.GREEN_TERRACOTTA, "&cFood Composter &7(&eII&7)", "", "&fProduces &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(10), LoreBuilder.powerBuffer(512), LoreBuilder.powerPerSecond(52)); + public static final SlimefunItemStack FOOD_COMPOSTER = new SlimefunItemStack("FOOD_COMPOSTER", XMaterial.GREEN_TERRACOTTA.parseMaterial(), "&cFood Composter", "", "&fProduces &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(16)); + public static final SlimefunItemStack FOOD_COMPOSTER_2 = new SlimefunItemStack("FOOD_COMPOSTER_2", XMaterial.GREEN_TERRACOTTA.parseMaterial(), "&cFood Composter &7(&eII&7)", "", "&fProduces &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(10), LoreBuilder.powerBuffer(512), LoreBuilder.powerPerSecond(52)); public static final SlimefunItemStack EXP_COLLECTOR = new SlimefunItemStack("XP_COLLECTOR", HeadTexture.EXP_COLLECTOR, "&aEXP Collector", "", "&fCollects nearby Exp and stores it", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(20)); public static final SlimefunItemStack REACTOR_COOLANT_CELL = new SlimefunItemStack("REACTOR_COLLANT_CELL", HeadTexture.COOLANT_CELL, "&bReactor Coolant Cell"); public static final SlimefunItemStack NUCLEAR_REACTOR = new SlimefunItemStack("NUCLEAR_REACTOR", HeadTexture.NUCLEAR_REACTOR, "&2Nuclear Reactor", "", "&fRequires Cooling!", "&8\u21E8 &bMust be surrounded by Water", "&8\u21E8 &bMust be supplied with Reactor Coolant Cells", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), LoreBuilder.powerBuffer(16384), LoreBuilder.powerPerSecond(500)); public static final SlimefunItemStack NETHER_STAR_REACTOR = new SlimefunItemStack("NETHERSTAR_REACTOR", HeadTexture.NETHER_STAR_REACTOR, "&fNether Star Reactor", "", "&fRuns on Nether Stars", "&8\u21E8 &bMust be surrounded by Water", "&8\u21E8 &bMust be supplied with Nether Ice Coolant Cells", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), LoreBuilder.powerBuffer(32768), LoreBuilder.powerPerSecond(1024), "&8\u21E8 &4Causes nearby Entities to get Withered"); - public static final SlimefunItemStack REACTOR_ACCESS_PORT = new SlimefunItemStack("REACTOR_ACCESS_PORT", Material.CYAN_TERRACOTTA, "&2Reactor Access Port", "", "&fAllows you to interact with a Reactor", "&fvia Cargo Nodes, can also be used", "&fas a Buffer", "", "&8\u21E8 &eMust be placed &a3 Blocks &eabove the Reactor"); + public static final SlimefunItemStack REACTOR_ACCESS_PORT = new SlimefunItemStack("REACTOR_ACCESS_PORT", XMaterial.CYAN_TERRACOTTA.parseMaterial(), "&2Reactor Access Port", "", "&fAllows you to interact with a Reactor", "&fvia Cargo Nodes, can also be used", "&fas a Buffer", "", "&8\u21E8 &eMust be placed &a3 Blocks &eabove the Reactor"); - public static final SlimefunItemStack FREEZER = new SlimefunItemStack("FREEZER", Material.LIGHT_BLUE_STAINED_GLASS, "&bFreezer", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(18)); - public static final SlimefunItemStack FREEZER_2 = new SlimefunItemStack("FREEZER_2", Material.LIGHT_BLUE_STAINED_GLASS, "&bFreezer &7(&eII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(2), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(30)); - public static final SlimefunItemStack FREEZER_3 = new SlimefunItemStack("FREEZER_3", Material.LIGHT_BLUE_STAINED_GLASS, "&bFreezer &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(42)); + public static final SlimefunItemStack FREEZER = new SlimefunItemStack("FREEZER", XMaterial.LIGHT_BLUE_STAINED_GLASS.parseMaterial(), "&bFreezer", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(18)); + public static final SlimefunItemStack FREEZER_2 = new SlimefunItemStack("FREEZER_2", XMaterial.LIGHT_BLUE_STAINED_GLASS.parseMaterial(), "&bFreezer &7(&eII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(2), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(30)); + public static final SlimefunItemStack FREEZER_3 = new SlimefunItemStack("FREEZER_3", XMaterial.LIGHT_BLUE_STAINED_GLASS.parseMaterial(), "&bFreezer &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(42)); - public static final SlimefunItemStack ELECTRIC_GOLD_PAN = new SlimefunItemStack("ELECTRIC_GOLD_PAN", Material.BROWN_TERRACOTTA, "&6Electric Gold Pan", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(2)); - public static final SlimefunItemStack ELECTRIC_GOLD_PAN_2 = new SlimefunItemStack("ELECTRIC_GOLD_PAN_2", Material.BROWN_TERRACOTTA, "&6Electric Gold Pan &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(4)); - public static final SlimefunItemStack ELECTRIC_GOLD_PAN_3 = new SlimefunItemStack("ELECTRIC_GOLD_PAN_3", Material.BROWN_TERRACOTTA, "&6Electric Gold Pan &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(10), LoreBuilder.powerPerSecond(14)); + public static final SlimefunItemStack ELECTRIC_GOLD_PAN = new SlimefunItemStack("ELECTRIC_GOLD_PAN", XMaterial.BROWN_TERRACOTTA.parseMaterial(), "&6Electric Gold Pan", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(2)); + public static final SlimefunItemStack ELECTRIC_GOLD_PAN_2 = new SlimefunItemStack("ELECTRIC_GOLD_PAN_2", XMaterial.BROWN_TERRACOTTA.parseMaterial(), "&6Electric Gold Pan &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(4)); + public static final SlimefunItemStack ELECTRIC_GOLD_PAN_3 = new SlimefunItemStack("ELECTRIC_GOLD_PAN_3", XMaterial.BROWN_TERRACOTTA.parseMaterial(), "&6Electric Gold Pan &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(10), LoreBuilder.powerPerSecond(14)); - public static final SlimefunItemStack ELECTRIC_DUST_WASHER = new SlimefunItemStack("ELECTRIC_DUST_WASHER", Material.BLUE_STAINED_GLASS, "&3Electric Dust Washer", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(6)); - public static final SlimefunItemStack ELECTRIC_DUST_WASHER_2 = new SlimefunItemStack("ELECTRIC_DUST_WASHER_2", Material.BLUE_STAINED_GLASS, "&3Electric Dust Washer &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(2), LoreBuilder.powerPerSecond(10)); - public static final SlimefunItemStack ELECTRIC_DUST_WASHER_3 = new SlimefunItemStack("ELECTRIC_DUST_WASHER_3", Material.BLUE_STAINED_GLASS, "&3Electric Dust Washer &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(10), LoreBuilder.powerPerSecond(30)); + public static final SlimefunItemStack ELECTRIC_DUST_WASHER = new SlimefunItemStack("ELECTRIC_DUST_WASHER", XMaterial.BLUE_STAINED_GLASS.parseMaterial(), "&3Electric Dust Washer", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(6)); + public static final SlimefunItemStack ELECTRIC_DUST_WASHER_2 = new SlimefunItemStack("ELECTRIC_DUST_WASHER_2", XMaterial.BLUE_STAINED_GLASS.parseMaterial(), "&3Electric Dust Washer &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(2), LoreBuilder.powerPerSecond(10)); + public static final SlimefunItemStack ELECTRIC_DUST_WASHER_3 = new SlimefunItemStack("ELECTRIC_DUST_WASHER_3", XMaterial.BLUE_STAINED_GLASS.parseMaterial(), "&3Electric Dust Washer &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(10), LoreBuilder.powerPerSecond(30)); - public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY", Material.RED_TERRACOTTA, "&cElectric Ingot Factory", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(8)); - public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY_2 = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY_2", Material.RED_TERRACOTTA, "&cElectric Ingot Factory &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(2), LoreBuilder.powerPerSecond(14)); - public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY_3 = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY_3", Material.RED_TERRACOTTA, "&cElectric Ingot Factory &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(8), LoreBuilder.powerPerSecond(40)); + public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY", XMaterial.RED_TERRACOTTA.parseMaterial(), "&cElectric Ingot Factory", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(8)); + public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY_2 = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY_2", XMaterial.RED_TERRACOTTA.parseMaterial(), "&cElectric Ingot Factory &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.speed(2), LoreBuilder.powerPerSecond(14)); + public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY_3 = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY_3", XMaterial.RED_TERRACOTTA.parseMaterial(), "&cElectric Ingot Factory &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(8), LoreBuilder.powerPerSecond(40)); - public static final SlimefunItemStack FLUID_PUMP = new SlimefunItemStack("FLUID_PUMP", Material.BLUE_TERRACOTTA, "&9Fluid Pump", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &732 J/Block"); - public static final SlimefunItemStack CHARGING_BENCH = new SlimefunItemStack("CHARGING_BENCH", Material.CRAFTING_TABLE, "&6Charging Bench", "", "&fCharges Items such as Jetpacks", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.powerBuffer(128), "&8\u21E8 &e\u26A1 &7Energy Loss: &c50%"); + public static final SlimefunItemStack FLUID_PUMP = new SlimefunItemStack("FLUID_PUMP", XMaterial.BLUE_TERRACOTTA.parseMaterial(), "&9Fluid Pump", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &732 J/Block"); + public static final SlimefunItemStack CHARGING_BENCH = new SlimefunItemStack("CHARGING_BENCH", XMaterial.CRAFTING_TABLE.parseMaterial(), "&6Charging Bench", "", "&fCharges Items such as Jetpacks", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.powerBuffer(128), "&8\u21E8 &e\u26A1 &7Energy Loss: &c50%"); public static final SlimefunItemStack VANILLA_AUTO_CRAFTER = new SlimefunItemStack("VANILLA_AUTO_CRAFTER", HeadTexture.VANILLA_AUTO_CRAFTER, "&2Auto-Crafter &8(Vanilla)", "", "&fPlace this machine on top of a", "&fchest or similar and make it craft", "&fanything that can be crafted using a", "&fnormal &eCrafting Table", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &716 J/Item"); public static final SlimefunItemStack ENHANCED_AUTO_CRAFTER = new SlimefunItemStack("ENHANCED_AUTO_CRAFTER", HeadTexture.ENHANCED_AUTO_CRAFTER, "&2Auto-Crafter &8(Enhanced)", "", "&fPlace this machine on top of a", "&fchest or similar and make it craft", "&fanything that can be crafted using an", "&eEnhanced Crafting Table", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &716 J/Item"); @@ -858,13 +861,17 @@ private SlimefunItems() {} public static final SlimefunItemStack TRASH_CAN = new SlimefunItemStack("TRASH_CAN_BLOCK", HeadTexture.TRASH_CAN, "&3Trash Can", "", "&fWill destroy all Items put into it"); public static final SlimefunItemStack ELYTRA_SCALE = new SlimefunItemStack("ELYTRA_SCALE", Material.FEATHER, "&bElytra Scale"); - public static final SlimefunItemStack INFUSED_ELYTRA = new SlimefunItemStack("INFUSED_ELYTRA", Material.ELYTRA, "&5Infused Elytra"); - public static final SlimefunItemStack SOULBOUND_ELYTRA = new SlimefunItemStack("SOULBOUND_ELYTRA", Material.ELYTRA, "&cSoulbound Elytra"); + public static final SlimefunItemStack INFUSED_ELYTRA = new SlimefunItemStack("INFUSED_ELYTRA", XMaterial.ELYTRA.parseMaterial(), "&5Infused Elytra"); + public static final SlimefunItemStack SOULBOUND_ELYTRA = new SlimefunItemStack("SOULBOUND_ELYTRA", XMaterial.ELYTRA.parseMaterial(), "&cSoulbound Elytra"); public static final SlimefunItemStack MAGNESIUM_SALT = new SlimefunItemStack("MAGNESIUM_SALT", Material.SUGAR, "&cMagnesium Salt", "", "&7A special type of fuel that can be", "&7used in a Magnesium-powered Generator"); public static final SlimefunItemStack MAGNESIUM_GENERATOR = new SlimefunItemStack("MAGNESIUM_GENERATOR", HeadTexture.GENERATOR, "&cMagnesium-powered Generator", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.GENERATOR), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(36)); static { - INFUSED_ELYTRA.addUnsafeEnchantment(Enchantment.MENDING, 1); + // MENDING is 1.9+ (null on older servers, where the Infused Elytra cannot carry it). + if (VersionedEnchantment.MENDING != null) { + INFUSED_ELYTRA.addUnsafeEnchantment(VersionedEnchantment.MENDING, 1); + } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/StartupWarnings.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/StartupWarnings.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/StartupWarnings.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/StartupWarnings.java index 77b3a7479a..8470699825 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/StartupWarnings.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/StartupWarnings.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation; +package io.github.thebusybiscuit.slimefun5.implementation; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; /** * This class stores some startup warnings we occasionally need to print. @@ -74,3 +74,4 @@ static void oldJavaVersion(Logger logger, int recommendedJavaVersion) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/CheatSheetSlimefunGuide.java similarity index 61% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/CheatSheetSlimefunGuide.java index 79ab38c662..83e29bc9df 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/CheatSheetSlimefunGuide.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.guide; +package io.github.thebusybiscuit.slimefun5.implementation.guide; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; +import io.github.thebusybiscuit.slimefun5.core.guide.options.SlimefunGuideSettings; import java.util.LinkedList; import java.util.List; @@ -10,15 +12,15 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.groups.FlexItemGroup; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.SlimefunGuideItem; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -54,7 +56,7 @@ protected List getVisibleItemGroups(@Nonnull Player p, @Nonnull Playe List groups = new LinkedList<>(); for (ItemGroup group : Slimefun.getRegistry().getAllItemGroups()) { - if (!(group instanceof FlexItemGroup flexItemGroup) || flexItemGroup.isVisible(p, profile, getMode())) { + if (!(group instanceof FlexItemGroup) || ((FlexItemGroup) group).isVisible(p, profile, getMode())) { groups.add(group); } } @@ -77,8 +79,12 @@ protected List getVisibleItemGroups(@Nonnull Player p, @Nonnull Playe public void createHeader(Player p, PlayerProfile profile, ChestMenu menu) { super.createHeader(p, profile, menu); - // Remove Settings Panel - menu.addItem(1, ChestMenuUtils.getBackground()); - menu.addMenuClickHandler(1, ChestMenuUtils.getEmptyClickHandler()); + // Settings / Info panel (also available in the cheat-sheet guide) + menu.addItem(1, ChestMenuUtils.getMenuButton(p)); + menu.addMenuClickHandler(1, (pl, slot, item, action) -> { + SlimefunGuideSettings.openSettings(pl, HandCompat.getMainHand(pl.getInventory())); + return false; + }); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/SurvivalSlimefunGuide.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/SurvivalSlimefunGuide.java index 617816af07..c91f2df84e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/SurvivalSlimefunGuide.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.guide; +package io.github.thebusybiscuit.slimefun5.implementation.guide; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.Arrays; @@ -14,10 +16,10 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.RecipeChoice; @@ -27,29 +29,29 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; import io.github.bakedlibs.dough.recipes.MinecraftRecipe; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedItemFlag; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.groups.FlexItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.groups.LockedItemGroup; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.guide.GuideHistory; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideImplementation; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.core.guide.options.SlimefunGuideSettings; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlock; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AsyncRecipeChoiceTask; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedItemFlag; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.SlimefunGuideItem; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; @@ -109,8 +111,8 @@ protected final boolean isSurvivalMode() { for (ItemGroup group : Slimefun.getRegistry().getAllItemGroups()) { try { - if (group instanceof FlexItemGroup flexItemGroup) { - if (flexItemGroup.isVisible(p, profile, getMode())) { + if (group instanceof FlexItemGroup) { + FlexItemGroup flexItemGroup = (FlexItemGroup) group; if (flexItemGroup.isVisible(p, profile, getMode())) { groups.add(group); } } else if (!group.isHidden(p)) { @@ -223,8 +225,8 @@ public void openItemGroup(PlayerProfile profile, ItemGroup itemGroup, int page) return; } - if (itemGroup instanceof FlexItemGroup flexItemGroup) { - flexItemGroup.open(p, profile, getMode()); + if (itemGroup instanceof FlexItemGroup) { + FlexItemGroup flexItemGroup = (FlexItemGroup) itemGroup; flexItemGroup.open(p, profile, getMode()); return; } @@ -361,7 +363,7 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory ItemStack itemstack = CustomItemStack.create(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); - meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP); + VersionedItemFlag.addFlags(meta, VersionedItemFlag.HIDE_ATTRIBUTES, VersionedItemFlag.HIDE_ENCHANTS, VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP); }); menu.addItem(index, itemstack); @@ -483,16 +485,16 @@ private void showMinecraftRecipe(Recipe[] recipes, int index, ItemStack item, Pl private void showRecipeChoices(T recipe, ItemStack[] recipeItems, AsyncRecipeChoiceTask task) { RecipeChoice[] choices = Slimefun.getMinecraftRecipeService().getRecipeShape(recipe); - if (choices.length == 1 && choices[0] instanceof MaterialChoice materialChoice) { - recipeItems[4] = new ItemStack(materialChoice.getChoices().get(0)); + if (choices.length == 1 && choices[0] instanceof MaterialChoice) { + MaterialChoice materialChoice = (MaterialChoice) choices[0]; recipeItems[4] = new ItemStack(materialChoice.getChoices().get(0)); if (materialChoice.getChoices().size() > 1) { task.add(recipeSlots[4], materialChoice); } } else { for (int i = 0; i < choices.length; i++) { - if (choices[i] instanceof MaterialChoice materialChoice) { - recipeItems[i] = new ItemStack(materialChoice.getChoices().get(0)); + if (choices[i] instanceof MaterialChoice) { + MaterialChoice materialChoice = (MaterialChoice) choices[i]; recipeItems[i] = new ItemStack(materialChoice.getChoices().get(0)); if (materialChoice.getChoices().size() > 1) { task.add(recipeSlots[i], materialChoice); @@ -515,7 +517,7 @@ public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToH Optional wiki = item.getWikipage(); if (wiki.isPresent()) { - menu.addItem(8, CustomItemStack.create(Material.KNOWLEDGE_BOOK, ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); + menu.addItem(8, CustomItemStack.create(XMaterial.KNOWLEDGE_BOOK.parseMaterial(), ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> { pl.closeInventory(); ChatUtils.sendURL(pl, wiki.get()); @@ -535,8 +537,8 @@ public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToH displayItem(menu, profile, p, item, result, recipeType, recipe, task); - if (item instanceof RecipeDisplayItem recipeDisplayItem) { - displayRecipes(p, profile, menu, recipeDisplayItem, 0); + if (item instanceof RecipeDisplayItem) { + RecipeDisplayItem recipeDisplayItem = (RecipeDisplayItem) item; displayRecipes(p, profile, menu, recipeDisplayItem, 0); } menu.open(p); @@ -593,7 +595,7 @@ public void createHeader(Player p, PlayerProfile profile, ChestMenu menu) { // Settings Panel menu.addItem(1, ChestMenuUtils.getMenuButton(p)); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { - SlimefunGuideSettings.openSettings(pl, pl.getInventory().getItemInMainHand()); + SlimefunGuideSettings.openSettings(pl, HandCompat.getMainHand(pl.getInventory())); return false; }); @@ -760,3 +762,4 @@ private void printErrorMessage(Player p, SlimefunItem item, Throwable x) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/package-info.java new file mode 100644 index 0000000000..34792f2257 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/guide/package-info.java @@ -0,0 +1,5 @@ +/** + * This package provides the different implementations of our + * {@link io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide} + */ +package io.github.thebusybiscuit.slimefun5.implementation.guide; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/SimpleBlockBreakHandler.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/SimpleBlockBreakHandler.java index 0122d13390..a2f3d877e7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/SimpleBlockBreakHandler.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.handlers; +package io.github.thebusybiscuit.slimefun5.implementation.handlers; import java.util.List; @@ -9,9 +9,9 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; +import io.github.thebusybiscuit.slimefun5.api.events.AndroidMineEvent; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.MinerAndroid; /** * This simple implementation of {@link BlockBreakHandler} will execute the same code @@ -57,3 +57,4 @@ public void onExplode(Block b, List drops) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/VanillaInventoryDropHandler.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/VanillaInventoryDropHandler.java index 7ead892718..a457306cc2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/VanillaInventoryDropHandler.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.handlers; +package io.github.thebusybiscuit.slimefun5.implementation.handlers; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.List; @@ -14,8 +16,8 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; import io.papermc.lib.PaperLib; /** @@ -69,7 +71,7 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro T inventoryHolder = blockStateClass.cast(state); for (ItemStack stack : getInventory(inventoryHolder)) { - if (stack != null && !stack.getType().isAir()) { + if (stack != null && !MaterialCompat.isAir(stack.getType())) { drops.add(stack); } } @@ -78,11 +80,12 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro @Nonnull protected Inventory getInventory(@Nonnull T inventoryHolder) { - if (inventoryHolder instanceof Chest chest) { - return chest.getBlockInventory(); + if (inventoryHolder instanceof Chest) { + Chest chest = (Chest) inventoryHolder; return chest.getBlockInventory(); } else { return inventoryHolder.getInventory(); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/package-info.java similarity index 52% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/package-info.java index 2afaa20dce..c6dab3948d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/handlers/package-info.java @@ -1,5 +1,5 @@ /** - * This package holds simple implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemHandler}. + * This package holds simple implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.ItemHandler}. * These are just handlers that can be re-used frequently. */ -package io.github.thebusybiscuit.slimefun4.implementation.handlers; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.handlers; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/EnchantedItem.java similarity index 57% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/EnchantedItem.java index a7525c9971..430267d013 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/EnchantedItem.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * The {@link EnchantedItem} is an enchanted {@link SlimefunItem}. @@ -28,3 +28,4 @@ public EnchantedItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/HiddenItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/HiddenItem.java similarity index 60% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/HiddenItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/HiddenItem.java index dcfaa8a103..ccd3499481 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/HiddenItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/HiddenItem.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotConfigurable; /** * The {@link HiddenItem} is a {@link NotConfigurable} {@link SlimefunItem} @@ -25,3 +25,4 @@ public HiddenItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe this.setHidden(true); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/LimitedUseItem.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/LimitedUseItem.java index c4377d4585..a7fb533172 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/LimitedUseItem.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.util.Collections; import java.util.List; @@ -8,7 +10,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -16,16 +18,16 @@ import org.bukkit.persistence.PersistentDataType; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.StormStaff; -import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder; -import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves.StormStaff; +import io.github.thebusybiscuit.slimefun5.utils.LoreBuilder; +import io.github.thebusybiscuit.slimefun5.utils.PatternUtils; /** * This class represents an item with a limited number of uses. @@ -112,8 +114,7 @@ protected void damageItem(Player p, ItemStack item) { } else { ItemMeta meta = item.getItemMeta(); NamespacedKey key = getStorageKey(); - PersistentDataContainer pdc = meta.getPersistentDataContainer(); - int usesLeft = pdc.getOrDefault(key, PersistentDataType.INTEGER, getMaxUseCount()); + int usesLeft = (Integer) PdcCompat.getOrDefault(meta, key, "INTEGER", getMaxUseCount()); if (usesLeft == 1) { SoundEffect.LIMITED_USE_ITEM_BREAK_SOUND.playFor(p); @@ -121,7 +122,7 @@ protected void damageItem(Player p, ItemStack item) { item.setType(Material.AIR); } else { usesLeft--; - pdc.set(key, PersistentDataType.INTEGER, usesLeft); + PdcCompat.set(meta, key, "INTEGER", usesLeft); updateItemLore(item, meta, usesLeft); } @@ -150,3 +151,4 @@ private void updateItemLore(ItemStack item, ItemMeta meta, int usesLeft) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/RadioactiveItem.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/RadioactiveItem.java index 0a08ae0eff..6c75fc326d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/RadioactiveItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -6,15 +6,15 @@ import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactive; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactivity; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; /** * A quick and easy implementation of {@link SlimefunItem} that also implements the @@ -91,3 +91,4 @@ public Radioactivity getRadioactivity() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/SimpleSlimefunItem.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/SimpleSlimefunItem.java index 839a3ce053..394e79a88c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/SimpleSlimefunItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -6,12 +6,12 @@ import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; /** * This is basically a quickstart class for your very first {@link SlimefunItem}. @@ -54,3 +54,4 @@ public void preRegister() { public abstract @Nonnull T getItemHandler(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/VanillaItem.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/VanillaItem.java index 7d6291b91a..6bdc18ace1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/VanillaItem.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemState; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemState; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; /** * Represents a vanilla item that is overridden by Slimefun (like {@code ELYTRA}). @@ -47,3 +47,4 @@ public VanillaItem(ItemGroup itemGroup, ItemStack item, String id, RecipeType re useableInWorkbench = true; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AltarRecipe.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AltarRecipe.java index b42f909d3f..2ae6e063c0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AltarRecipe.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.altar; +package io.github.thebusybiscuit.slimefun5.implementation.items.altar; import java.util.ArrayList; import java.util.List; @@ -41,3 +41,4 @@ public List getInput() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientAltar.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AncientAltar.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientAltar.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AncientAltar.java index e7d153f33a..e0414b405f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientAltar.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AncientAltar.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.altar; +package io.github.thebusybiscuit.slimefun5.implementation.items.altar; import java.util.ArrayList; import java.util.List; @@ -8,15 +8,15 @@ import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.AncientAltarCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask; +import io.github.thebusybiscuit.slimefun5.api.events.AncientAltarCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.AncientAltarListener; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AncientAltarTask; /** * The {@link AncientAltar} is a multiblock structure. @@ -68,3 +68,4 @@ public List getRecipes() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AncientPedestal.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AncientPedestal.java index 5d2548e0b8..05a8c09763 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/AncientPedestal.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.altar; +package io.github.thebusybiscuit.slimefun5.implementation.items.altar; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.Optional; @@ -20,21 +24,21 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask; -import io.github.thebusybiscuit.slimefun4.utils.ArmorStandUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockDispenseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.AncientAltarListener; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AncientAltarTask; +import io.github.thebusybiscuit.slimefun5.utils.ArmorStandUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * The {@link AncientPedestal} is a part of the {@link AncientAltar}. @@ -94,9 +98,9 @@ public void onBlockBreak(@Nonnull Block b) { public @Nonnull Optional getPlacedItem(@Nonnull Block pedestal) { Location l = pedestal.getLocation().add(0.5, 1.2, 0.5); - for (Entity n : l.getWorld().getNearbyEntities(l, 0.5, 0.5, 0.5, AncientPedestal::testItem)) { - if (n instanceof Item item) { - return Optional.of(item); + for (Entity n : EntityCompat.getNearbyEntities(l.getWorld(), l, 0.5, 0.5, 0.5, AncientPedestal::testItem)) { + if (n instanceof Item) { + Item item = (Item) n; return Optional.of(item); } } @@ -106,14 +110,14 @@ public void onBlockBreak(@Nonnull Block b) { public @Nullable ArmorStand getArmorStand(@Nonnull Block pedestal, boolean createIfNoneExists) { Optional entity = getPlacedItem(pedestal); - if (entity.isPresent() && entity.get().getVehicle() instanceof ArmorStand armorStand) { - return armorStand; + if (entity.isPresent() && entity.get().getVehicle() instanceof ArmorStand) { + ArmorStand armorStand = (ArmorStand) entity.get().getVehicle(); return armorStand; } Location l = pedestal.getLocation().add(0.5, 1.2, 0.5); - for (Entity n : l.getWorld().getNearbyEntities(l, 0.5, 0.5, 0.5, this::testArmorStand)) { - if (n instanceof ArmorStand armorStand) { - return armorStand; + for (Entity n : EntityCompat.getNearbyEntities(l.getWorld(), l, 0.5, 0.5, 0.5, this::testArmorStand)) { + if (n instanceof ArmorStand) { + ArmorStand armorStand = (ArmorStand) n; return armorStand; } } @@ -121,8 +125,8 @@ public void onBlockBreak(@Nonnull Block b) { } public static boolean testItem(@Nullable Entity n) { - if (n instanceof Item item && n.isValid()) { - ItemMeta meta = item.getItemStack().getItemMeta(); + if (n instanceof Item && n.isValid()) { + Item item = (Item) n; ItemMeta meta = item.getItemStack().getItemMeta(); return meta.hasDisplayName() && meta.getDisplayName().startsWith(ITEM_PREFIX); } else { @@ -155,7 +159,7 @@ private boolean testArmorStand(@Nullable Entity n) { } public void placeItem(@Nonnull Player p, @Nonnull Block b) { - ItemStack hand = p.getInventory().getItemInMainHand(); + ItemStack hand = HandCompat.getMainHand(p.getInventory()); String displayName = ITEM_PREFIX + System.nanoTime(); ItemStack displayItem = CustomItemStack.create(hand, displayName); displayItem.setAmount(1); @@ -171,14 +175,15 @@ public void placeItem(@Nonnull Player p, @Nonnull Block b) { if (entity != null) { ArmorStand armorStand = getArmorStand(b, true); - entity.setInvulnerable(true); + ReflectionCompat.invoke(entity, "setInvulnerable", true); entity.setVelocity(new Vector(0, 0.1, 0)); entity.setCustomNameVisible(true); entity.setCustomName(nametag); armorStand.setCustomName(displayName); - armorStand.addPassenger(entity); + ReflectionCompat.invoke(armorStand, "addPassenger", entity); SlimefunUtils.markAsNoPickup(entity, "altar_item"); SoundEffect.ANCIENT_PEDESTAL_ITEM_PLACE_SOUND.playAt(b); } } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/package-info.java new file mode 100644 index 0000000000..3233da9d01 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/altar/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds the {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} implementations related to + * the {@link io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientAltar}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.altar; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidAction.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidAction.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidAction.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidAction.java index 296452b6b6..ba106478c2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidAction.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidAction.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -11,3 +11,4 @@ interface AndroidAction { void perform(ProgrammableAndroid android, Block b, BlockMenu inventory, BlockFace face); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidFuelSource.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidFuelSource.java index d2bdc34581..fece3703ec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidFuelSource.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; import javax.annotation.Nonnull; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; /** * This enum covers all different fuel sources a {@link ProgrammableAndroid} can have. @@ -47,3 +47,4 @@ public ItemStack getItem() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidInstance.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidInstance.java index ff68ea759a..ab17f8d63d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidInstance.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; import org.bukkit.block.Block; @@ -21,3 +21,4 @@ public Block getBlock() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidInterface.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidInterface.java index ec21c6a83b..840002a6c4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidInterface.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.block.Dispenser; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockDispenseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.VanillaInventoryDropHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link AndroidInterface} are inventories used to interact with a {@link ProgrammableAndroid}. @@ -36,3 +36,4 @@ public BlockDispenseHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidType.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidType.java index c4fa1a0308..f77e95cefa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/AndroidType.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; import javax.annotation.Nonnull; @@ -62,3 +62,4 @@ boolean isType(@Nonnull AndroidType type) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/ButcherAndroid.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/ButcherAndroid.java index 76e43e65fa..d9dbb57a8e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/ButcherAndroid.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import java.util.function.Predicate; import javax.annotation.ParametersAreNonnullByDefault; @@ -13,10 +14,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; public class ButcherAndroid extends ProgrammableAndroid { @@ -37,15 +38,26 @@ protected void attack(Block b, BlockFace face, Predicate predicate double damage = getTier() >= 3 ? 20D : 4D * getTier(); double radius = 4.0 + getTier(); - for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), radius, radius, radius, n -> n instanceof LivingEntity livingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.isValid() && predicate.test(livingEntity))) { + for (Entity n : EntityCompat.getNearbyEntities(b.getWorld(), b.getLocation(), radius, radius, radius, n -> n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.isValid() && predicate.test((LivingEntity) n))) { // Check if our android is facing this entity. - boolean willAttack = switch (face) { - case NORTH -> n.getLocation().getZ() < b.getZ(); - case EAST -> n.getLocation().getX() > b.getX(); - case SOUTH -> n.getLocation().getZ() > b.getZ(); - case WEST -> n.getLocation().getX() < b.getX(); - default -> false; - }; + boolean willAttack = false; + switch (face) { + case NORTH: + willAttack = n.getLocation().getZ() < b.getZ(); + break; + case EAST: + willAttack = n.getLocation().getX() > b.getX(); + break; + case SOUTH: + willAttack = n.getLocation().getZ() > b.getZ(); + break; + case WEST: + willAttack = n.getLocation().getX() < b.getX(); + break; + default: + willAttack = false; + break; + } if (willAttack) { if (n.hasMetadata(METADATA_KEY)) { @@ -61,3 +73,4 @@ protected void attack(Block b, BlockFace face, Predicate predicate } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/FarmerAndroid.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/FarmerAndroid.java new file mode 100644 index 0000000000..9b778d45ec --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/FarmerAndroid.java @@ -0,0 +1,100 @@ +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun5.api.events.AndroidFarmEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; + +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; + +public class FarmerAndroid extends ProgrammableAndroid { + + @ParametersAreNonnullByDefault + public FarmerAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(itemGroup, tier, item, recipeType, recipe); + } + + @Override + public AndroidType getAndroidType() { + return getTier() == 1 ? AndroidType.FARMER : AndroidType.ADVANCED_FARMER; + } + + @Override + protected void farm(Block b, BlockMenu menu, Block block, boolean isAdvanced) { + Material blockType = block.getType(); + Object data = BlockDataCompat.getBlockData(block); + ItemStack drop = null; + + // WorldBorder#isInside(Location) is 1.20.4+; on older servers treat the location as inside. + Object inside = ReflectionCompat.invoke(block.getWorld().getWorldBorder(), "isInside", block.getLocation()); + if (Boolean.FALSE.equals(inside)) { + return; + } + + if (BlockDataCompat.isInstance(data, "org.bukkit.block.data.Ageable") + && BlockDataCompat.getInt(data, "getAge") >= BlockDataCompat.getInt(data, "getMaximumAge")) { + drop = getDropFromCrop(blockType); + } + + AndroidInstance instance = new AndroidInstance(this, b); + + AndroidFarmEvent event = new AndroidFarmEvent(block, instance, isAdvanced, drop); + Bukkit.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + drop = event.getDrop(); + + if (drop != null && menu.pushItem(drop, getOutputSlots()) == null) { + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, blockType); + + if (BlockDataCompat.isInstance(data, "org.bukkit.block.data.Ageable")) { + BlockDataCompat.set(data, "setAge", 0); + BlockDataCompat.setBlockData(block, data); + } + } + } + } + + private ItemStack getDropFromCrop(Material crop) { + Random random = ThreadLocalRandom.current(); + + // Java-8 universal port: switch labels for crops added after 1.8 (POTATOES, CARROTS, + // BEETROOTS, NETHER_WART, SWEET_BERRY_BUSH) do not exist on the 1.8.8 enum, so we compare + // against XMaterial-resolved constants instead. parseMaterial() yields null on versions + // lacking the crop, which simply never matches the (non-null) block material. + if (crop == XMaterial.WHEAT.parseMaterial()) { + return new ItemStack(Material.WHEAT, random.nextInt(2) + 1); + } else if (crop == XMaterial.POTATOES.parseMaterial()) { + return new ItemStack(Material.POTATO, random.nextInt(3) + 1); + } else if (crop == XMaterial.CARROTS.parseMaterial()) { + return new ItemStack(Material.CARROT, random.nextInt(3) + 1); + } else if (crop == XMaterial.BEETROOTS.parseMaterial()) { + return MaterialCompat.stack(XMaterial.BEETROOT, random.nextInt(3) + 1); + } else if (crop == XMaterial.COCOA.parseMaterial()) { + return MaterialCompat.stack(XMaterial.COCOA_BEANS, random.nextInt(3) + 1); + } else if (crop == XMaterial.NETHER_WART.parseMaterial()) { + return MaterialCompat.stack(XMaterial.NETHER_WART, random.nextInt(3) + 1); + } else if (crop == XMaterial.SWEET_BERRY_BUSH.parseMaterial()) { + return MaterialCompat.stack(XMaterial.SWEET_BERRIES, random.nextInt(3) + 1); + } else { + return null; + } + } + +} + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/FishermanAndroid.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/FishermanAndroid.java index a6ce80e2fe..da13c6e4e6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/FishermanAndroid.java @@ -1,22 +1,24 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.collections.RandomizedSet; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class FishermanAndroid extends ProgrammableAndroid { @@ -34,17 +36,17 @@ public FishermanAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, R // Junk fishingLoot.add(new ItemStack(Material.BONE), 10); fishingLoot.add(new ItemStack(Material.STRING), 10); - fishingLoot.add(new ItemStack(Material.INK_SAC), 8); - fishingLoot.add(new ItemStack(Material.KELP), 6); + fishingLoot.add(MaterialCompat.stack(XMaterial.INK_SAC), 8); + fishingLoot.add(MaterialCompat.stack(XMaterial.KELP), 6); fishingLoot.add(new ItemStack(Material.STICK), 5); fishingLoot.add(new ItemStack(Material.ROTTEN_FLESH), 3); fishingLoot.add(new ItemStack(Material.LEATHER), 2); - fishingLoot.add(new ItemStack(Material.BAMBOO), 3); + fishingLoot.add(MaterialCompat.stack(XMaterial.BAMBOO), 3); // "loot" fishingLoot.add(new ItemStack(Material.SADDLE), 1); fishingLoot.add(new ItemStack(Material.NAME_TAG), 1); - fishingLoot.add(new ItemStack(Material.NAUTILUS_SHELL), 1); + fishingLoot.add(MaterialCompat.stack(XMaterial.NAUTILUS_SHELL), 1); } @Override @@ -66,3 +68,4 @@ protected void fish(Block b, BlockMenu menu) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/Instruction.java similarity index 98% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/Instruction.java index 03fba08cff..b2719627ca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/Instruction.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; import java.util.HashMap; import java.util.Map; @@ -18,8 +18,8 @@ import org.bukkit.entity.Monster; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -303,3 +303,4 @@ public static Instruction getInstruction(@Nonnull String value) { return nameLookup.get(value); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/MinerAndroid.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/MinerAndroid.java index 8d041bafb5..153dbf0b05 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/MinerAndroid.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.WorldCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import java.util.Collection; import java.util.UUID; @@ -15,16 +19,16 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.InfiniteBlockGenerator; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.events.AndroidMineEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.InfiniteBlockGenerator; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -126,7 +130,7 @@ protected void moveAndDig(Block b, BlockMenu menu, BlockFace face, Block block) @ParametersAreNonnullByDefault private void breakBlock(BlockMenu menu, Collection drops, Block block) { - if (!block.getWorld().getWorldBorder().isInside(block.getLocation())) { + if (!WorldCompat.isInside(block.getWorld(), block.getLocation())) { return; } @@ -149,7 +153,7 @@ private void breakBlock(BlockMenu menu, Collection drops, Block block // "poof" a "new" block was generated SoundEffect.MINER_ANDROID_BLOCK_GENERATION_SOUND.playAt(block); - block.getWorld().spawnParticle(VersionedParticle.SMOKE, block.getX() + 0.5, block.getY() + 1.25, block.getZ() + 0.5, 8, 0.5, 0.5, 0.5, 0.015); + ParticleCompat.spawn(block.getWorld(), VersionedParticle.SMOKE, block.getX() + 0.5, block.getY() + 1.25, block.getZ() + 0.5, 8, 0.5, 0.5, 0.5, 0.015); } else { block.setType(Material.AIR); } @@ -159,3 +163,4 @@ private void breakBlock(BlockMenu menu, Collection drops, Block block } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/ProgrammableAndroid.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/ProgrammableAndroid.java index 669327a9bf..5d703e301d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/ProgrammableAndroid.java @@ -1,5 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.WorldCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -14,13 +18,12 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Rotatable; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; @@ -34,22 +37,21 @@ import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.bakedlibs.dough.skins.PlayerHead; -import io.github.bakedlibs.dough.skins.PlayerSkin; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPlayerHead; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; @@ -61,6 +63,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, RecipeDisplayItem { @@ -148,16 +151,12 @@ public void onPlayerPlace(BlockPlaceEvent e) { BlockStorage.addBlockInfo(b, "script", DEFAULT_SCRIPT); BlockStorage.addBlockInfo(b, "index", "0"); BlockStorage.addBlockInfo(b, "fuel", "0"); - BlockStorage.addBlockInfo(b, "rotation", p.getFacing().getOppositeFace().toString()); + BlockStorage.addBlockInfo(b, "rotation", EntityCompat.getFacing(p).getOppositeFace().toString()); BlockStorage.addBlockInfo(b, "paused", "true"); - BlockData blockData = Material.PLAYER_HEAD.createBlockData(data -> { - if (data instanceof Rotatable rotatable) { - rotatable.setRotation(p.getFacing()); - } - }); + Object blockData = BlockDataCompat.createBlockData(XMaterial.PLAYER_HEAD.parseMaterial(), data -> BlockDataCompat.set(data, "setRotation", EntityCompat.getFacing(p))); - b.setBlockData(blockData); + BlockDataCompat.setBlockData(b, blockData); } }; } @@ -203,12 +202,16 @@ public AndroidType getAndroidType() { * @return The required type of fuel */ public AndroidFuelSource getFuelSource() { - return switch (getTier()) { - case 1 -> AndroidFuelSource.SOLID; - case 2 -> AndroidFuelSource.LIQUID; - case 3 -> AndroidFuelSource.NUCLEAR; - default -> throw new IllegalStateException("Cannot convert the following Android tier to a fuel type: " + getTier()); - }; + switch (getTier()) { + case 1: + return AndroidFuelSource.SOLID; + case 2: + return AndroidFuelSource.LIQUID; + case 3: + return AndroidFuelSource.NUCLEAR; + default: + throw new IllegalStateException("Cannot convert the following Android tier to a fuel type: " + getTier()); + } } @Override @@ -594,15 +597,15 @@ public void setScript(@Nonnull Location l, @Nonnull String script) { private void registerDefaultFuelTypes() { switch (getFuelSource()) { - case SOLID -> { + case SOLID: { registerFuelType(new MachineFuel(80, new ItemStack(Material.COAL_BLOCK))); registerFuelType(new MachineFuel(45, new ItemStack(Material.BLAZE_ROD))); - registerFuelType(new MachineFuel(70, new ItemStack(Material.DRIED_KELP_BLOCK))); + registerFuelType(new MachineFuel(70, MaterialCompat.stack(XMaterial.DRIED_KELP_BLOCK))); // Coal, Charcoal & Bamboo registerFuelType(new MachineFuel(8, new ItemStack(Material.COAL))); - registerFuelType(new MachineFuel(8, new ItemStack(Material.CHARCOAL))); - registerFuelType(new MachineFuel(1, new ItemStack(Material.BAMBOO))); + registerFuelType(new MachineFuel(8, MaterialCompat.stack(XMaterial.CHARCOAL))); + registerFuelType(new MachineFuel(1, MaterialCompat.stack(XMaterial.BAMBOO))); // Logs for (Material mat : Tag.LOGS.getValues()) { @@ -613,18 +616,25 @@ private void registerDefaultFuelTypes() { for (Material mat : Tag.PLANKS.getValues()) { registerFuelType(new MachineFuel(1, new ItemStack(mat))); } + + break; } - case LIQUID -> { + case LIQUID: { registerFuelType(new MachineFuel(100, new ItemStack(Material.LAVA_BUCKET))); registerFuelType(new MachineFuel(200, SlimefunItems.OIL_BUCKET)); registerFuelType(new MachineFuel(500, SlimefunItems.FUEL_BUCKET)); + + break; } - case NUCLEAR -> { + case NUCLEAR: { registerFuelType(new MachineFuel(2500, SlimefunItems.URANIUM)); registerFuelType(new MachineFuel(1200, SlimefunItems.NEPTUNIUM)); registerFuelType(new MachineFuel(3000, SlimefunItems.BOOSTED_URANIUM)); + + break; } - default -> throw new IllegalStateException("Unhandled Fuel Source: " + getFuelSource()); + default: + throw new IllegalStateException("Unhandled Fuel Source: " + getFuelSource()); } } @@ -671,7 +681,7 @@ public int getTier() { } protected void tick(Block b, Config data) { - if (b.getType() != Material.PLAYER_HEAD) { + if (b.getType() != XMaterial.PLAYER_HEAD.parseMaterial()) { // The Android was destroyed or moved. return; } @@ -750,13 +760,9 @@ protected void rotate(Block b, BlockFace current, int mod) { BlockFace rotation = POSSIBLE_ROTATIONS.get(index); - BlockData blockData = Material.PLAYER_HEAD.createBlockData(data -> { - if (data instanceof Rotatable rotatable) { - rotatable.setRotation(rotation.getOppositeFace()); - } - }); + Object blockData = BlockDataCompat.createBlockData(XMaterial.PLAYER_HEAD.parseMaterial(), data -> BlockDataCompat.set(data, "setRotation", rotation.getOppositeFace())); - b.setBlockData(blockData); + BlockDataCompat.setBlockData(b, blockData); BlockStorage.addBlockInfo(b, "rotation", rotation.name()); } @@ -764,8 +770,8 @@ protected void depositItems(BlockMenu menu, Block facedBlock) { if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_ITEMS")) { BlockState state = PaperLib.getBlockState(facedBlock, false).getState(); - if (state instanceof Dispenser dispenser) { - for (int slot : getOutputSlots()) { + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; for (int slot : getOutputSlots()) { ItemStack stack = menu.getItemInSlot(slot); if (stack != null) { @@ -786,8 +792,8 @@ protected void refuel(BlockMenu menu, Block facedBlock) { if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_FUEL")) { BlockState state = PaperLib.getBlockState(facedBlock, false).getState(); - if (state instanceof Dispenser dispenser) { - for (int slot = 0; slot < 9; slot++) { + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; for (int slot = 0; slot < 9; slot++) { ItemStack item = dispenser.getInventory().getItem(slot); if (item != null) { @@ -865,26 +871,21 @@ public void addItems(Block b, ItemStack... items) { @ParametersAreNonnullByDefault protected void move(Block b, BlockFace face, Block block) { - if (block.getY() > block.getWorld().getMinHeight() && block.getY() < block.getWorld().getMaxHeight() && block.isEmpty()) { + if (block.getY() > WorldCompat.getMinHeight(block.getWorld()) && block.getY() < block.getWorld().getMaxHeight() && block.isEmpty()) { - if (!block.getWorld().getWorldBorder().isInside(block.getLocation())) { + if (!WorldCompat.isInside(block.getWorld(), block.getLocation())) { return; } - BlockData blockData = Material.PLAYER_HEAD.createBlockData(data -> { - if (data instanceof Rotatable rotatable) { - rotatable.setRotation(face.getOppositeFace()); - } - }); + Object blockData = BlockDataCompat.createBlockData(XMaterial.PLAYER_HEAD.parseMaterial(), data -> BlockDataCompat.set(data, "setRotation", face.getOppositeFace())); - block.setBlockData(blockData); + BlockDataCompat.setBlockData(block, blockData); Slimefun.runSync(() -> { - PlayerSkin skin = PlayerSkin.fromBase64(texture); Material type = block.getType(); // Ensure that this Block is still a Player Head - if (type == Material.PLAYER_HEAD || type == Material.PLAYER_WALL_HEAD) { - PlayerHead.setSkin(block, skin, true); + if (type == XMaterial.PLAYER_HEAD.parseMaterial() || type == XMaterial.PLAYER_WALL_HEAD.parseMaterial()) { + VersionedPlayerHead.setSkin(block, texture, true); } }); @@ -918,3 +919,4 @@ protected void farm(Block b, BlockMenu menu, Block block, boolean isAdvanced) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/Script.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/Script.java index bdb647b5cd..b4af186e65 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/Script.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; import java.io.File; import java.util.ArrayList; @@ -21,9 +21,9 @@ import io.github.bakedlibs.dough.config.Config; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; /** * A {@link Script} represents runnable code for a {@link ProgrammableAndroid}. @@ -266,3 +266,4 @@ public static void upload(Player p, AndroidType androidType, int id, String name } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/WoodcutterAndroid.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/WoodcutterAndroid.java new file mode 100644 index 0000000000..1c95f7605a --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/WoodcutterAndroid.java @@ -0,0 +1,151 @@ +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.WorldCompat; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.function.Predicate; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Bukkit; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.inventory.ItemStack; + +import io.github.bakedlibs.dough.blocks.Vein; +import io.github.bakedlibs.dough.protection.Interaction; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; + +import me.mrCookieSlime.Slimefun.api.BlockStorage; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; + +public class WoodcutterAndroid extends ProgrammableAndroid { + + private static final int MAX_REACH = 160; + + /* + * Maps each (flattened 1.13+) log/wood material NAME to its sapling material NAME and the soil tag it + * needs to replant on. Resolved by name at runtime (see replant) so that server versions lacking a + * given material simply skip it — the universal-jar approach to the 1.13 "flattening". + */ + private static final Map LOG_TO_SAPLING = new HashMap<>(); + private static final Map LOG_TO_SOIL = new HashMap<>(); + + private static void registerTree(String saplingName, SlimefunTag soil, String... logNames) { + for (String logName : logNames) { + LOG_TO_SAPLING.put(logName, saplingName); + LOG_TO_SOIL.put(logName, soil); + } + } + + static { + registerTree("OAK_SAPLING", SlimefunTag.DIRT_VARIANTS, "OAK_LOG", "OAK_WOOD", "STRIPPED_OAK_LOG", "STRIPPED_OAK_WOOD"); + registerTree("BIRCH_SAPLING", SlimefunTag.DIRT_VARIANTS, "BIRCH_LOG", "BIRCH_WOOD", "STRIPPED_BIRCH_LOG", "STRIPPED_BIRCH_WOOD"); + registerTree("JUNGLE_SAPLING", SlimefunTag.DIRT_VARIANTS, "JUNGLE_LOG", "JUNGLE_WOOD", "STRIPPED_JUNGLE_LOG", "STRIPPED_JUNGLE_WOOD"); + registerTree("SPRUCE_SAPLING", SlimefunTag.DIRT_VARIANTS, "SPRUCE_LOG", "SPRUCE_WOOD", "STRIPPED_SPRUCE_LOG", "STRIPPED_SPRUCE_WOOD"); + registerTree("ACACIA_SAPLING", SlimefunTag.DIRT_VARIANTS, "ACACIA_LOG", "ACACIA_WOOD", "STRIPPED_ACACIA_LOG", "STRIPPED_ACACIA_WOOD"); + registerTree("DARK_OAK_SAPLING", SlimefunTag.DIRT_VARIANTS, "DARK_OAK_LOG", "DARK_OAK_WOOD", "STRIPPED_DARK_OAK_LOG", "STRIPPED_DARK_OAK_WOOD"); + registerTree("CRIMSON_FUNGUS", SlimefunTag.FUNGUS_SOIL, "CRIMSON_STEM", "CRIMSON_HYPHAE", "STRIPPED_CRIMSON_STEM", "STRIPPED_CRIMSON_HYPHAE"); + registerTree("WARPED_FUNGUS", SlimefunTag.FUNGUS_SOIL, "WARPED_STEM", "WARPED_HYPHAE", "STRIPPED_WARPED_STEM", "STRIPPED_WARPED_HYPHAE"); + registerTree("MANGROVE_PROPAGULE", SlimefunTag.MANGROVE_BASE_BLOCKS, "MANGROVE_LOG", "STRIPPED_MANGROVE_LOG"); + registerTree("CHERRY_SAPLING", SlimefunTag.DIRT_VARIANTS, "CHERRY_LOG", "STRIPPED_CHERRY_LOG"); + registerTree("PALE_OAK_SAPLING", SlimefunTag.DIRT_VARIANTS, "PALE_OAK_LOG", "PALE_OAK_WOOD", "STRIPPED_PALE_OAK_LOG", "STRIPPED_PALE_OAK_WOOD"); + } + + @ParametersAreNonnullByDefault + public WoodcutterAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(itemGroup, tier, item, recipeType, recipe); + } + + @Override + public AndroidType getAndroidType() { + return AndroidType.WOODCUTTER; + } + + @Override + protected boolean chopTree(Block b, BlockMenu menu, BlockFace face) { + Block target = b.getRelative(face); + + if (!WorldCompat.isInside(target.getWorld(), target.getLocation())) { + return true; + } + + if (Tag.LOGS.isTagged(target.getType())) { + List list = Vein.find(target, MAX_REACH, block -> Tag.LOGS.isTagged(block.getType())); + + if (!list.isEmpty()) { + Block log = list.get(list.size() - 1); + log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType()); + + OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))); + if (Slimefun.getProtectionManager().hasPermission(owner, log.getLocation(), Interaction.BREAK_BLOCK)) { + breakLog(log, b, menu, face); + } + + return false; + } + } + + return true; + } + + @ParametersAreNonnullByDefault + private void breakLog(Block log, Block android, BlockMenu menu, BlockFace face) { + ItemStack drop = new ItemStack(log.getType()); + + // We try to push the log into the android's inventory, but nothing happens if it does not fit + menu.pushItem(drop, getOutputSlots()); + + log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType()); + + // If the android just chopped the bottom log, we replant the appropriate sapling + if (log.getY() == android.getRelative(face).getY()) { + replant(log); + } else { + log.setType(Material.AIR); + } + } + + private void replant(@Nonnull Block block) { + Material logType = block.getType(); + Material saplingType = null; + Predicate soilRequirement = null; + + // Version-safe lookup: resolve the sapling Material by name so server versions that lack a given + // flattened (1.13+) material simply skip it instead of failing to load. Replaces the previous + // switch-on-Material, whose case labels referenced enum constants absent on the Java-8/1.8 floor. + String saplingName = LOG_TO_SAPLING.get(logType.name()); + SlimefunTag soilTag = LOG_TO_SOIL.get(logType.name()); + + if (saplingName != null && soilTag != null) { + saplingType = Material.getMaterial(saplingName); + soilRequirement = soilTag::isTagged; + } + + if (saplingType != null && soilRequirement != null) { + if (soilRequirement.test(block.getRelative(BlockFace.DOWN).getType())) { + // Replant the block + block.setType(saplingType); + } else { + // Simply drop the sapling if the soil does not fit + block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(saplingType)); + block.setType(Material.AIR); + } + } + } + +} + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/package-info.java new file mode 100644 index 0000000000..d39e81d44d --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/androids/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are related to the {@link io.github.thebusybiscuit.slimefun5.implementation.items.androids.ProgrammableAndroid}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.androids; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/ElytraCap.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/ElytraCap.java index 59ae6670a5..23e471eead 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/ElytraCap.java @@ -1,23 +1,23 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.GameMode; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraImpactListener; -import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectiveArmor; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.ElytraImpactListener; +import io.github.thebusybiscuit.slimefun5.utils.UnbreakingAlgorithm; /** * The {@link ElytraCap} negates damage taken when crashing into a wall using an elytra. @@ -71,3 +71,4 @@ public NamespacedKey getArmorSetId() { return key; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/EnderBoots.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/EnderBoots.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/EnderBoots.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/EnderBoots.java index 13bf9cf315..75e0ea25ca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/EnderBoots.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/EnderBoots.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.entity.EnderPearl; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; /** * {@link EnderBoots} are a pair of boots which negate damage caused @@ -24,3 +24,4 @@ public EnderBoots(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe super(itemGroup, item, recipeType, recipe); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/FarmerShoes.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/FarmerShoes.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/FarmerShoes.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/FarmerShoes.java index 86bf5bbc1a..45598f065f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/FarmerShoes.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/FarmerShoes.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,10 +6,10 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; /** * The {@link FarmerShoes} are just a simple pair of boots which allows a {@link Player} to walk @@ -26,3 +26,4 @@ public FarmerShoes(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recip } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/HazmatArmorPiece.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/HazmatArmorPiece.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/HazmatArmorPiece.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/HazmatArmorPiece.java index d3ed9916da..f294b01a30 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/HazmatArmorPiece.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/HazmatArmorPiece.java @@ -1,17 +1,17 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectiveArmor; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * Represents 1 {@link SlimefunArmorPiece} of the Hazmat armor set. @@ -51,3 +51,4 @@ public NamespacedKey getArmorSetId() { return namespacedKey; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/LongFallBoots.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/LongFallBoots.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/LongFallBoots.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/LongFallBoots.java index 7872d93bb7..9555a60f7e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/LongFallBoots.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/LongFallBoots.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,10 +6,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; /** * {@link LongFallBoots} are a pair of boots which negate fall damage. @@ -50,3 +50,4 @@ public SoundEffect getSoundEffect() { return soundEffect; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/Parachute.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/Parachute.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/Parachute.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/Parachute.java index 5efec631ce..1563cd564f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/Parachute.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/Parachute.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.ParachuteTask; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.Jetpack; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.ParachuteTask; /** * The {@link Parachute} is a {@link SlimefunItem} that can be equipped as a chestplate. @@ -32,3 +32,4 @@ public Parachute(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeT } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/RainbowArmorPiece.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/RainbowArmorPiece.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/RainbowArmorPiece.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/RainbowArmorPiece.java index 10a5030b5d..54420a6933 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/RainbowArmorPiece.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/RainbowArmorPiece.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import java.util.Arrays; @@ -11,10 +11,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * Represents a {@link SlimefunArmorPiece} with rainbow properties (leather armor changing color). @@ -60,3 +60,4 @@ public RainbowArmorPiece(ItemGroup itemGroup, SlimefunItemStack item, RecipeType } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/SlimefunArmorPiece.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/SlimefunArmorPiece.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/SlimefunArmorPiece.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/SlimefunArmorPiece.java index 8ed493f066..dd13fbb6d2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/SlimefunArmorPiece.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/SlimefunArmorPiece.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,10 +7,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; public class SlimefunArmorPiece extends SlimefunItem { @@ -33,3 +33,4 @@ public PotionEffect[] getPotionEffects() { return effects; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/StomperBoots.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/StomperBoots.java index 726b359181..53a0af3d0e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/StomperBoots.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -18,12 +18,13 @@ import org.bukkit.util.Vector; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; /** * The Boots of the Stomper are boots which damage nearby enemies whenever the {@link Player} @@ -51,7 +52,8 @@ public void stomp(@Nonnull EntityDamageEvent fallDamageEvent) { player.setVelocity(new Vector(0, 0.7, 0)); for (Entity entity : player.getNearbyEntities(4, 4, 4)) { - if (entity instanceof LivingEntity livingEntity && canPush(player, livingEntity)) { + if (entity instanceof LivingEntity && canPush(player, (LivingEntity) entity)) { + LivingEntity livingEntity = (LivingEntity) entity; Vector velocity = getShockwave(player.getLocation(), entity.getLocation()); entity.setVelocity(velocity); @@ -108,6 +110,9 @@ protected Vector getShockwave(@Nonnull Location origin, @Nonnull Location target * @return If the entity can move. */ protected boolean canPush(@Nonnull Player player, @Nonnull LivingEntity entity) { - return entity.isValid() && !entity.getUniqueId().equals(player.getUniqueId()) && entity.isCollidable() && entity.hasGravity(); + return entity.isValid() && !entity.getUniqueId().equals(player.getUniqueId()) + && !Boolean.FALSE.equals(ReflectionCompat.invoke(entity, "isCollidable")) + && !Boolean.FALSE.equals(ReflectionCompat.invoke(entity, "hasGravity")); } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/package-info.java new file mode 100644 index 0000000000..c4c8712329 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/armor/package-info.java @@ -0,0 +1,6 @@ +/** + * This package contains implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} that are + * related to armor, such as the expandable + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece} class for example. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.armor; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/AbstractAutoCrafter.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/AbstractAutoCrafter.java index 4186291716..601cd42c7b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractAutoCrafter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/AbstractAutoCrafter.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import java.util.ArrayList; import java.util.HashMap; @@ -13,7 +17,8 @@ import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -26,22 +31,22 @@ import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemState; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AutoCrafterListener; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemState; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.AutoCrafterListener; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AsyncRecipeChoiceTask; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import io.papermc.lib.PaperLib; import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult; @@ -174,13 +179,14 @@ protected void tick(@Nonnull Block b, @Nonnull Config data) { if (isValidInventory(targetBlock)) { BlockState state = PaperLib.getBlockState(targetBlock, false).getState(); - if (state instanceof InventoryHolder inventoryHolder) { + if (state instanceof InventoryHolder) { + InventoryHolder inventoryHolder = (InventoryHolder) state; Inventory inv = inventoryHolder.getInventory(); if (craft(inv, recipe)) { // We are done crafting! Location loc = b.getLocation().add(0.5, 0.8, 0.5); - b.getWorld().spawnParticle(VersionedParticle.HAPPY_VILLAGER, loc, 6); + ParticleCompat.spawn(b.getWorld(), VersionedParticle.HAPPY_VILLAGER, loc, 6); removeCharge(b.getLocation(), getEnergyConsumption()); } } @@ -243,16 +249,17 @@ protected void setSelectedRecipe(@Nonnull Block b, @Nullable AbstractRecipe reci BlockStateSnapshotResult result = PaperLib.getBlockState(b, false); BlockState state = result.getState(); - if (state instanceof Skull skull) { + if (state instanceof Skull) { + Skull skull = (Skull) state; if (recipe == null) { // Clear the value from persistent data storage - PersistentDataAPI.remove(skull, recipeStorageKey); + PdcCompat.remove(skull, recipeStorageKey); // Also remove the "enabled" state since this should be per-recipe. - PersistentDataAPI.remove(skull, recipeEnabledKey); + PdcCompat.remove(skull, recipeEnabledKey); } else { // Store the value to persistent data storage - PersistentDataAPI.setString(skull, recipeStorageKey, recipe.toString()); + PdcCompat.setString(skull, recipeStorageKey, recipe.toString()); } // Fixes #2899 - Update the BlockState if necessary @@ -329,12 +336,13 @@ private void setRecipeEnabled(Player p, Block b, boolean enabled) { BlockState state = PaperLib.getBlockState(b, false).getState(); // Make sure the block is still a Skull - if (state instanceof Skull skull) { + if (state instanceof Skull) { + Skull skull = (Skull) state; if (enabled) { - PersistentDataAPI.remove(skull, recipeEnabledKey); + PdcCompat.remove(skull, recipeEnabledKey); Slimefun.getLocalization().sendMessage(p, "messages.auto-crafting.re-enabled"); } else { - PersistentDataAPI.setByte(skull, recipeEnabledKey, (byte) 1); + PdcCompat.setByte(skull, recipeEnabledKey, (byte) 1); Slimefun.getLocalization().sendMessage(p, "messages.auto-crafting.temporarily-disabled"); } } @@ -471,15 +479,20 @@ public boolean craft(@Nonnull Inventory inv, @Nonnull AbstractRecipe recipe) { private ItemStack getLeftoverItem(@Nonnull ItemStack item) { Material type = item.getType(); - return switch (type) { - case WATER_BUCKET, - LAVA_BUCKET, - MILK_BUCKET -> new ItemStack(Material.BUCKET); - case DRAGON_BREATH, - POTION, - HONEY_BOTTLE -> new ItemStack(Material.GLASS_BOTTLE); - default -> null; - }; + // DRAGON_BREATH (1.9+) and HONEY_BOTTLE (1.15+) are absent on the 1.8.8 enum, so the original + // grouped switch becomes XMaterial comparisons. parseMaterial() yields null on versions lacking + // a constant, which never matches the (non-null) item material. + if (type == XMaterial.WATER_BUCKET.parseMaterial() + || type == XMaterial.LAVA_BUCKET.parseMaterial() + || type == XMaterial.MILK_BUCKET.parseMaterial()) { + return new ItemStack(Material.BUCKET); + } else if (type == XMaterial.DRAGON_BREATH.parseMaterial() + || type == XMaterial.POTION.parseMaterial() + || type == XMaterial.HONEY_BOTTLE.parseMaterial()) { + return new ItemStack(Material.GLASS_BOTTLE); + } else { + return null; + } } /** @@ -566,3 +579,4 @@ public final EnergyNetComponentType getEnergyComponentType() { return EnergyNetComponentType.CONSUMER; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/AbstractRecipe.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/AbstractRecipe.java index 12cef3cf9a..8817fab0d6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/AbstractRecipe.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/AbstractRecipe.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; import java.util.Collection; import java.util.function.Predicate; @@ -14,10 +14,10 @@ import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.EnhancedCraftingTable; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.EnhancedCraftingTable; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AsyncRecipeChoiceTask; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -136,10 +136,10 @@ public void setEnabled(boolean enabled) { */ @Nullable public static AbstractRecipe of(@Nullable Recipe recipe) { - if (recipe instanceof ShapedRecipe shapedRecipe) { - return new VanillaRecipe(shapedRecipe); - } else if (recipe instanceof ShapelessRecipe shapelessRecipe) { - return new VanillaRecipe(shapelessRecipe); + if (recipe instanceof ShapedRecipe) { + ShapedRecipe shapedRecipe = (ShapedRecipe) recipe; return new VanillaRecipe(shapedRecipe); + } else if (recipe instanceof ShapelessRecipe) { + ShapelessRecipe shapelessRecipe = (ShapelessRecipe) recipe; return new VanillaRecipe(shapelessRecipe); } else { return null; } @@ -167,3 +167,4 @@ public static AbstractRecipe of(@Nullable SlimefunItem item, @Nonnull RecipeType } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/ArmorAutoCrafter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/ArmorAutoCrafter.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/ArmorAutoCrafter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/ArmorAutoCrafter.java index 195e3fa682..bfbb975934 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/ArmorAutoCrafter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/ArmorAutoCrafter.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.ArmorForge; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.ArmorForge; /** * The {@link ArmorAutoCrafter} is an implementation of the {@link AbstractAutoCrafter}. @@ -29,3 +29,4 @@ public ArmorAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/EnhancedAutoCrafter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/EnhancedAutoCrafter.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/EnhancedAutoCrafter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/EnhancedAutoCrafter.java index a3bc793540..2f37a97e3a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/EnhancedAutoCrafter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/EnhancedAutoCrafter.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.EnhancedCraftingTable; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AutoCrafterListener; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.EnhancedCraftingTable; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.AutoCrafterListener; /** * The {@link EnhancedAutoCrafter} is an implementation of the {@link AbstractAutoCrafter}. @@ -30,3 +30,4 @@ public EnhancedAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeTy } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/SlimefunAutoCrafter.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/SlimefunAutoCrafter.java index d6b730b981..ff8c542071 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunAutoCrafter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/SlimefunAutoCrafter.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -7,6 +11,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Skull; @@ -16,14 +21,14 @@ import org.bukkit.persistence.PersistentDataType; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AsyncRecipeChoiceTask; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -60,14 +65,13 @@ public AbstractRecipe getSelectedRecipe(@Nonnull Block b) { BlockState state = PaperLib.getBlockState(b, false).getState(); - if (state instanceof Skull skull) { - // Read the stored value from persistent data storage - PersistentDataContainer container = skull.getPersistentDataContainer(); - String value = container.get(recipeStorageKey, PersistentDataType.STRING); + if (state instanceof Skull) { + Skull skull = (Skull) state; // Read the stored value from persistent data storage + String value = (String) PdcCompat.get(skull, recipeStorageKey, "STRING"); SlimefunItem item = SlimefunItem.getById(value); if (item != null) { - boolean enabled = !container.has(recipeEnabledKey, PersistentDataType.BYTE); + boolean enabled = !PdcCompat.has(skull, recipeEnabledKey, "BYTE"); AbstractRecipe recipe = AbstractRecipe.of(item, targetRecipeType); recipe.setEnabled(enabled); return recipe; @@ -79,7 +83,7 @@ public AbstractRecipe getSelectedRecipe(@Nonnull Block b) { @Override protected void updateRecipe(@Nonnull Block b, @Nonnull Player p) { - ItemStack itemInHand = p.getInventory().getItemInMainHand(); + ItemStack itemInHand = HandCompat.getMainHand(p.getInventory()); SlimefunItem item = SlimefunItem.getByItem(itemInHand); if (item != null && item.getRecipeType().equals(targetRecipeType)) { @@ -95,7 +99,7 @@ protected void updateRecipe(@Nonnull Block b, @Nonnull Player p) { ChestMenuUtils.drawBackground(menu, background); ChestMenuUtils.drawBackground(menu, 45, 46, 47, 48, 50, 51, 52, 53); - menu.addItem(49, CustomItemStack.create(Material.CRAFTING_TABLE, ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select"))); + menu.addItem(49, CustomItemStack.create(XMaterial.CRAFTING_TABLE.parseMaterial(), ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select"))); menu.addMenuClickHandler(49, (pl, stack, slot, action) -> { setSelectedRecipe(b, recipe); SoundEffect.AUTO_CRAFTER_UPDATE_RECIPE.playAt(b); @@ -122,3 +126,4 @@ protected void updateRecipe(@Nonnull Block b, @Nonnull Player p) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunItemRecipe.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/SlimefunItemRecipe.java similarity index 77% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunItemRecipe.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/SlimefunItemRecipe.java index 32cede3e95..2f6c72db31 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/SlimefunItemRecipe.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/SlimefunItemRecipe.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.ArrayList; import java.util.Collection; @@ -10,11 +12,11 @@ import org.apache.commons.lang.Validate; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AsyncRecipeChoiceTask; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -44,7 +46,7 @@ private static Collection> getInputs(@Nonnull SlimefunItem for (int i = 0; i < 9; i++) { ItemStack ingredient = item.getRecipe()[i]; - if (ingredient != null && !ingredient.getType().isAir()) { + if (ingredient != null && !MaterialCompat.isAir(ingredient.getType())) { predicates.add(stack -> SlimefunUtils.isItemSimilar(stack, ingredient, true)); } } @@ -69,3 +71,4 @@ public String toString() { return item.getId(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/VanillaAutoCrafter.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/VanillaAutoCrafter.java index 5885d99aec..35c7817b67 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaAutoCrafter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/VanillaAutoCrafter.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.List; @@ -11,8 +15,9 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.NamespacedKey; -import org.bukkit.SoundCategory; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Skull; @@ -26,15 +31,15 @@ import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.MinecraftRecipeService; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AsyncRecipeChoiceTask; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -62,10 +67,9 @@ public VanillaAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeTyp public @Nullable AbstractRecipe getSelectedRecipe(@Nonnull Block b) { BlockState state = PaperLib.getBlockState(b, false).getState(); - if (state instanceof Skull skull) { - // Read the stored value from persistent data storage - PersistentDataContainer container = skull.getPersistentDataContainer(); - String value = container.get(recipeStorageKey, PersistentDataType.STRING); + if (state instanceof Skull) { + Skull skull = (Skull) state; // Read the stored value from persistent data storage + String value = (String) PdcCompat.get(skull, recipeStorageKey, "STRING"); if (value != null) { String[] values = CommonPatterns.COLON.split(value); @@ -80,7 +84,7 @@ public VanillaAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeTyp Recipe keyedRecipe = Slimefun.getMinecraftRecipeService().getRecipe(key); if (keyedRecipe != null) { - boolean enabled = !container.has(recipeEnabledKey, PersistentDataType.BYTE); + boolean enabled = !PdcCompat.has(skull, recipeEnabledKey, "BYTE"); AbstractRecipe recipe = AbstractRecipe.of(keyedRecipe); recipe.setEnabled(enabled); @@ -106,7 +110,7 @@ protected boolean matches(@Nonnull ItemStack item, @Nonnull Predicate @Override protected void updateRecipe(@Nonnull Block b, @Nonnull Player p) { - ItemStack item = p.getInventory().getItemInMainHand(); + ItemStack item = HandCompat.getMainHand(p.getInventory()); List recipes = getRecipesFor(item); if (recipes.isEmpty()) { @@ -154,7 +158,7 @@ private void offerRecipe(Player p, Block b, List recipes, int index, Che AbstractRecipe recipe = AbstractRecipe.of(recipes.get(index)); - menu.replaceExistingItem(49, CustomItemStack.create(Material.CRAFTING_TABLE, ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select"))); + menu.replaceExistingItem(49, CustomItemStack.create(XMaterial.CRAFTING_TABLE.parseMaterial(), ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "messages.auto-crafting.select"))); menu.addMenuClickHandler(49, (pl, slot, item, action) -> { setSelectedRecipe(b, recipe); pl.closeInventory(); @@ -186,3 +190,4 @@ private List getRecipesFor(@Nonnull ItemStack item) { return recipes; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/VanillaRecipe.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/VanillaRecipe.java index 0654c4e366..d21a160c6f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/VanillaRecipe.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/VanillaRecipe.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; import java.util.ArrayList; import java.util.Collection; @@ -8,7 +8,7 @@ import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; -import org.bukkit.Keyed; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.RecipeChoice; @@ -16,9 +16,10 @@ import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AsyncRecipeChoiceTask; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.RecipeCompat; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AsyncRecipeChoiceTask; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -37,7 +38,7 @@ class VanillaRecipe extends AbstractRecipe { private final Recipe recipe; VanillaRecipe(@Nonnull ShapelessRecipe recipe) { - super(new ArrayList<>(recipe.getChoiceList()), recipe.getResult()); + super(new ArrayList<>(RecipeCompat.getChoiceList(recipe)), recipe.getResult()); this.recipe = recipe; } @@ -54,7 +55,7 @@ private static Collection> getChoices(@Nonnull ShapedRecipe for (String row : recipe.getShape()) { for (char c : row.toCharArray()) { - RecipeChoice choice = recipe.getChoiceMap().get(c); + RecipeChoice choice = RecipeCompat.getChoiceMap(recipe).get(c); if (choice != null) { choices.add(choice); @@ -81,16 +82,16 @@ public void show(@Nonnull ChestMenu menu, @Nonnull AsyncRecipeChoiceTask task) { RecipeChoice[] choices = Slimefun.getMinecraftRecipeService().getRecipeShape(recipe); ItemStack[] items = new ItemStack[9]; - if (choices.length == 1 && choices[0] instanceof MaterialChoice materialChoice) { - items[4] = new ItemStack(materialChoice.getChoices().get(0)); + if (choices.length == 1 && choices[0] instanceof MaterialChoice) { + MaterialChoice materialChoice = (MaterialChoice) choices[0]; items[4] = new ItemStack(materialChoice.getChoices().get(0)); if (materialChoice.getChoices().size() > 1) { task.add(slots[4], materialChoice); } } else { for (int i = 0; i < choices.length; i++) { - if (choices[i] instanceof MaterialChoice materialChoice) { - items[i] = new ItemStack(materialChoice.getChoices().get(0)); + if (choices[i] instanceof MaterialChoice) { + MaterialChoice materialChoice = (MaterialChoice) choices[i]; items[i] = new ItemStack(materialChoice.getChoices().get(0)); if (materialChoice.getChoices().size() > 1) { task.add(slots[i], materialChoice); @@ -107,10 +108,10 @@ public void show(@Nonnull ChestMenu menu, @Nonnull AsyncRecipeChoiceTask task) { @Override public String toString() { - if (recipe instanceof Keyed keyed) { - return keyed.getKey().toString(); - } else { - return "invalid-recipe"; - } + // recipe is a real org.bukkit Recipe; getKey() (Keyed, 1.12+) is reached reflectively so we + // never reference org.bukkit.Keyed (absent on 1.8-1.11). + Object key = ReflectionCompat.invoke(recipe, "getKey"); + return key != null ? key.toString() : "invalid-recipe"; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/package-info.java similarity index 54% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/package-info.java index 18d6c0deab..8b9b703602 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/package-info.java @@ -1,4 +1,4 @@ /** * This package contains any electric machines related to automatic crafting tables. */ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/Cooler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/Cooler.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/Cooler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/Cooler.java index 94c94097b5..120555ecd9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/Cooler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/Cooler.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks; +package io.github.thebusybiscuit.slimefun5.implementation.items.backpacks; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.Juice; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.CoolerListener; /** * The {@link Cooler} is a special variant of the {@link SlimefunBackpack}. @@ -37,3 +37,4 @@ public boolean isItemAllowed(ItemStack item, SlimefunItem itemAsSlimefunItem) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/EnderBackpack.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/EnderBackpack.java similarity index 61% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/EnderBackpack.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/EnderBackpack.java index 649a63c7be..ff4a0004ca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/EnderBackpack.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/EnderBackpack.java @@ -1,20 +1,19 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks; +package io.github.thebusybiscuit.slimefun5.implementation.items.backpacks; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.block.EnderChest; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link EnderBackpack} is a pretty simple {@link SlimefunItem} which opens your @@ -40,3 +39,4 @@ public EnderBackpack(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/RestoredBackpack.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/RestoredBackpack.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/RestoredBackpack.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/RestoredBackpack.java index a1b62862bd..232ae35ed8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/RestoredBackpack.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/RestoredBackpack.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks; +package io.github.thebusybiscuit.slimefun5.implementation.items.backpacks; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,10 +6,10 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; /** * This class represents a {@link SlimefunBackpack} that has been restored via /sf backpack for retrieving items if the @@ -38,3 +38,4 @@ public RestoredBackpack(@Nonnull ItemGroup itemGroup) { this.hidden = true; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/SlimefunBackpack.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/SlimefunBackpack.java index 4f2a0e3500..2670d0c801 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/SlimefunBackpack.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks; +package io.github.thebusybiscuit.slimefun5.implementation.items.backpacks; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -8,18 +8,18 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.DistinctiveItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.DistinctiveItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BackpackListener; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * This class represents a {@link SlimefunItem} that is considered a Backpack. @@ -96,3 +96,4 @@ public boolean canStack(@Nonnull ItemMeta itemMetaOne, @Nonnull ItemMeta itemMet return !hasLoreItem && !hasLoreSfItem; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SoulboundBackpack.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/SoulboundBackpack.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SoulboundBackpack.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/SoulboundBackpack.java index b320f03b5f..a6a6d74b2c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SoulboundBackpack.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/SoulboundBackpack.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks; +package io.github.thebusybiscuit.slimefun5.implementation.items.backpacks; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Soulbound; /** * This implementation of {@link SlimefunBackpack} is also {@link Soulbound}. @@ -23,3 +23,4 @@ public SoulboundBackpack(int size, ItemGroup itemGroup, SlimefunItemStack item, } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/package-info.java new file mode 100644 index 0000000000..1a1038899c --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds classes related to + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SlimefunBackpack}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.backpacks; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/AbstractMonsterSpawner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/AbstractMonsterSpawner.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/AbstractMonsterSpawner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/AbstractMonsterSpawner.java index d0c24310f4..7f87ed9d8b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/AbstractMonsterSpawner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/AbstractMonsterSpawner.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import java.util.List; import java.util.Locale; @@ -16,11 +16,11 @@ import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; /** * This is a parent class for the {@link BrokenSpawner} and {@link RepairedSpawner} @@ -83,11 +83,11 @@ public ItemStack getItemForEntityType(@Nonnull EntityType type) { ItemMeta meta = item.getItemMeta(); // Fixes #2583 - Proper NBT handling of Spawners - if (meta instanceof BlockStateMeta stateMeta) { - BlockState state = stateMeta.getBlockState(); + if (meta instanceof BlockStateMeta) { + BlockStateMeta stateMeta = (BlockStateMeta) meta; BlockState state = stateMeta.getBlockState(); - if (state instanceof CreatureSpawner spawner) { - spawner.setSpawnedType(type); + if (state instanceof CreatureSpawner) { + CreatureSpawner spawner = (CreatureSpawner) state; spawner.setSpawnedType(type); } stateMeta.setBlockState(state); @@ -110,3 +110,4 @@ public ItemStack getItemForEntityType(@Nonnull EntityType type) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/BlockPlacer.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/BlockPlacer.java index 1e567f803f..6e446ee1b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/BlockPlacer.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import java.util.List; import java.util.UUID; @@ -22,19 +22,20 @@ import org.bukkit.inventory.meta.ItemMeta; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.MaterialTagSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.events.BlockPlacerPlaceEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.MaterialTagSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockDispenseHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.VanillaInventoryDropHandler; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import io.papermc.lib.PaperLib; import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult; @@ -161,7 +162,7 @@ private boolean isAllowed(@Nonnull Block facedBlock, @Nonnull Material type) { * Special case for cakes. * Cakes are a lie but I really want the Block Placer to place them down!!! */ - return !facedBlock.getRelative(BlockFace.DOWN).isPassable(); + return !Boolean.TRUE.equals(ReflectionCompat.invoke(facedBlock.getRelative(BlockFace.DOWN), "isPassable")); } else if (SlimefunTag.BLOCK_PLACER_IGNORED_MATERIALS.isTagged(type)) { /* * Some materials cannot be reliably placed, like beds, @@ -222,8 +223,8 @@ private void placeBlock(ItemStack item, Block facedBlock, Dispenser dispenser) { if (meta.hasDisplayName()) { BlockStateSnapshotResult blockState = PaperLib.getBlockState(facedBlock, false); - if (blockState.getState() instanceof Nameable nameable) { - nameable.setCustomName(meta.getDisplayName()); + if (blockState.getState() instanceof Nameable) { + Nameable nameable = (Nameable) blockState.getState(); nameable.setCustomName(meta.getDisplayName()); if (blockState.isSnapshot()) { // Update block state after changing name @@ -263,3 +264,4 @@ private void schedulePlacement(Block b, Inventory inv, ItemStack item, Runnable }, 2L); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BrokenSpawner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/BrokenSpawner.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BrokenSpawner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/BrokenSpawner.java index df6121194e..f5cc61258d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BrokenSpawner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/BrokenSpawner.java @@ -1,17 +1,17 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; /** * This implementation of {@link SlimefunItem} represents a Broken Spawner. @@ -38,3 +38,4 @@ private ItemUseHandler onRightClick() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/Composter.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/Composter.java index ee0e546090..10bdd2620b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/Composter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import java.util.LinkedList; import java.util.List; @@ -10,7 +10,8 @@ import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -19,15 +20,16 @@ import io.github.bakedlibs.dough.protection.Interaction; import io.github.bakedlibs.dough.scheduling.TaskQueue; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class Composter extends SimpleSlimefunItem implements RecipeDisplayItem { @@ -65,7 +67,7 @@ private List getMachineRecipes() { items.add(new ItemStack(Material.SOUL_SAND)); items.add(new ItemStack(Material.WHEAT, 4)); - items.add(new ItemStack(Material.NETHER_WART)); + items.add(MaterialCompat.stack(XMaterial.NETHER_WART)); return items; } @@ -141,3 +143,4 @@ private ItemStack getOutput(Player p, ItemStack input) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/Crucible.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/Crucible.java index f11e7a35ad..baea9615c3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/Crucible.java @@ -1,4 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import java.util.LinkedList; import java.util.List; @@ -8,29 +13,28 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.Levelled; -import org.bukkit.block.data.Waterlogged; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -77,7 +81,7 @@ private List getMachineRecipes() { items.add(new ItemStack(Material.OBSIDIAN, 1)); items.add(new ItemStack(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.TERRACOTTA, 12)); + items.add(MaterialCompat.stack(XMaterial.TERRACOTTA, 12)); items.add(new ItemStack(Material.LAVA_BUCKET)); for (Material leave : Tag.LEAVES.getValues()) { @@ -90,20 +94,20 @@ private List getMachineRecipes() { items.add(new ItemStack(Material.LAVA_BUCKET)); } - items.add(new ItemStack(Material.BLACKSTONE, 8)); + items.add(MaterialCompat.stack(XMaterial.BLACKSTONE, 8)); items.add(new ItemStack(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.BASALT, 12)); + items.add(MaterialCompat.stack(XMaterial.BASALT, 12)); items.add(new ItemStack(Material.LAVA_BUCKET)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - items.add(new ItemStack(Material.COBBLED_DEEPSLATE, 12)); + items.add(MaterialCompat.stack(XMaterial.COBBLED_DEEPSLATE, 12)); items.add(new ItemStack(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.DEEPSLATE, 10)); + items.add(MaterialCompat.stack(XMaterial.DEEPSLATE, 10)); items.add(new ItemStack(Material.LAVA_BUCKET)); - items.add(new ItemStack(Material.TUFF, 8)); + items.add(MaterialCompat.stack(XMaterial.TUFF, 8)); items.add(new ItemStack(Material.LAVA_BUCKET)); } @@ -165,7 +169,7 @@ private void generateLiquid(@Nonnull Block block, boolean isWater) { // Fixes #2877 - If water in the nether is disabled, abort and play an effect. if (isWater && block.getWorld().getEnvironment() == Environment.NETHER && !allowWaterInNether.getValue()) { // We will still consume the items but won't generate water in the Nether. - block.getWorld().spawnParticle(VersionedParticle.SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 4); + ParticleCompat.spawn(block.getWorld(), VersionedParticle.SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 4); SoundEffect.CRUCIBLE_GENERATE_LIQUID_SOUND.playAt(block); return; } @@ -173,7 +177,7 @@ private void generateLiquid(@Nonnull Block block, boolean isWater) { if (block.getType() == (isWater ? Material.WATER : Material.LAVA)) { addLiquidLevel(block, isWater); } else if (block.getType() == (isWater ? Material.LAVA : Material.WATER)) { - int level = ((Levelled) block.getBlockData()).getLevel(); + int level = BlockDataCompat.getInt(BlockDataCompat.getBlockData(block), "getLevel"); block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE); SoundEffect.CRUCIBLE_GENERATE_LIQUID_SOUND.playAt(block); } else { @@ -182,7 +186,7 @@ private void generateLiquid(@Nonnull Block block, boolean isWater) { } private void addLiquidLevel(@Nonnull Block block, boolean water) { - int level = ((Levelled) block.getBlockData()).getLevel(); + int level = BlockDataCompat.getInt(BlockDataCompat.getBlockData(block), "getLevel"); if (level > 7) { level -= 8; @@ -197,13 +201,14 @@ private void addLiquidLevel(@Nonnull Block block, boolean water) { } private void placeLiquid(@Nonnull Block block, boolean water) { - if (block.getType().isAir()) { + if (MaterialCompat.isAir(block.getType())) { // Fixes #2903 - Cancel physics update to resolve weird overlapping block.setType(water ? Material.WATER : Material.LAVA, false); } else { - if (water && block.getBlockData() instanceof Waterlogged waterlogged) { - waterlogged.setWaterlogged(true); - block.setBlockData(waterlogged, false); + if (water && BlockDataCompat.isInstance(BlockDataCompat.getBlockData(block), "org.bukkit.block.data.Waterlogged")) { + Object waterlogged = BlockDataCompat.getBlockData(block); + BlockDataCompat.set(waterlogged, "setWaterlogged", true); + BlockDataCompat.setBlockData(block, waterlogged, false); SoundEffect.CRUCIBLE_PLACE_WATER_SOUND.playAt(block); return; } @@ -217,15 +222,16 @@ private void placeLiquid(@Nonnull Block block, boolean water) { @ParametersAreNonnullByDefault private void runPostTask(Block block, SoundEffect sound, int times) { - if (!(block.getBlockData() instanceof Levelled le)) { + if (!BlockDataCompat.isInstance(BlockDataCompat.getBlockData(block), "org.bukkit.block.data.Levelled")) { SoundEffect.CRUCIBLE_BLOCK_BREAK_SOUND.playAt(block); return; } + Object le = BlockDataCompat.getBlockData(block); sound.playAt(block); int level = 8 - times; - le.setLevel(level); - block.setBlockData(le, false); + BlockDataCompat.set(le, "setLevel", level); + BlockDataCompat.setBlockData(block, le, false); if (times < 8) { Slimefun.runSync(() -> runPostTask(block, sound, times + 1), 50L); @@ -235,3 +241,4 @@ private void runPostTask(Block block, SoundEffect sound, int times) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/EnhancedFurnace.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/EnhancedFurnace.java index b41cd8904f..1cd07e9fc1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/EnhancedFurnace.java @@ -1,21 +1,22 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nonnull; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Furnace; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.VanillaInventoryDropHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; import io.papermc.lib.PaperLib; import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult; @@ -79,16 +80,18 @@ public BlockTicker getItemHandler() { @Override public void tick(Block b, SlimefunItem item, Config data) { - if (b.getType() != Material.FURNACE) { - // The Furnace has been destroyed, we can clear the block data + if (!MaterialCompat.isVanillaFurnace(b.getType())) { + // The Furnace has been destroyed, we can clear the block data. + // (isVanillaFurnace keeps the lit-furnace material valid on 1.8-1.12, so the speed + // boost still applies while burning instead of wiping the block data.) BlockStorage.clearBlockInfo(b); } else { BlockStateSnapshotResult result = PaperLib.getBlockState(b, false); BlockState state = result.getState(); // Check if the BlockState is a Furnace and cooking something - if (state instanceof Furnace furnace && furnace.getCookTime() > 0) { - setProgress(furnace); + if (state instanceof Furnace && ((Furnace) state).getCookTime() > 0) { + Furnace furnace = (Furnace) state; setProgress(furnace); // Only update if necessary if (result.isSnapshot()) { @@ -109,6 +112,10 @@ public boolean isSynchronized() { private void setProgress(@Nonnull Furnace furnace) { // Update the cooktime int cookTime = furnace.getCookTime() + getProcessingSpeed() * 10; - furnace.setCookTime((short) Math.min(cookTime, furnace.getCookTimeTotal() - 1)); + // Furnace#getCookTimeTotal() is 1.13+; default to the vanilla 200 ticks on older servers. + Object total = ReflectionCompat.invoke(furnace, "getCookTimeTotal"); + int cookTimeTotal = total instanceof Integer ? (Integer) total : 200; + furnace.setCookTime((short) Math.min(cookTime, cookTimeTotal - 1)); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HardenedGlass.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/HardenedGlass.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HardenedGlass.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/HardenedGlass.java index 3fa2150e67..13e5ec9688 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HardenedGlass.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/HardenedGlass.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,10 +6,10 @@ import org.bukkit.entity.WitherSkull; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.WitherProof; /** * {@link HardenedGlass} is a special kind of block which cannot be destroyed by explosions. @@ -29,3 +29,4 @@ public HardenedGlass(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/HologramProjector.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/HologramProjector.java index 640d0d375a..dec2871200 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/HologramProjector.java @@ -1,10 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; @@ -14,20 +15,20 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.utils.ArmorStandUtils; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.holograms.HologramsService; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.utils.ArmorStandUtils; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -119,7 +120,7 @@ private void openEditor(@Nonnull Player p, @Nonnull Block projector) { return false; }); - menu.addItem(1, CustomItemStack.create(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); + menu.addItem(1, CustomItemStack.create(XMaterial.CLOCK.parseMaterial(), "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { double offset = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + (action.isRightClicked() ? -0.1F : 0.1F)); ArmorStand hologram = getArmorStand(projector, true); @@ -140,8 +141,8 @@ private static ArmorStand getArmorStand(@Nonnull Block projector, boolean create Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5); for (Entity n : l.getChunk().getEntities()) { - if (n instanceof ArmorStand armorStand && l.distanceSquared(n.getLocation()) < 0.4) { - String customName = n.getCustomName(); + if (n instanceof ArmorStand && l.distanceSquared(n.getLocation()) < 0.4) { + ArmorStand armorStand = (ArmorStand) n; String customName = n.getCustomName(); if (customName != null && customName.equals(nametag)) { return armorStand; @@ -164,3 +165,4 @@ private static void killArmorStand(@Nonnull Block b) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/IgnitionChamber.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/IgnitionChamber.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/IgnitionChamber.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/IgnitionChamber.java index 50c55891aa..5d6c8131ee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/IgnitionChamber.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/IgnitionChamber.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ItemMetaCompat; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -17,14 +19,14 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.VanillaInventoryDropHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.Smeltery; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -87,7 +89,7 @@ public static boolean useFlintAndSteel(Player p, Block smelteryBlock) { ItemMeta meta = item.getItemMeta(); // Only damage the Flint and Steel if it isn't unbreakable. - if (!meta.isUnbreakable()) { + if (!ItemMetaCompat.isUnbreakable(meta)) { // Update the damage value ((Damageable) meta).setDamage(((Damageable) meta).getDamage() + 1); @@ -116,8 +118,8 @@ public static boolean useFlintAndSteel(Player p, Block smelteryBlock) { if (block.getType() == Material.DROPPER && BlockStorage.check(block) instanceof IgnitionChamber) { BlockState state = PaperLib.getBlockState(b.getRelative(face), false).getState(); - if (state instanceof Dropper dropper) { - return dropper.getInventory(); + if (state instanceof Dropper) { + Dropper dropper = (Dropper) state; return dropper.getInventory(); } } } @@ -126,3 +128,4 @@ public static boolean useFlintAndSteel(Player p, Block smelteryBlock) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/OutputChest.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/OutputChest.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/OutputChest.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/OutputChest.java index 5e82014379..3a1f3b92a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/OutputChest.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/OutputChest.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import java.util.Optional; @@ -15,12 +15,12 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.inventory.InvUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.VanillaInventoryDropHandler; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -83,8 +83,8 @@ public static Optional findOutputChestFor(@Nonnull Block b, @Nonnull // Found the output chest! Now, let's check if we can fit the product in it. BlockState state = PaperLib.getBlockState(potentialOutput, false).getState(); - if (state instanceof Chest chest) { - Inventory inv = chest.getInventory(); + if (state instanceof Chest) { + Chest chest = (Chest) state; Inventory inv = chest.getInventory(); // Check if the Item fits into that inventory. if (InvUtils.fits(inv, item)) { @@ -100,3 +100,4 @@ public static Optional findOutputChestFor(@Nonnull Block b, @Nonnull } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/RainbowBlock.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/RainbowBlock.java index 20be3883a3..dd095f09e8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/RainbowBlock.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.RainbowTickHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.RainbowTickHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * A {@link RainbowBlock} cycles through different colored {@link Material Materials}. @@ -34,3 +34,4 @@ public RainbowTickHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/RepairedSpawner.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/RepairedSpawner.java index 8084e40e87..3436f4ecf3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/RepairedSpawner.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import java.util.ArrayList; import java.util.Collection; @@ -7,19 +7,20 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.CreatureSpawner; import org.bukkit.event.block.BlockEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.events.BlockPlacerPlaceEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * A {@link RepairedSpawner} is the repaired variant of a {@link BrokenSpawner}. @@ -73,7 +74,7 @@ private void onPlace(ItemStack item, BlockEvent e) { * This may no longer be needed at some point but for legacy items * we still need to set the spawned EntityType manually */ - if (e.getBlock().getType() == Material.SPAWNER) { + if (e.getBlock().getType() == XMaterial.SPAWNER.parseMaterial()) { getEntityType(item).ifPresent(entity -> { CreatureSpawner spawner = (CreatureSpawner) e.getBlock().getState(); spawner.setSpawnedType(entity); @@ -94,3 +95,4 @@ public Collection getDrops() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/UnplaceableBlock.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/UnplaceableBlock.java index 8002996589..d95878101d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/UnplaceableBlock.java @@ -1,18 +1,18 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * This is a simple {@link SlimefunItem} implementation which implements the {@link NotPlaceable} @@ -42,3 +42,4 @@ public ItemUseHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/WitherProofBlock.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/WitherProofBlock.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/WitherProofBlock.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/WitherProofBlock.java index a4cd38a985..8e4bfcd915 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/WitherProofBlock.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/WitherProofBlock.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,11 +6,11 @@ import org.bukkit.entity.Wither; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.WitherProof; /** * A quick and easy implementation of {@link SlimefunItem} that also implements the @@ -40,3 +40,4 @@ public void onAttack(Block block, Wither wither) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/package-info.java new file mode 100644 index 0000000000..66d09ff4a3 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/blocks/package-info.java @@ -0,0 +1,6 @@ +/** + * This package contains a few miscellaneous implementations of + * {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} which are blocks. + * Such as the {@link io.github.thebusybiscuit.slimefun5.implementation.items.blocks.BlockPlacer} for example. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.blocks; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AbstractCargoNode.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AbstractCargoNode.java index c335e7fc25..de09fb05f9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AbstractCargoNode.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -13,17 +13,17 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.ColoredMaterial; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.ColoredMaterial; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -153,3 +153,4 @@ public int getSelectedChannel(@Nonnull Block b) { abstract void markDirty(@Nonnull Location loc); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AbstractFilterNode.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AbstractFilterNode.java index c28891e81a..2d762ec8d6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AbstractFilterNode.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -6,18 +6,19 @@ import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -80,7 +81,7 @@ protected void onPlace(BlockPlaceEvent e) { @Override protected void createBorder(BlockMenuPreset preset) { for (int i : getBorder()) { - preset.addItem(i, CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(XMaterial.CYAN_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); } preset.addItem(2, CustomItemStack.create(Material.PAPER, "&3Items", "", "&bPut in all Items you want to", "&bblacklist/whitelist"), ChestMenuUtils.getEmptyClickHandler()); @@ -92,14 +93,14 @@ protected void updateBlockMenu(BlockMenu menu, Block b) { String filterType = BlockStorage.getLocationInfo(loc, FILTER_TYPE); if (!BlockStorage.hasBlockInfo(b) || filterType == null || filterType.equals("whitelist")) { - menu.replaceExistingItem(15, CustomItemStack.create(Material.WHITE_WOOL, "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); + menu.replaceExistingItem(15, CustomItemStack.create(XMaterial.WHITE_WOOL.parseMaterial(), "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist")); menu.addMenuClickHandler(15, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, FILTER_TYPE, "blacklist"); updateBlockMenu(menu, b); return false; }); } else { - menu.replaceExistingItem(15, CustomItemStack.create(Material.BLACK_WOOL, "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist")); + menu.replaceExistingItem(15, CustomItemStack.create(XMaterial.BLACK_WOOL.parseMaterial(), "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist")); menu.addMenuClickHandler(15, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, FILTER_TYPE, "whitelist"); updateBlockMenu(menu, b); @@ -139,3 +140,4 @@ protected void markDirty(@Nonnull Location loc) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AdvancedCargoOutputNode.java similarity index 77% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AdvancedCargoOutputNode.java index 695acfa42f..61ae61759f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/AdvancedCargoOutputNode.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; /** * The {@link AdvancedCargoOutputNode} is the advanced version of the @@ -30,3 +30,4 @@ protected int[] getBorder() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoConnectorNode.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoConnectorNode.java index 45c795bb7c..1809600981 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoConnectorNode.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,13 +7,13 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link CargoConnectorNode} connects a {@link CargoNode} with a {@link CargoNet}. @@ -50,3 +50,4 @@ public CargoConnectorNode(ItemGroup itemGroup, SlimefunItemStack item, RecipeTyp }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoInputNode.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoInputNode.java index fe32c6fe7d..a2898622de 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoInputNode.java @@ -1,17 +1,18 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -64,7 +65,7 @@ protected void updateBlockMenu(BlockMenu menu, Block b) { String smartFillNode = BlockStorage.getLocationInfo(b.getLocation(), SMART_FILL_MODE); if (!BlockStorage.hasBlockInfo(b) || smartFillNode == null || smartFillNode.equals(String.valueOf(false))) { - menu.replaceExistingItem(16, CustomItemStack.create(Material.WRITABLE_BOOK, "&7\"Smart-Filling\" Mode: &4\u2718", "", "&e> Click to enable \"Smart-Filling\" Mode", "", "&fIn this mode, the Cargo node will attempt", "&fto keep a constant amount of items", "&fin the inventory. This is not perfect", "&fand will still fill in empty slots that", "&fcome before a stack of a configured item.")); + menu.replaceExistingItem(16, CustomItemStack.create(XMaterial.WRITABLE_BOOK.parseMaterial(), "&7\"Smart-Filling\" Mode: &4\u2718", "", "&e> Click to enable \"Smart-Filling\" Mode", "", "&fIn this mode, the Cargo node will attempt", "&fto keep a constant amount of items", "&fin the inventory. This is not perfect", "&fand will still fill in empty slots that", "&fcome before a stack of a configured item.")); menu.addMenuClickHandler(16, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, SMART_FILL_MODE, String.valueOf(true)); updateBlockMenu(menu, b); @@ -81,3 +82,4 @@ protected void updateBlockMenu(BlockMenu menu, Block b) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoManager.java similarity index 77% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoManager.java index 2c1c14e0fe..bfb71b6f22 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoManager.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import java.util.Optional; @@ -10,16 +10,16 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -82,3 +82,4 @@ public void onRightClick(PlayerRightClickEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoNode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoNode.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoNode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoNode.java index d68e7355c1..6605117a5c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoNode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoNode.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.Nonnull; import org.bukkit.block.Block; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; /** * This interface marks a {@link SlimefunItem} as a {@link CargoNode}. @@ -34,3 +34,4 @@ public interface CargoNode { boolean hasItemFilter(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoOutputNode.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoOutputNode.java index d00de44ea7..a12dca045e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/CargoOutputNode.java @@ -1,18 +1,19 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -39,7 +40,7 @@ protected void onPlace(BlockPlaceEvent e) { @Override protected void createBorder(BlockMenuPreset preset) { for (int i : BORDER) { - preset.addItem(i, CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(XMaterial.CYAN_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); } } @@ -54,3 +55,4 @@ protected void markDirty(Location loc) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/ReactorAccessPort.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/ReactorAccessPort.java index 52b61e10d2..c95aea754e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/ReactorAccessPort.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -6,24 +6,25 @@ import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.CoolantCell; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.Reactor; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.CoolantCell; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -72,7 +73,7 @@ public void newInstance(BlockMenu menu, Block b) { BlockMenu reactor = getReactor(b.getLocation()); if (reactor != null) { - menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(Material.GREEN_WOOL, "&7Reactor", "", "&6Detected", "", "&7> Click to view Reactor")); + menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(XMaterial.GREEN_WOOL.parseMaterial(), "&7Reactor", "", "&6Detected", "", "&7> Click to view Reactor")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { if (reactor != null) { reactor.open(p); @@ -83,7 +84,7 @@ public void newInstance(BlockMenu menu, Block b) { return false; }); } else { - menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(Material.RED_WOOL, "&7Reactor", "", "&cNot detected", "", "&7Reactor must be", "&7placed 3 blocks below", "&7the access port!")); + menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(XMaterial.RED_WOOL.parseMaterial(), "&7Reactor", "", "&cNot detected", "", "&7Reactor must be", "&7placed 3 blocks below", "&7the access port!")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { newInstance(menu, b); return false; @@ -135,9 +136,9 @@ public void onBlockBreak(@Nonnull Block b) { private void constructMenu(@Nonnull BlockMenuPreset preset) { preset.drawBackground(ChestMenuUtils.getBackground(), background); - preset.drawBackground(CustomItemStack.create(Material.LIME_STAINED_GLASS_PANE, " "), fuelBorder); - preset.drawBackground(CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), inputBorder); - preset.drawBackground(CustomItemStack.create(Material.GREEN_STAINED_GLASS_PANE, " "), outputBorder); + preset.drawBackground(CustomItemStack.create(XMaterial.LIME_STAINED_GLASS_PANE.parseMaterial(), " "), fuelBorder); + preset.drawBackground(CustomItemStack.create(XMaterial.CYAN_STAINED_GLASS_PANE.parseMaterial(), " "), inputBorder); + preset.drawBackground(CustomItemStack.create(XMaterial.GREEN_STAINED_GLASS_PANE.parseMaterial(), " "), outputBorder); preset.addItem(1, CustomItemStack.create(SlimefunItems.URANIUM.item(), "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), ChestMenuUtils.getEmptyClickHandler()); preset.addItem(22, CustomItemStack.create(SlimefunItems.PLUTONIUM.item(), "&7Byproduct Slot", "", "&rThis Slot contains the Reactor's Byproduct", "&rsuch as &aNeptunium &ror &7Plutonium"), ChestMenuUtils.getEmptyClickHandler()); @@ -177,3 +178,4 @@ private BlockMenu getReactor(@Nonnull Location l) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/TrashCan.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/TrashCan.java index a61f8deb54..fd384b99d0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/TrashCan.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/TrashCan.java @@ -1,17 +1,18 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; @@ -30,7 +31,7 @@ public class TrashCan extends SlimefunItem implements InventoryBlock { private final int[] border = { 0, 1, 2, 3, 5, 4, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }; - private final ItemStack background = CustomItemStack.create(Material.RED_STAINED_GLASS_PANE, " "); + private final ItemStack background = CustomItemStack.create(XMaterial.RED_STAINED_GLASS_PANE.parseMaterial(), " "); @ParametersAreNonnullByDefault public TrashCan(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -76,3 +77,4 @@ public boolean isSynchronized() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/package-info.java new file mode 100644 index 0000000000..bd2ef62fd9 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/cargo/package-info.java @@ -0,0 +1,7 @@ +/** + * This package provides the different implementations of + * {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are related to the {@link io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet}, most + * notably: Cargo Nodes. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.cargo; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/AbstractEnergyProvider.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/AbstractEnergyProvider.java index e84871e1ce..3e6ab66fc3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/AbstractEnergyProvider.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric; import java.util.ArrayList; import java.util.HashSet; @@ -14,15 +14,15 @@ import org.bukkit.inventory.meta.ItemMeta; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetProvider; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.Reactor; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -124,3 +124,4 @@ public List getDisplayRecipes() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Capacitor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/Capacitor.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Capacitor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/Capacitor.java index 21f39ceb73..afab894701 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Capacitor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/Capacitor.java @@ -1,17 +1,17 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; /** * A {@link Capacitor} is an {@link EnergyNetComponent} that serves as the energy @@ -48,3 +48,4 @@ public int getCapacity() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/EnergyConnector.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/EnergyConnector.java index 90b56d4a20..5a4b54e6ff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/EnergyConnector.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,14 +8,14 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * This {@link EnergyNetComponent} is a connector for the {@link EnergyNet} networks. @@ -62,3 +62,4 @@ public int getCapacity() { return 0; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/EnergyRegulator.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/EnergyRegulator.java index 2377d02d09..0f37416ca2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/EnergyRegulator.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,16 +7,16 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -87,3 +87,4 @@ private void tick(@Nonnull Block b) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/JetBoots.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/JetBoots.java index ebd08cc5de..c5b59c32da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/JetBoots.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.JetBootsTask; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.JetBootsTask; /** * {@link JetBoots} allow you to hover for a bit. @@ -44,3 +44,4 @@ public float getMaxItemCharge(ItemStack item) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/Jetpack.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/Jetpack.java index a5adefa937..efb4691d61 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/Jetpack.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.JetpackTask; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.JetpackTask; /** * {@link JetBoots} allow you to fly up into the air. @@ -43,3 +43,4 @@ public float getMaxItemCharge(ItemStack item) { return capacity; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/MultiTool.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/MultiTool.java index d608742da4..bc58ea6cbf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/MultiTool.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.util.ArrayList; import java.util.List; @@ -10,22 +12,22 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEntityType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ToolUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEntityType; /** * The {@link MultiTool} is an electric device which can mimic @@ -82,7 +84,7 @@ protected ItemUseHandler getItemUseHandler() { ItemMeta meta = item.getItemMeta(); e.cancel(); - int index = PersistentDataAPI.getInt(meta, key, 0); + int index = PdcCompat.getInt(meta, key, 0); SlimefunItem sfItem = modes.get(index).getItem(); if (!p.isSneaking()) { @@ -96,7 +98,7 @@ protected ItemUseHandler getItemUseHandler() { String itemName = selectedItem != null ? selectedItem.getItemName() : "Unknown"; Slimefun.getLocalization().sendMessage(p, "messages.multi-tool.mode-change", true, msg -> msg.replace("%device%", "Multi Tool").replace("%mode%", ChatColor.stripColor(itemName))); - PersistentDataAPI.setInt(meta, key, index); + PdcCompat.setInt(meta, key, index); List lore = meta.hasLore() ? meta.getLore() : new ArrayList<>(); @@ -155,3 +157,4 @@ public void preRegister() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiToolMode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/MultiToolMode.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiToolMode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/MultiToolMode.java index d3963496d4..0f648b80dd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiToolMode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/MultiToolMode.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; class MultiToolMode { @@ -29,7 +29,7 @@ class MultiToolMode { * * @return The ID of this mode */ - @Deprecated(since = "RC-37", forRemoval = true) + @Deprecated public int getId() { return id; } @@ -47,4 +47,4 @@ String getItemId() { boolean isEnabled() { return enabled.getValue(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/Multimeter.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/Multimeter.java index f194494345..94809f8daa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/Multimeter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets; import java.util.Optional; @@ -8,16 +8,16 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; /** * The {@link Multimeter} is used to measure charge and capacity of any {@link EnergyNetComponent}. @@ -43,8 +43,8 @@ public ItemUseHandler getItemHandler() { if (e.getClickedBlock().isPresent() && block.isPresent()) { SlimefunItem item = block.get(); - if (item instanceof EnergyNetComponent component && component.isChargeable()) { - e.cancel(); + if (item instanceof EnergyNetComponent && ((EnergyNetComponent) item).isChargeable()) { + EnergyNetComponent component = (EnergyNetComponent) item; e.cancel(); Location l = e.getClickedBlock().get().getLocation(); String stored = NumberUtils.getCompactDouble(component.getCharge(l)) + " J"; @@ -59,3 +59,4 @@ public ItemUseHandler getItemHandler() { }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/SolarHelmet.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/SolarHelmet.java index d864a84c2a..cd4313a89c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/SolarHelmet.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -8,14 +10,14 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SolarHelmetTask; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.DoubleRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.SolarHelmetTask; /** * The {@link SolarHelmet} can be worn by {@link Player}. @@ -60,16 +62,17 @@ public void rechargeItems(@Nonnull Player p) { recharge(inv.getLeggings()); recharge(inv.getBoots()); - recharge(inv.getItemInMainHand()); - recharge(inv.getItemInOffHand()); + recharge(HandCompat.getMainHand(inv)); + recharge(HandCompat.getOffHand(inv)); } private void recharge(@Nullable ItemStack item) { SlimefunItem sfItem = SlimefunItem.getByItem(item); - if (sfItem instanceof Rechargeable rechargeable) { - rechargeable.addItemCharge(item, charge.getValue().floatValue()); + if (sfItem instanceof Rechargeable) { + Rechargeable rechargeable = (Rechargeable) sfItem; rechargeable.addItemCharge(item, charge.getValue().floatValue()); } } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/package-info.java new file mode 100644 index 0000000000..f3020f2fdb --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/gadgets/package-info.java @@ -0,0 +1,7 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are used in combination with electricity, like the + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.Multimeter} or the + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.SolarHelmet} + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/BioGenerator.java similarity index 50% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/BioGenerator.java index c9cd289dec..1548d552e2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/BioGenerator.java @@ -1,20 +1,22 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class BioGenerator extends AGenerator { @@ -30,53 +32,53 @@ protected void registerDefaultFuelTypes() { registerFuel(new MachineFuel(2, new ItemStack(Material.BONE))); registerFuel(new MachineFuel(2, new ItemStack(Material.STRING))); registerFuel(new MachineFuel(3, new ItemStack(Material.APPLE))); - registerFuel(new MachineFuel(3, new ItemStack(Material.MELON_SLICE))); + registerFuel(new MachineFuel(3, MaterialCompat.stack(XMaterial.MELON_SLICE))); registerFuel(new MachineFuel(27, new ItemStack(Material.MELON))); registerFuel(new MachineFuel(3, new ItemStack(Material.PUMPKIN))); registerFuel(new MachineFuel(3, new ItemStack(Material.PUMPKIN_SEEDS))); registerFuel(new MachineFuel(3, new ItemStack(Material.MELON_SEEDS))); registerFuel(new MachineFuel(3, new ItemStack(Material.WHEAT))); - registerFuel(new MachineFuel(3, new ItemStack(Material.WHEAT_SEEDS))); + registerFuel(new MachineFuel(3, MaterialCompat.stack(XMaterial.WHEAT_SEEDS))); registerFuel(new MachineFuel(3, new ItemStack(Material.CARROT))); registerFuel(new MachineFuel(3, new ItemStack(Material.POTATO))); registerFuel(new MachineFuel(3, new ItemStack(Material.SUGAR_CANE))); - registerFuel(new MachineFuel(3, new ItemStack(Material.NETHER_WART))); + registerFuel(new MachineFuel(3, MaterialCompat.stack(XMaterial.NETHER_WART))); registerFuel(new MachineFuel(2, new ItemStack(Material.RED_MUSHROOM))); registerFuel(new MachineFuel(2, new ItemStack(Material.BROWN_MUSHROOM))); registerFuel(new MachineFuel(2, new ItemStack(Material.VINE))); registerFuel(new MachineFuel(2, new ItemStack(Material.CACTUS))); - registerFuel(new MachineFuel(2, new ItemStack(Material.LILY_PAD))); - registerFuel(new MachineFuel(8, new ItemStack(Material.CHORUS_FRUIT))); - registerFuel(new MachineFuel(1, new ItemStack(Material.KELP))); - registerFuel(new MachineFuel(2, new ItemStack(Material.DRIED_KELP))); - registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK))); - registerFuel(new MachineFuel(1, new ItemStack(Material.SEAGRASS))); - registerFuel(new MachineFuel(2, new ItemStack(Material.SEA_PICKLE))); - registerFuel(new MachineFuel(1, new ItemStack(Material.BAMBOO))); - registerFuel(new MachineFuel(2, new ItemStack(Material.SWEET_BERRIES))); - registerFuel(new MachineFuel(2, new ItemStack(Material.COCOA_BEANS))); - registerFuel(new MachineFuel(3, new ItemStack(Material.BEETROOT))); - registerFuel(new MachineFuel(3, new ItemStack(Material.BEETROOT_SEEDS))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.LILY_PAD))); + registerFuel(new MachineFuel(8, MaterialCompat.stack(XMaterial.CHORUS_FRUIT))); + registerFuel(new MachineFuel(1, MaterialCompat.stack(XMaterial.KELP))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.DRIED_KELP))); + registerFuel(new MachineFuel(20, MaterialCompat.stack(XMaterial.DRIED_KELP_BLOCK))); + registerFuel(new MachineFuel(1, MaterialCompat.stack(XMaterial.SEAGRASS))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.SEA_PICKLE))); + registerFuel(new MachineFuel(1, MaterialCompat.stack(XMaterial.BAMBOO))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.SWEET_BERRIES))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.COCOA_BEANS))); + registerFuel(new MachineFuel(3, MaterialCompat.stack(XMaterial.BEETROOT))); + registerFuel(new MachineFuel(3, MaterialCompat.stack(XMaterial.BEETROOT_SEEDS))); // Small Flowers (formally just dandelions and poppies). for (Material m : Tag.SMALL_FLOWERS.getValues()) { registerFuel(new MachineFuel(1, new ItemStack(m))); } - registerFuel(new MachineFuel(4, new ItemStack(Material.HONEYCOMB))); - registerFuel(new MachineFuel(40, new ItemStack(Material.HONEYCOMB_BLOCK))); + registerFuel(new MachineFuel(4, MaterialCompat.stack(XMaterial.HONEYCOMB))); + registerFuel(new MachineFuel(40, MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK))); - registerFuel(new MachineFuel(4, new ItemStack(Material.SHROOMLIGHT))); - registerFuel(new MachineFuel(2, new ItemStack(Material.CRIMSON_FUNGUS))); - registerFuel(new MachineFuel(2, new ItemStack(Material.WARPED_FUNGUS))); + registerFuel(new MachineFuel(4, MaterialCompat.stack(XMaterial.SHROOMLIGHT))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.CRIMSON_FUNGUS))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.WARPED_FUNGUS))); registerFuel(new MachineFuel(16, SlimefunItems.STRANGE_NETHER_GOO.item())); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - registerFuel(new MachineFuel(2, new ItemStack(Material.GLOW_BERRIES))); - registerFuel(new MachineFuel(3, new ItemStack(Material.SMALL_DRIPLEAF))); - registerFuel(new MachineFuel(3, new ItemStack(Material.BIG_DRIPLEAF))); - registerFuel(new MachineFuel(2, new ItemStack(Material.GLOW_LICHEN))); - registerFuel(new MachineFuel(20, new ItemStack(Material.SPORE_BLOSSOM))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.GLOW_BERRIES))); + registerFuel(new MachineFuel(3, MaterialCompat.stack(XMaterial.SMALL_DRIPLEAF))); + registerFuel(new MachineFuel(3, MaterialCompat.stack(XMaterial.BIG_DRIPLEAF))); + registerFuel(new MachineFuel(2, MaterialCompat.stack(XMaterial.GLOW_LICHEN))); + registerFuel(new MachineFuel(20, MaterialCompat.stack(XMaterial.SPORE_BLOSSOM))); } // Leaves @@ -101,7 +103,8 @@ protected void registerDefaultFuelTypes() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_HOE); + return MaterialCompat.stack(XMaterial.GOLDEN_HOE); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/CoalGenerator.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/CoalGenerator.java index cb2a488441..b0aeed02fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/CoalGenerator.java @@ -1,18 +1,20 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class CoalGenerator extends AGenerator { @@ -25,7 +27,7 @@ public CoalGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec protected void registerDefaultFuelTypes() { registerFuel(new MachineFuel(80, new ItemStack(Material.COAL_BLOCK))); registerFuel(new MachineFuel(12, new ItemStack(Material.BLAZE_ROD))); - registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK))); + registerFuel(new MachineFuel(20, MaterialCompat.stack(XMaterial.DRIED_KELP_BLOCK))); // Boats for (Material mat : Tag.ITEMS_BOATS.getValues()) { @@ -34,7 +36,7 @@ protected void registerDefaultFuelTypes() { // Coal & Charcoal registerFuel(new MachineFuel(8, new ItemStack(Material.COAL))); - registerFuel(new MachineFuel(8, new ItemStack(Material.CHARCOAL))); + registerFuel(new MachineFuel(8, MaterialCompat.stack(XMaterial.CHARCOAL))); // Logs for (Material mat : Tag.LOGS.getValues()) { @@ -89,3 +91,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/CombustionGenerator.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/CombustionGenerator.java index eb69dc5718..abb57f5f7f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CombustionGenerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/CombustionGenerator.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -32,3 +32,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/LavaGenerator.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/LavaGenerator.java index 59100fbeb1..9306107c1d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/LavaGenerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/LavaGenerator.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -30,3 +30,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/MagnesiumGenerator.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/MagnesiumGenerator.java index 110b7fff05..c9c9e07a2a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/MagnesiumGenerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/MagnesiumGenerator.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -31,3 +31,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/SolarGenerator.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/SolarGenerator.java index a44f05d462..753592cbc5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/SolarGenerator.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,15 +7,15 @@ import org.bukkit.World.Environment; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetProvider; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNet; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; @@ -128,3 +128,4 @@ public void preRegister() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/package-info.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/package-info.java index 27d9fcfb58..20cc88b29c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/generators/package-info.java @@ -2,4 +2,4 @@ * This package contains the different implementations of * {@link me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator}. */ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoAnvil.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoAnvil.java index 20b5a12d40..7b60ddb60c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoAnvil.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; @@ -88,3 +88,4 @@ private ItemStack repair(ItemStack item) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoBrewer.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoBrewer.java index 6dcd35c335..204fa25195 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoBrewer.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import java.util.HashMap; import java.util.Map; @@ -7,22 +7,25 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; import io.github.bakedlibs.dough.inventory.InvUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PotionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionType; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * @@ -40,14 +43,14 @@ public class AutoBrewer extends AContainer implements NotHopperable { potionRecipes.put(Material.SUGAR, VersionedPotionType.SWIFTNESS); potionRecipes.put(Material.RABBIT_FOOT, VersionedPotionType.LEAPING); potionRecipes.put(Material.BLAZE_POWDER, PotionType.STRENGTH); - potionRecipes.put(Material.GLISTERING_MELON_SLICE, VersionedPotionType.HEALING); + potionRecipes.put(XMaterial.GLISTERING_MELON_SLICE.parseMaterial(), VersionedPotionType.HEALING); potionRecipes.put(Material.SPIDER_EYE, PotionType.POISON); potionRecipes.put(Material.GHAST_TEAR, VersionedPotionType.REGENERATION); potionRecipes.put(Material.MAGMA_CREAM, PotionType.FIRE_RESISTANCE); - potionRecipes.put(Material.PUFFERFISH, PotionType.WATER_BREATHING); + potionRecipes.put(XMaterial.PUFFERFISH.parseMaterial(), PotionType.WATER_BREATHING); potionRecipes.put(Material.GOLDEN_CARROT, PotionType.NIGHT_VISION); - potionRecipes.put(Material.TURTLE_HELMET, PotionType.TURTLE_MASTER); - potionRecipes.put(Material.PHANTOM_MEMBRANE, PotionType.SLOW_FALLING); + potionRecipes.put(XMaterial.TURTLE_HELMET.parseMaterial(), VersionedPotionType.TURTLE_MASTER); + potionRecipes.put(XMaterial.PHANTOM_MEMBRANE.parseMaterial(), VersionedPotionType.SLOW_FALLING); fermentations.put(VersionedPotionType.SWIFTNESS, PotionType.SLOWNESS); fermentations.put(VersionedPotionType.LEAPING, PotionType.SLOWNESS); @@ -108,39 +111,39 @@ public AutoBrewer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe if (Slimefun.getMinecraftVersion().isBefore(20,2)) { return brewPreBasePotionType(input, potionType, potion); } - PotionType type = potion.getBasePotionType(); + PotionType type = PotionCompat.getBasePotionType(potion); if (type == PotionType.WATER) { if (input == Material.FERMENTED_SPIDER_EYE) { - potion.setBasePotionType(PotionType.WEAKNESS); + PotionCompat.setBasePotionType(potion, PotionType.WEAKNESS); return new ItemStack(potionType); - } else if (input == Material.NETHER_WART) { - potion.setBasePotionType(PotionType.AWKWARD); + } else if (input == XMaterial.NETHER_WART.parseMaterial()) { + PotionCompat.setBasePotionType(potion, VersionedPotionType.AWKWARD); return new ItemStack(potionType); - } else if (potionType == Material.POTION && input == Material.GUNPOWDER) { - return new ItemStack(Material.SPLASH_POTION); - } else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) { - return new ItemStack(Material.LINGERING_POTION); + } else if (potionType == Material.POTION && input == XMaterial.GUNPOWDER.parseMaterial()) { + return MaterialCompat.stack(XMaterial.SPLASH_POTION); + } else if (potionType == XMaterial.SPLASH_POTION.parseMaterial() && input == XMaterial.DRAGON_BREATH.parseMaterial()) { + return MaterialCompat.stack(XMaterial.LINGERING_POTION); } } else if (input == Material.FERMENTED_SPIDER_EYE) { PotionType fermented = fermentations.get(type); if (fermented != null) { - potion.setBasePotionType(fermented); + PotionCompat.setBasePotionType(potion, fermented); return new ItemStack(potionType); } - } else if (input == Material.REDSTONE && type.isExtendable() && !type.isUpgradeable()) { + } else if (input == Material.REDSTONE && PotionCompat.isExtendable(type) && !PotionCompat.isUpgradeable(type)) { // Fixes #3390 - Potions can only be either extended or upgraded. Not both. - potion.setBasePotionType(type); + PotionCompat.setBasePotionType(potion, type); return new ItemStack(potionType); - } else if (input == Material.GLOWSTONE_DUST && type.isUpgradeable() && !type.isExtendable()) { + } else if (input == Material.GLOWSTONE_DUST && PotionCompat.isUpgradeable(type) && !PotionCompat.isExtendable(type)) { // Fixes #3390 - Potions can only be either extended or upgraded. Not both. - potion.setBasePotionType(type); + PotionCompat.setBasePotionType(potion, type); return new ItemStack(potionType); - } else if (type == PotionType.AWKWARD) { + } else if (type == VersionedPotionType.AWKWARD) { PotionType potionRecipe = potionRecipes.get(input); if (potionRecipe != null) { - potion.setBasePotionType(potionRecipe); + PotionCompat.setBasePotionType(potion, potionRecipe); return new ItemStack(potionType); } } @@ -149,42 +152,42 @@ public AutoBrewer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe } @ParametersAreNonnullByDefault - @SuppressWarnings("deprecration") + @SuppressWarnings("deprecation") private ItemStack brewPreBasePotionType(Material input, Material potionType, PotionMeta potion) { - PotionData data = potion.getBasePotionData(); + PotionData data = PotionCompat.getBasePotionData(potion); PotionType type = data.getType(); if (type == PotionType.WATER) { if (input == Material.FERMENTED_SPIDER_EYE) { - potion.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false)); + PotionCompat.setBasePotionData(potion, new PotionData(PotionType.WEAKNESS, false, false)); return new ItemStack(potionType); - } else if (input == Material.NETHER_WART) { - potion.setBasePotionData(new PotionData(PotionType.AWKWARD, false, false)); + } else if (input == XMaterial.NETHER_WART.parseMaterial()) { + PotionCompat.setBasePotionData(potion, new PotionData(VersionedPotionType.AWKWARD, false, false)); return new ItemStack(potionType); - } else if (potionType == Material.POTION && input == Material.GUNPOWDER) { - return new ItemStack(Material.SPLASH_POTION); - } else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) { - return new ItemStack(Material.LINGERING_POTION); + } else if (potionType == Material.POTION && input == XMaterial.GUNPOWDER.parseMaterial()) { + return MaterialCompat.stack(XMaterial.SPLASH_POTION); + } else if (potionType == XMaterial.SPLASH_POTION.parseMaterial() && input == XMaterial.DRAGON_BREATH.parseMaterial()) { + return MaterialCompat.stack(XMaterial.LINGERING_POTION); } } else if (input == Material.FERMENTED_SPIDER_EYE) { PotionType fermented = fermentations.get(type); if (fermented != null) { - potion.setBasePotionData(new PotionData(fermented, data.isExtended(), data.isUpgraded())); + PotionCompat.setBasePotionData(potion, new PotionData(fermented, data.isExtended(), data.isUpgraded())); return new ItemStack(potionType); } - } else if (input == Material.REDSTONE && type.isExtendable() && !data.isUpgraded()) { + } else if (input == Material.REDSTONE && PotionCompat.isExtendable(type) && !data.isUpgraded()) { // Fixes #3390 - Potions can only be either extended or upgraded. Not both. - potion.setBasePotionData(new PotionData(type, true, false)); + PotionCompat.setBasePotionData(potion, new PotionData(type, true, false)); return new ItemStack(potionType); - } else if (input == Material.GLOWSTONE_DUST && type.isUpgradeable() && !data.isExtended()) { + } else if (input == Material.GLOWSTONE_DUST && PotionCompat.isUpgradeable(type) && !data.isExtended()) { // Fixes #3390 - Potions can only be either extended or upgraded. Not both. - potion.setBasePotionData(new PotionData(type, false, true)); + PotionCompat.setBasePotionData(potion, new PotionData(type, false, true)); return new ItemStack(potionType); - } else if (type == PotionType.AWKWARD) { + } else if (type == VersionedPotionType.AWKWARD) { PotionType potionRecipe = potionRecipes.get(input); if (potionRecipe != null) { - potion.setBasePotionData(new PotionData(potionRecipe, false, false)); + PotionCompat.setBasePotionData(potion, new PotionData(potionRecipe, false, false)); return new ItemStack(potionType); } } @@ -200,7 +203,7 @@ private ItemStack brewPreBasePotionType(Material input, Material potionType, Pot * @return Whether this {@link Material} is a valid potion */ private boolean isPotion(@Nonnull Material mat) { - return mat == Material.POTION || mat == Material.SPLASH_POTION || mat == Material.LINGERING_POTION; + return mat == Material.POTION || mat == XMaterial.SPLASH_POTION.parseMaterial() || mat == XMaterial.LINGERING_POTION.parseMaterial(); } @Override @@ -213,3 +216,4 @@ private boolean isPotion(@Nonnull Material mat) { return "AUTO_BREWER"; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoDrier.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoDrier.java index e7245f5992..54a5ab4128 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/AutoDrier.java @@ -1,24 +1,26 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import java.util.ArrayList; import java.util.List; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link AutoDrier} is an implementation of {@link AContainer} that features recipes @@ -43,19 +45,19 @@ protected void registerDefaultRecipes() { recipeList.add(new ItemStack(Material.ROTTEN_FLESH)); recipeList.add(new ItemStack(Material.LEATHER)); - recipeList.add(new ItemStack(Material.WET_SPONGE)); + recipeList.add(MaterialCompat.stack(XMaterial.WET_SPONGE)); recipeList.add(new ItemStack(Material.SPONGE)); - recipeList.add(new ItemStack(Material.KELP)); - recipeList.add(new ItemStack(Material.DRIED_KELP)); + recipeList.add(MaterialCompat.stack(XMaterial.KELP)); + recipeList.add(MaterialCompat.stack(XMaterial.DRIED_KELP)); recipeList.add(new ItemStack(Material.POTION)); recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); - recipeList.add(new ItemStack(Material.SPLASH_POTION)); + recipeList.add(MaterialCompat.stack(XMaterial.SPLASH_POTION)); recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); - recipeList.add(new ItemStack(Material.LINGERING_POTION)); + recipeList.add(MaterialCompat.stack(XMaterial.LINGERING_POTION)); recipeList.add(new ItemStack(Material.GLASS_BOTTLE)); recipeList.add(new ItemStack(Material.WATER_BUCKET)); @@ -64,7 +66,7 @@ protected void registerDefaultRecipes() { recipeList.add(new ItemStack(Material.COOKED_BEEF)); recipeList.add(SlimefunItems.BEEF_JERKY.item()); - recipeList.add(new ItemStack(Material.COOKED_PORKCHOP)); + recipeList.add(MaterialCompat.stack(XMaterial.COOKED_PORKCHOP)); recipeList.add(SlimefunItems.PORK_JERKY.item()); recipeList.add(new ItemStack(Material.COOKED_CHICKEN)); @@ -76,14 +78,14 @@ protected void registerDefaultRecipes() { recipeList.add(new ItemStack(Material.COOKED_RABBIT)); recipeList.add(SlimefunItems.RABBIT_JERKY.item()); - recipeList.add(new ItemStack(Material.COOKED_COD)); + recipeList.add(MaterialCompat.stack(XMaterial.COOKED_COD)); recipeList.add(SlimefunItems.FISH_JERKY.item()); - recipeList.add(new ItemStack(Material.COOKED_SALMON)); + recipeList.add(MaterialCompat.stack(XMaterial.COOKED_SALMON)); recipeList.add(SlimefunItems.FISH_JERKY.item()); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_19)) { - recipeList.add(new ItemStack(Material.MUD)); + recipeList.add(MaterialCompat.stack(XMaterial.MUD)); recipeList.add(new ItemStack(Material.CLAY)); } @@ -118,3 +120,4 @@ public String getMachineIdentifier() { return "AUTO_DRIER"; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/CarbonPress.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/CarbonPress.java index 1ea7aa7769..aaac6b2695 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CarbonPress.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/CarbonPress.java @@ -1,18 +1,20 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class CarbonPress extends AContainer implements RecipeDisplayItem { @@ -23,7 +25,7 @@ public CarbonPress(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recip @Override protected void registerDefaultRecipes() { - registerRecipe(15, new ItemStack[] { new ItemStack(Material.CHARCOAL, 4) }, new ItemStack[] { new ItemStack(Material.COAL) }); + registerRecipe(15, new ItemStack[] { MaterialCompat.stack(XMaterial.CHARCOAL, 4) }, new ItemStack[] { new ItemStack(Material.COAL) }); registerRecipe(20, new ItemStack[] { new ItemStack(Material.COAL, 8) }, new ItemStack[] { SlimefunItems.CARBON.item() }); registerRecipe(180, new ItemStack[] { new ItemStack(Material.COAL_BLOCK, 8) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARBON, 9).item() }); registerRecipe(30, new ItemStack[] { CustomItemStack.create(SlimefunItems.CARBON.item(), 4) }, new ItemStack[] { SlimefunItems.COMPRESSED_CARBON.item() }); @@ -43,3 +45,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ChargingBench.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ChargingBench.java index b535e44b40..fa058d3ea6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ChargingBench.java @@ -1,18 +1,20 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link ChargingBench} is a powered machine that can be used to charge any {@link Rechargeable} item. @@ -30,7 +32,7 @@ public ChargingBench(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_PICKAXE); + return MaterialCompat.stack(XMaterial.GOLDEN_PICKAXE); } @Override @@ -57,8 +59,8 @@ protected void tick(Block b) { private boolean charge(Block b, BlockMenu inv, int slot, ItemStack item) { SlimefunItem sfItem = SlimefunItem.getByItem(item); - if (sfItem instanceof Rechargeable rechargeable) { - float charge = getEnergyConsumption() / 2F; + if (sfItem instanceof Rechargeable) { + Rechargeable rechargeable = (Rechargeable) sfItem; float charge = getEnergyConsumption() / 2F; if (rechargeable.addItemCharge(item, charge)) { removeCharge(b.getLocation(), getEnergyConsumption()); @@ -82,3 +84,4 @@ public String getMachineIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricDustWasher.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricDustWasher.java index d640571f2f..7e4aebc450 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricDustWasher.java @@ -1,22 +1,24 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.OreWasher; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.OreWasher; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link ElectricDustWasher} serves as an electrical {@link OreWasher}. @@ -40,7 +42,7 @@ public ElectricDustWasher(ItemGroup itemGroup, SlimefunItemStack item, RecipeTyp @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_SHOVEL); + return MaterialCompat.stack(XMaterial.GOLDEN_SHOVEL); } @Override @@ -92,3 +94,4 @@ private boolean hasFreeSlot(BlockMenu menu) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricFurnace.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricFurnace.java index c77e660dfb..538351afca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricFurnace.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import javax.annotation.ParametersAreNonnullByDefault; @@ -9,11 +9,12 @@ import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.RecipeChoice.MaterialChoice; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -35,10 +36,10 @@ public ElectricFurnace(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r public void registerDefaultRecipes() { Slimefun.getMinecraftRecipeService().subscribe(snapshot -> { for (FurnaceRecipe recipe : snapshot.getRecipes(FurnaceRecipe.class)) { - RecipeChoice choice = recipe.getInputChoice(); + RecipeChoice choice = (RecipeChoice) ReflectionCompat.invoke(recipe, "getInputChoice"); - if (choice instanceof MaterialChoice materialChoice) { - for (Material input : materialChoice.getChoices()) { + if (choice instanceof MaterialChoice) { + MaterialChoice materialChoice = (MaterialChoice) choice; for (Material input : materialChoice.getChoices()) { registerRecipe(4, new ItemStack[] { new ItemStack(input) }, new ItemStack[] { recipe.getResult() }); } } @@ -57,3 +58,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricGoldPan.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricGoldPan.java index a454482f8e..293eb08323 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricGoldPan.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import java.util.ArrayList; import java.util.List; @@ -7,20 +7,22 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.NetherGoldPan; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GoldPan; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.NetherGoldPan; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link ElectricGoldPan} is an electric machine based on the {@link GoldPan}. @@ -50,7 +52,7 @@ public ElectricGoldPan(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r * @deprecated since RC-36 * Use {@link ElectricGoldPan#isOutputLimitOverridden()} instead. */ - @Deprecated(since = "RC-36") + @Deprecated public boolean isOutputLimitOverriden() { return isOutputLimitOverridden(); } @@ -81,7 +83,7 @@ public boolean isOutputLimitOverridden() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.DIAMOND_SHOVEL); + return MaterialCompat.stack(XMaterial.DIAMOND_SHOVEL); } @Override @@ -128,3 +130,4 @@ private boolean hasFreeSlot(@Nonnull BlockMenu menu) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotFactory.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricIngotFactory.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotFactory.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricIngotFactory.java index 287383f517..a6e6500b61 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotFactory.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricIngotFactory.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -27,3 +27,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricIngotPulverizer.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricIngotPulverizer.java index 12a93cb07b..79c76b167f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricIngotPulverizer.java @@ -1,22 +1,24 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import java.util.ArrayList; import java.util.List; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link ElectricIngotPulverizer} is an implementation of {@link AContainer} that allows @@ -57,7 +59,7 @@ protected void registerDefaultRecipes() { registerRecipe(3, new ItemStack(Material.GOLD_INGOT), SlimefunItems.GOLD_DUST.item()); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - registerRecipe(3, new ItemStack(Material.COPPER_INGOT), SlimefunItems.COPPER_DUST.item()); + registerRecipe(3, MaterialCompat.stack(XMaterial.COPPER_INGOT), SlimefunItems.COPPER_DUST.item()); } } @@ -67,3 +69,4 @@ public String getMachineIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricOreGrinder.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricOreGrinder.java index 19a6425eea..226caee27f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricOreGrinder.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricOreGrinder.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -31,3 +31,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricPress.java similarity index 59% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricPress.java index 93ad03ab5f..034f36f34d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricPress.java @@ -1,20 +1,22 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link ElectricPress} is a pretty simple electrical machine. @@ -34,25 +36,25 @@ public ElectricPress(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec protected void registerDefaultRecipes() { addRecipe(4, new SlimefunItemStack(SlimefunItems.STONE_CHUNK, 3).item(), new ItemStack(Material.COBBLESTONE)); addRecipe(4, new ItemStack(Material.FLINT, 6), new ItemStack(Material.COBBLESTONE)); - addRecipe(5, new ItemStack(Material.GLASS), new ItemStack(Material.GLASS_PANE, 3)); - addRecipe(4, new ItemStack(Material.SNOWBALL, 4), new ItemStack(Material.SNOW_BLOCK)); - addRecipe(4, new ItemStack(Material.MAGMA_CREAM, 4), new ItemStack(Material.MAGMA_BLOCK)); + addRecipe(5, new ItemStack(Material.GLASS), MaterialCompat.stack(XMaterial.GLASS_PANE, 3)); + addRecipe(4, MaterialCompat.stack(XMaterial.SNOWBALL, 4), new ItemStack(Material.SNOW_BLOCK)); + addRecipe(4, new ItemStack(Material.MAGMA_CREAM, 4), MaterialCompat.stack(XMaterial.MAGMA_BLOCK)); addRecipe(4, new ItemStack(Material.SLIME_BALL, 9), new ItemStack(Material.SLIME_BLOCK)); - addRecipe(3, new ItemStack(Material.DRIED_KELP, 9), new ItemStack(Material.DRIED_KELP_BLOCK)); - addRecipe(3, new ItemStack(Material.BONE_MEAL, 9), new ItemStack(Material.BONE_BLOCK)); + addRecipe(3, MaterialCompat.stack(XMaterial.DRIED_KELP, 9), MaterialCompat.stack(XMaterial.DRIED_KELP_BLOCK)); + addRecipe(3, MaterialCompat.stack(XMaterial.BONE_MEAL, 9), MaterialCompat.stack(XMaterial.BONE_BLOCK)); addRecipe(3, new ItemStack(Material.CLAY_BALL, 4), new ItemStack(Material.CLAY)); - addRecipe(3, new ItemStack(Material.BRICK, 4), new ItemStack(Material.BRICKS)); + addRecipe(3, new ItemStack(Material.BRICK, 4), MaterialCompat.stack(XMaterial.BRICKS)); addRecipe(6, SlimefunItems.COPPER_INGOT.item(), CustomItemStack.create(SlimefunItems.COPPER_WIRE.item(), 3)); addRecipe(16, new SlimefunItemStack(SlimefunItems.STEEL_INGOT, 8), SlimefunItems.STEEL_PLATE); addRecipe(18, new SlimefunItemStack(SlimefunItems.REINFORCED_ALLOY_INGOT, 8), SlimefunItems.REINFORCED_PLATE); - addRecipe(8, new ItemStack(Material.NETHER_WART), CustomItemStack.create(SlimefunItems.MAGIC_LUMP_1.item(), 2)); + addRecipe(8, MaterialCompat.stack(XMaterial.NETHER_WART), CustomItemStack.create(SlimefunItems.MAGIC_LUMP_1.item(), 2)); addRecipe(10, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_1, 4), SlimefunItems.MAGIC_LUMP_2); addRecipe(12, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_2, 4), SlimefunItems.MAGIC_LUMP_3); - addRecipe(10, new ItemStack(Material.ENDER_EYE), CustomItemStack.create(SlimefunItems.ENDER_LUMP_1.item(), 2)); + addRecipe(10, MaterialCompat.stack(XMaterial.ENDER_EYE), CustomItemStack.create(SlimefunItems.ENDER_LUMP_1.item(), 2)); addRecipe(12, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_1, 4), SlimefunItems.ENDER_LUMP_2); addRecipe(14, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_2, 4), SlimefunItems.ENDER_LUMP_3); @@ -60,30 +62,30 @@ protected void registerDefaultRecipes() { addRecipe(24, new SlimefunItemStack(SlimefunItems.SMALL_URANIUM, 4), SlimefunItems.URANIUM); addRecipe(4, new ItemStack(Material.QUARTZ, 4), new ItemStack(Material.QUARTZ_BLOCK)); - addRecipe(4, new ItemStack(Material.IRON_NUGGET, 9), new ItemStack(Material.IRON_INGOT)); + addRecipe(4, MaterialCompat.stack(XMaterial.IRON_NUGGET, 9), new ItemStack(Material.IRON_INGOT)); addRecipe(4, new ItemStack(Material.GOLD_NUGGET, 9), new ItemStack(Material.GOLD_INGOT)); addRecipe(4, new ItemStack(Material.COAL, 9), new ItemStack(Material.COAL_BLOCK)); addRecipe(4, new ItemStack(Material.SAND, 4), new ItemStack(Material.SANDSTONE)); - addRecipe(4, new ItemStack(Material.RED_SAND, 4), new ItemStack(Material.RED_SANDSTONE)); + addRecipe(4, MaterialCompat.stack(XMaterial.RED_SAND, 4), new ItemStack(Material.RED_SANDSTONE)); addRecipe(5, new ItemStack(Material.IRON_INGOT, 9), new ItemStack(Material.IRON_BLOCK)); addRecipe(5, new ItemStack(Material.GOLD_INGOT, 9), new ItemStack(Material.GOLD_BLOCK)); addRecipe(6, new ItemStack(Material.REDSTONE, 9), new ItemStack(Material.REDSTONE_BLOCK)); - addRecipe(6, new ItemStack(Material.LAPIS_LAZULI, 9), new ItemStack(Material.LAPIS_BLOCK)); + addRecipe(6, MaterialCompat.stack(XMaterial.LAPIS_LAZULI, 9), new ItemStack(Material.LAPIS_BLOCK)); addRecipe(8, new ItemStack(Material.EMERALD, 9), new ItemStack(Material.EMERALD_BLOCK)); addRecipe(8, new ItemStack(Material.DIAMOND, 9), new ItemStack(Material.DIAMOND_BLOCK)); - addRecipe(16, new ItemStack(Material.NETHERITE_INGOT, 9), new ItemStack(Material.NETHERITE_BLOCK)); + addRecipe(16, MaterialCompat.stack(XMaterial.NETHERITE_INGOT, 9), MaterialCompat.stack(XMaterial.NETHERITE_BLOCK)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - addRecipe(4, new ItemStack(Material.AMETHYST_SHARD, 4), new ItemStack(Material.AMETHYST_BLOCK)); + addRecipe(4, MaterialCompat.stack(XMaterial.AMETHYST_SHARD, 4), MaterialCompat.stack(XMaterial.AMETHYST_BLOCK)); - addRecipe(5, new ItemStack(Material.COPPER_INGOT, 9), new ItemStack(Material.COPPER_BLOCK)); - addRecipe(5, new ItemStack(Material.RAW_IRON, 9), new ItemStack(Material.RAW_IRON_BLOCK)); - addRecipe(5, new ItemStack(Material.RAW_GOLD, 9), new ItemStack(Material.RAW_GOLD_BLOCK)); - addRecipe(5, new ItemStack(Material.RAW_COPPER, 9), new ItemStack(Material.RAW_COPPER_BLOCK)); + addRecipe(5, MaterialCompat.stack(XMaterial.COPPER_INGOT, 9), MaterialCompat.stack(XMaterial.COPPER_BLOCK)); + addRecipe(5, MaterialCompat.stack(XMaterial.RAW_IRON, 9), MaterialCompat.stack(XMaterial.RAW_IRON_BLOCK)); + addRecipe(5, MaterialCompat.stack(XMaterial.RAW_GOLD, 9), MaterialCompat.stack(XMaterial.RAW_GOLD_BLOCK)); + addRecipe(5, MaterialCompat.stack(XMaterial.RAW_COPPER, 9), MaterialCompat.stack(XMaterial.RAW_COPPER_BLOCK)); } } @@ -109,3 +111,4 @@ public String getMachineIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricSmeltery.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricSmeltery.java index 0f61a4e8c6..128b84a484 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectricSmeltery.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import java.util.Collections; import java.util.Comparator; @@ -9,20 +9,21 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.Smeltery; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -120,7 +121,7 @@ protected void constructMenu(BlockMenuPreset preset) { preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } - preset.addItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(22, CustomItemStack.create(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); for (int i : getOutputSlots()) { preset.addMenuClickHandler(i, ChestMenuUtils.getDefaultOutputHandler()); @@ -148,3 +149,4 @@ public String getMachineIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectrifiedCrucible.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectrifiedCrucible.java index ff5a33474b..d904982805 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/ElectrifiedCrucible.java @@ -1,17 +1,19 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class ElectrifiedCrucible extends AContainer { @@ -24,7 +26,7 @@ protected void registerDefaultRecipes() { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLESTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.NETHERRACK, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.STONE, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.TERRACOTTA, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), MaterialCompat.stack(XMaterial.TERRACOTTA, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.OBSIDIAN) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); for (Material terracotta : SlimefunTag.TERRACOTTA.getValues()) { @@ -35,13 +37,13 @@ protected void registerDefaultRecipes() { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(leaves, 16) }, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) }); } - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 8) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), MaterialCompat.stack(XMaterial.BLACKSTONE, 8) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), MaterialCompat.stack(XMaterial.BASALT, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLED_DEEPSLATE, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.DEEPSLATE, 10) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); - registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.TUFF, 8) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), MaterialCompat.stack(XMaterial.COBBLED_DEEPSLATE, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), MaterialCompat.stack(XMaterial.DEEPSLATE, 10) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); + registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), MaterialCompat.stack(XMaterial.TUFF, 8) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); } } @@ -56,3 +58,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FluidPump.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FluidPump.java index 729fd2ff51..676e536b7d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FluidPump.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; import java.util.List; import java.util.concurrent.ThreadLocalRandom; @@ -7,28 +8,28 @@ import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Levelled; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.blocks.Vein; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PotionCompat; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; @@ -174,7 +175,7 @@ protected void tick(@Nonnull Block b) { @Nullable private Block findNextFluid(@Nonnull Block fluid) { - if (fluid.getType() == Material.WATER || fluid.getType() == Material.BUBBLE_COLUMN) { + if (fluid.getType() == Material.WATER || fluid.getType() == XMaterial.BUBBLE_COLUMN.parseMaterial()) { /** * With water we can be sure to find an infinite source whenever we * go further than a block, so we can just remove the water here and @@ -199,32 +200,34 @@ private Block findNextFluid(@Nonnull Block fluid) { } private @Nonnull ItemStack getFilledBottle(@Nonnull Block fluid) { - switch (fluid.getType()) { - case WATER: - case BUBBLE_COLUMN: - ItemStack waterBottle = new ItemStack(Material.POTION); - PotionMeta meta = (PotionMeta) waterBottle.getItemMeta(); - if (Slimefun.getMinecraftVersion().isBefore(20, 2)) { - meta.setBasePotionData(new PotionData(PotionType.WATER)); - } else { - meta.setBasePotionType(PotionType.WATER); - } - waterBottle.setItemMeta(meta); - return waterBottle; - default: - return new ItemStack(Material.GLASS_BOTTLE); + // BUBBLE_COLUMN (1.13+) is absent on the 1.8.8 enum, so compare against XMaterial-resolved + // constants instead of a switch. WATER and BUBBLE_COLUMN shared a fall-through body originally. + Material type = fluid.getType(); + if (type == XMaterial.WATER.parseMaterial() || type == XMaterial.BUBBLE_COLUMN.parseMaterial()) { + ItemStack waterBottle = new ItemStack(Material.POTION); + PotionMeta meta = (PotionMeta) waterBottle.getItemMeta(); + if (Slimefun.getMinecraftVersion().isBefore(20, 2)) { + PotionCompat.setBasePotionData(meta, new PotionData(PotionType.WATER)); + } else { + PotionCompat.setBasePotionType(meta, PotionType.WATER); + } + waterBottle.setItemMeta(meta); + return waterBottle; + } else { + return new ItemStack(Material.GLASS_BOTTLE); } } private @Nonnull ItemStack getFilledBucket(@Nonnull Block fluid) { - return switch (fluid.getType()) { - case LAVA -> new ItemStack(Material.LAVA_BUCKET); - case WATER, - BUBBLE_COLUMN -> new ItemStack(Material.WATER_BUCKET); - default -> - // Fallback for any new liquids - new ItemStack(Material.BUCKET); - }; + Material type = fluid.getType(); + if (type == XMaterial.LAVA.parseMaterial()) { + return new ItemStack(Material.LAVA_BUCKET); + } else if (type == XMaterial.WATER.parseMaterial() || type == XMaterial.BUBBLE_COLUMN.parseMaterial()) { + return new ItemStack(Material.WATER_BUCKET); + } else { + // Fallback for any new liquids + return new ItemStack(Material.BUCKET); + } } /** @@ -237,11 +240,11 @@ private Block findNextFluid(@Nonnull Block fluid) { */ private boolean isSource(@Nonnull Block block) { if (block.isLiquid()) { - BlockData data = block.getBlockData(); + Object data = BlockDataCompat.getBlockData(block); - if (data instanceof Levelled levelled) { - // Check if this is a full block. - return levelled.getLevel() == 0; + if (BlockDataCompat.isInstance(data, "org.bukkit.block.data.Levelled")) { + // A level of 0 means this is a full (source) block. + return BlockDataCompat.getInt(data, "getLevel") == 0; } } @@ -264,3 +267,4 @@ public boolean isSynchronized() { }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FoodComposter.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FoodComposter.java index 7a2efcb226..f88b11c6b9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FoodComposter.java @@ -1,16 +1,18 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFertilizer; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.OrganicFertilizer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class FoodComposter extends AContainer implements RecipeDisplayItem { @@ -40,7 +42,8 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_HOE); + return MaterialCompat.stack(XMaterial.GOLDEN_HOE); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FoodFabricator.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FoodFabricator.java index b03e81cc3e..bce86cc4c3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/FoodFabricator.java @@ -1,15 +1,17 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFood; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.OrganicFood; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class FoodFabricator extends AContainer { @@ -22,14 +24,14 @@ protected void registerDefaultRecipes() { registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.WHEAT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.WHEAT_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.CARROT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.CARROT_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.POTATO) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.POTATO_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.WHEAT_SEEDS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SEEDS_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.BEETROOT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.BEETROOT_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.MELON_SLICE) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.MELON_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), MaterialCompat.stack(XMaterial.WHEAT_SEEDS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SEEDS_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), MaterialCompat.stack(XMaterial.BEETROOT) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.BEETROOT_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), MaterialCompat.stack(XMaterial.MELON_SLICE) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.MELON_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.APPLE) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.APPLE_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.DRIED_KELP) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.KELP_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.COCOA_BEANS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.COCOA_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.SWEET_BERRIES) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); - registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(Material.SEAGRASS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SEAGRASS_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), MaterialCompat.stack(XMaterial.DRIED_KELP) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.KELP_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), MaterialCompat.stack(XMaterial.COCOA_BEANS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.COCOA_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), MaterialCompat.stack(XMaterial.SWEET_BERRIES) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); + registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN.item(), MaterialCompat.stack(XMaterial.SEAGRASS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SEAGRASS_ORGANIC_FOOD, OrganicFood.OUTPUT).item() }); } @Override @@ -39,7 +41,8 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_HOE); + return MaterialCompat.stack(XMaterial.GOLDEN_HOE); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Freezer.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/Freezer.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Freezer.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/Freezer.java index 2da6de3dd8..eb7dd75a13 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Freezer.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/Freezer.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import java.util.ArrayList; import java.util.List; @@ -6,17 +6,19 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link Freezer} can freeze items into its frozen state, e.g. water to ice. @@ -40,18 +42,18 @@ protected void registerDefaultRecipes() { // This if statement makes the transformation follow Minecraft logic if (useVanillaRatios.getValue()) { registerRecipe(4, new ItemStack[] { new ItemStack(Material.ICE, 9) }, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }); - registerRecipe(6, new ItemStack[] { new ItemStack(Material.PACKED_ICE, 9) }, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }); + registerRecipe(6, new ItemStack[] { new ItemStack(Material.PACKED_ICE, 9) }, new ItemStack[] { MaterialCompat.stack(XMaterial.BLUE_ICE) }); } else { registerRecipe(4, new ItemStack[] { new ItemStack(Material.ICE) }, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }); - registerRecipe(6, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }); + registerRecipe(6, new ItemStack[] { new ItemStack(Material.PACKED_ICE) }, new ItemStack[] { MaterialCompat.stack(XMaterial.BLUE_ICE) }); } registerRecipe(2, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) }, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.ICE) }); registerRecipe(8, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.OBSIDIAN) }); - registerRecipe(8, new ItemStack[] { new ItemStack(Material.BLUE_ICE) }, new ItemStack[] { SlimefunItems.REACTOR_COOLANT_CELL.item() }); + registerRecipe(8, new ItemStack[] { MaterialCompat.stack(XMaterial.BLUE_ICE) }, new ItemStack[] { SlimefunItems.REACTOR_COOLANT_CELL.item() }); registerRecipe(6, new ItemStack[] { new ItemStack(Material.SNOW_BLOCK, 2) }, new ItemStack[] { new ItemStack(Material.ICE) }); registerRecipe(6, new ItemStack[] { new ItemStack(Material.MAGMA_CREAM) }, new ItemStack[] { new ItemStack(Material.SLIME_BALL) }); - registerRecipe(6, new ItemStack[] { new ItemStack(Material.MAGMA_BLOCK, 2) }, new ItemStack[] { new ItemStack(Material.SLIME_BLOCK) }); + registerRecipe(6, new ItemStack[] { MaterialCompat.stack(XMaterial.MAGMA_BLOCK, 2) }, new ItemStack[] { new ItemStack(Material.SLIME_BLOCK) }); } @Override @@ -68,7 +70,7 @@ public List getDisplayRecipes() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.GOLDEN_PICKAXE); + return MaterialCompat.stack(XMaterial.GOLDEN_PICKAXE); } @Override @@ -77,3 +79,4 @@ public String getMachineIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/HeatedPressureChamber.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/HeatedPressureChamber.java index b1aacbc8f7..14092b4499 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/HeatedPressureChamber.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import java.util.ArrayList; import java.util.Collections; @@ -14,12 +14,12 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -106,3 +106,4 @@ public String getMachineIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Refinery.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/Refinery.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Refinery.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/Refinery.java index 98cc035072..7f8d8d65ef 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/Refinery.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/Refinery.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; @@ -33,3 +33,4 @@ public String getMachineIdentifier() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java index 8997df479e..4affdfc0f3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/AbstractGrowthAccelerator.java @@ -1,22 +1,23 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; @@ -54,7 +55,7 @@ public void onBlockBreak(Block b) { private void constructMenu(BlockMenuPreset preset) { for (int i : BORDER) { - preset.addItem(i, CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(XMaterial.CYAN_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); } } @@ -93,3 +94,4 @@ public boolean isSynchronized() { protected abstract void tick(Block b); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AnimalGrowthAccelerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/AnimalGrowthAccelerator.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AnimalGrowthAccelerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/AnimalGrowthAccelerator.java index 3bb587f914..b646216de1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/AnimalGrowthAccelerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/AnimalGrowthAccelerator.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import org.bukkit.block.Block; import org.bukkit.entity.Ageable; @@ -6,13 +9,13 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -38,7 +41,7 @@ public int getCapacity() { protected void tick(Block b) { BlockMenu inv = BlockStorage.getInventory(b); - for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), RADIUS, RADIUS, RADIUS, this::isReadyToGrow)) { + for (Entity n : EntityCompat.getNearbyEntities(b.getWorld(), b.getLocation(), RADIUS, RADIUS, RADIUS, this::isReadyToGrow)) { for (int slot : getInputSlots()) { if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), organicFood, false, false)) { if (getCharge(b.getLocation()) < ENERGY_CONSUMPTION) { @@ -54,7 +57,7 @@ protected void tick(Block b) { ageable.setAge(0); } - n.getWorld().spawnParticle(VersionedParticle.HAPPY_VILLAGER, ((LivingEntity) n).getEyeLocation(), 8, 0.2F, 0.2F, 0.2F); + ParticleCompat.spawn(n.getWorld(), VersionedParticle.HAPPY_VILLAGER, ((LivingEntity) n).getEyeLocation(), 8, 0.2F, 0.2F, 0.2F); return; } } @@ -62,7 +65,7 @@ protected void tick(Block b) { } private boolean isReadyToGrow(Entity n) { - return n instanceof Ageable ageable && n.isValid() && !ageable.isAdult(); - } + return n instanceof Ageable && n.isValid() && !((Ageable) n).isAdult(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/CropGrowthAccelerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/CropGrowthAccelerator.java similarity index 61% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/CropGrowthAccelerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/CropGrowthAccelerator.java index b5d032f459..759f83b65d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/CropGrowthAccelerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/CropGrowthAccelerator.java @@ -1,17 +1,19 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import org.bukkit.block.Block; -import org.bukkit.block.data.Ageable; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -54,18 +56,18 @@ protected void tick(Block b) { } private boolean grow(Block machine, BlockMenu inv, Block crop) { - Ageable ageable = (Ageable) crop.getBlockData(); + Object ageable = BlockDataCompat.getBlockData(crop); - if (ageable.getAge() < ageable.getMaximumAge()) { + if (BlockDataCompat.getInt(ageable, "getAge") < BlockDataCompat.getInt(ageable, "getMaximumAge")) { for (int slot : getInputSlots()) { if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), organicFertilizer, false, false)) { removeCharge(machine.getLocation(), getEnergyConsumption()); inv.consumeItem(slot); - ageable.setAge(ageable.getAge() + 1); - crop.setBlockData(ageable); + BlockDataCompat.set(ageable, "setAge", BlockDataCompat.getInt(ageable, "getAge") + 1); + BlockDataCompat.setBlockData(crop, ageable); - crop.getWorld().spawnParticle(VersionedParticle.HAPPY_VILLAGER, crop.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F); + ParticleCompat.spawn(crop.getWorld(), VersionedParticle.HAPPY_VILLAGER, crop.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F); return true; } } @@ -75,3 +77,4 @@ private boolean grow(Block machine, BlockMenu inv, Block crop) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/TreeGrowthAccelerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/TreeGrowthAccelerator.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/TreeGrowthAccelerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/TreeGrowthAccelerator.java index 51d50cde95..16a92e0727 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/TreeGrowthAccelerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/TreeGrowthAccelerator.java @@ -1,24 +1,27 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.Tag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.type.Sapling; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -79,8 +82,8 @@ private boolean tryToBoostGrowth(Block machine, BlockMenu inv, Block sapling) { // On 1.17+ we can actually simulate bonemeal :O return applyBoneMeal(machine, sapling, inv); } else { - Sapling saplingData = (Sapling) sapling.getBlockData(); - return saplingData.getStage() < saplingData.getMaximumStage() && updateSaplingData(machine, sapling, inv, saplingData); + Object saplingData = BlockDataCompat.getBlockData(sapling); + return BlockDataCompat.getInt(saplingData, "getStage") < BlockDataCompat.getInt(saplingData, "getMaximumStage") && updateSaplingData(machine, sapling, inv, saplingData); } } @@ -90,10 +93,10 @@ private boolean applyBoneMeal(Block machine, Block sapling, BlockMenu inv) { if (isFertilizer(inv.getItemInSlot(slot))) { removeCharge(machine.getLocation(), ENERGY_CONSUMPTION); - sapling.applyBoneMeal(BlockFace.UP); + ReflectionCompat.invoke(sapling, "applyBoneMeal", BlockFace.UP); inv.consumeItem(slot); - sapling.getWorld().spawnParticle(VersionedParticle.HAPPY_VILLAGER, sapling.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F); + ParticleCompat.spawn(sapling.getWorld(), VersionedParticle.HAPPY_VILLAGER, sapling.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F); return true; } } @@ -102,16 +105,16 @@ private boolean applyBoneMeal(Block machine, Block sapling, BlockMenu inv) { } @ParametersAreNonnullByDefault - private boolean updateSaplingData(Block machine, Block block, BlockMenu inv, Sapling sapling) { + private boolean updateSaplingData(Block machine, Block block, BlockMenu inv, Object sapling) { for (int slot : getInputSlots()) { if (isFertilizer(inv.getItemInSlot(slot))) { removeCharge(machine.getLocation(), ENERGY_CONSUMPTION); - sapling.setStage(sapling.getStage() + 1); - block.setBlockData(sapling, false); + BlockDataCompat.set(sapling, "setStage", BlockDataCompat.getInt(sapling, "getStage") + 1); + BlockDataCompat.setBlockData(block, sapling, false); inv.consumeItem(slot); - block.getWorld().spawnParticle(VersionedParticle.HAPPY_VILLAGER, block.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F); + ParticleCompat.spawn(block.getWorld(), VersionedParticle.HAPPY_VILLAGER, block.getLocation().add(0.5D, 0.5D, 0.5D), 4, 0.1F, 0.1F, 0.1F); return true; } } @@ -124,3 +127,4 @@ protected boolean isFertilizer(@Nullable ItemStack item) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/package-info.java similarity index 62% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/package-info.java index 96accec694..3496a71ae2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/accelerators/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/accelerators/package-info.java @@ -2,4 +2,4 @@ * This package contains any electric machines related to growth accelerations. * These growth accelerators speed up the growth of animals or plants. */ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java index 9f4e03f481..f2a35705df 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/enchanting/AbstractEnchantmentMachine.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting; import java.util.Collections; import java.util.List; @@ -13,12 +13,12 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -98,3 +98,4 @@ protected boolean isEnchantmentAmountAllowed(int numberOfEnchants) { return numberOfEnchants <= maxEnchants.getValue(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/enchanting/AutoDisenchanter.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/enchanting/AutoDisenchanter.java index 61f38c5b75..48653342c8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/AutoDisenchanter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/enchanting/AutoDisenchanter.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.KeyedCompat; import java.util.HashMap; import java.util.Map; @@ -16,12 +19,12 @@ import org.bukkit.inventory.meta.Repairable; import io.github.bakedlibs.dough.inventory.InvUtils; -import io.github.thebusybiscuit.slimefun4.api.events.AutoDisenchantEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.events.AutoDisenchantEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; @@ -145,7 +148,7 @@ private void transferEnchantments(ItemStack item, ItemStack book, Map dro private void updateBlockInventory(BlockMenu menu, Block b) { if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), KEY_ENABLED) == null || BlockStorage.getLocationInfo(b.getLocation(), KEY_ENABLED).equals(String.valueOf(false))) { - menu.replaceExistingItem(22, CustomItemStack.create(Material.GUNPOWDER, "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine")); + menu.replaceExistingItem(22, CustomItemStack.create(XMaterial.GUNPOWDER.parseMaterial(), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine")); menu.addMenuClickHandler(22, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, KEY_ENABLED, String.valueOf(true)); updateBlockInventory(menu, b); @@ -176,7 +177,7 @@ private void updateBlockInventory(BlockMenu menu, Block b) { double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET) == null) ? 3.0F : Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET)); - menu.replaceExistingItem(31, CustomItemStack.create(Material.PISTON, "&7Offset: &3" + offset + " Block(s)", "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); + menu.replaceExistingItem(31, CustomItemStack.create(XMaterial.PISTON.parseMaterial(), "&7Offset: &3" + offset + " Block(s)", "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1")); menu.addMenuClickHandler(31, (p, slot, item, action) -> { double offsetv = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET)) + (action.isRightClicked() ? -0.1F : 0.1F)); BlockStorage.addBlockInfo(b, KEY_OFFSET, String.valueOf(offsetv)); @@ -281,7 +282,7 @@ private void consumeResources(BlockMenu inv) { protected void constructMenu(BlockMenuPreset preset) { preset.addItem(1, CustomItemStack.create(getHead(), "&7Head Slot", "", "&fThis Slot accepts the head type"), ChestMenuUtils.getEmptyClickHandler()); preset.addItem(7, CustomItemStack.create(getBody(), "&7Body Slot", "", "&fThis Slot accepts the body type"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(13, CustomItemStack.create(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, CustomItemStack.create(XMaterial.CLOCK.parseMaterial(), "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); } @Override @@ -302,3 +303,4 @@ public EnergyNetComponentType getEnergyComponentType() { public abstract T spawnEntity(Location l); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AnimalProduce.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/AnimalProduce.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AnimalProduce.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/AnimalProduce.java index ed4e2c381f..bf97874592 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AnimalProduce.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/AnimalProduce.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities; import java.util.function.Predicate; @@ -37,3 +37,4 @@ public boolean test(@Nonnull LivingEntity entity) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/AutoBreeder.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/AutoBreeder.java index 072b69f968..53a5917d70 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/AutoBreeder.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/AutoBreeder.java @@ -1,9 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.entity.Animals; @@ -12,17 +17,17 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; @@ -30,6 +35,7 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class AutoBreeder extends SlimefunItem implements InventoryBlock, EnergyNetComponent { @@ -65,7 +71,7 @@ public void onBlockBreak(Block b) { protected void constructMenu(BlockMenuPreset preset) { for (int i : border) { - preset.addItem(i, CustomItemStack.create(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false); + preset.addItem(i, CustomItemStack.create(MaterialCompat.stack(XMaterial.CYAN_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false); } } @@ -109,7 +115,7 @@ public boolean isSynchronized() { protected void tick(Block b) { BlockMenu inv = BlockStorage.getInventory(b); - for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), 4.0, 2.0, 4.0, this::canBreed)) { + for (Entity n : EntityCompat.getNearbyEntities(b.getWorld(), b.getLocation(), 4.0, 2.0, 4.0, this::canBreed)) { for (int slot : getInputSlots()) { if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), organicFood, false)) { if (getCharge(b.getLocation()) < ENERGY_CONSUMPTION) { @@ -119,8 +125,8 @@ protected void tick(Block b) { removeCharge(b.getLocation(), ENERGY_CONSUMPTION); inv.consumeItem(slot); - ((Animals) n).setLoveModeTicks(600); - n.getWorld().spawnParticle(Particle.HEART, ((LivingEntity) n).getEyeLocation(), 8, 0.2F, 0.2F, 0.2F); + ReflectionCompat.invoke((Animals) n, "setLoveModeTicks", 600); + ParticleCompat.spawn(n.getWorld(), Particle.HEART, ((LivingEntity) n).getEyeLocation(), 8, 0.2F, 0.2F, 0.2F); return; } } @@ -128,11 +134,12 @@ protected void tick(Block b) { } private boolean canBreed(@Nonnull Entity n) { - if (n.isValid() && n instanceof Animals animal) { - return animal.isAdult() && animal.canBreed() && !animal.isLoveMode(); + if (n.isValid() && n instanceof Animals) { + Animals animal = (Animals) n; return animal.isAdult() && animal.canBreed() && !Boolean.TRUE.equals(ReflectionCompat.invoke(animal, "isLoveMode")); } return false; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/ExpCollector.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/ExpCollector.java index bff5364220..c131838f18 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ExpCollector.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/ExpCollector.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import java.util.Iterator; import javax.annotation.Nonnull; @@ -7,6 +8,7 @@ import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.ExperienceOrb; @@ -14,17 +16,17 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeFlask; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.KnowledgeFlask; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; @@ -50,7 +52,7 @@ public class ExpCollector extends SlimefunItem implements InventoryBlock, Energy private int energyConsumedPerTick = -1; private int energyCapacity = -1; - @Deprecated(since = "RC-38", forRemoval = true) + @Deprecated @ParametersAreNonnullByDefault public ExpCollector(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { this(itemGroup, item, recipeType, recipe, 4.0); @@ -107,7 +109,7 @@ public EnergyNetComponentType getEnergyComponentType() { protected void constructMenu(BlockMenuPreset preset) { for (int slot : border) { - preset.addItem(slot, CustomItemStack.create(Material.PURPLE_STAINED_GLASS_PANE, " "), (p, s, item, action) -> false); + preset.addItem(slot, CustomItemStack.create(XMaterial.PURPLE_STAINED_GLASS_PANE.parseMaterial(), " "), (p, s, item, action) -> false); } } @@ -129,7 +131,7 @@ public boolean isSynchronized() { protected void tick(Block block) { Location location = block.getLocation(); - Iterator iterator = block.getWorld().getNearbyEntities(location, range, range, range, n -> n instanceof ExperienceOrb && n.isValid()).iterator(); + Iterator iterator = EntityCompat.getNearbyEntities(block.getWorld(), location, range, range, range, n -> n instanceof ExperienceOrb && n.isValid()).iterator(); int experiencePoints = 0; while (iterator.hasNext() && experiencePoints == 0) { @@ -202,3 +204,4 @@ public ExpCollector setCapacity(int energyCapacity) { return this; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/IronGolemAssembler.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/IronGolemAssembler.java index 727dc342d1..7caae43550 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/IronGolemAssembler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/IronGolemAssembler.java @@ -1,21 +1,23 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.SoundCategory; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.entity.IronGolem; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link IronGolemAssembler} is an electrical machine that can automatically spawn @@ -45,12 +47,12 @@ public int getEnergyConsumption() { @Override public ItemStack getHead() { - return new ItemStack(Material.CARVED_PUMPKIN); + return MaterialCompat.stack(XMaterial.CARVED_PUMPKIN); } @Override public Material getHeadBorder() { - return Material.ORANGE_STAINED_GLASS_PANE; + return XMaterial.ORANGE_STAINED_GLASS_PANE.parseMaterial(); } @Override @@ -60,14 +62,14 @@ public ItemStack getBody() { @Override public Material getBodyBorder() { - return Material.WHITE_STAINED_GLASS_PANE; + return XMaterial.WHITE_STAINED_GLASS_PANE.parseMaterial(); } @Override protected void constructMenu(BlockMenuPreset preset) { preset.addItem(1, CustomItemStack.create(getHead(), "&7Pumpkin Slot", "", "&fThis Slot accepts Pumpkins"), ChestMenuUtils.getEmptyClickHandler()); preset.addItem(7, CustomItemStack.create(getBody(), "&7Iron Block Slot", "", "&fThis Slot accepts Iron Blocks"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(13, CustomItemStack.create(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, CustomItemStack.create(XMaterial.CLOCK.parseMaterial(), "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); } @Override @@ -76,3 +78,4 @@ public IronGolem spawnEntity(Location l) { return l.getWorld().spawn(l, IronGolem.class); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/ProduceCollector.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/ProduceCollector.java index e1d5e1f4e3..424c9cb6a2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/ProduceCollector.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/ProduceCollector.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -12,6 +13,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.entity.Ageable; import org.bukkit.entity.Cow; @@ -23,22 +25,23 @@ import io.github.bakedlibs.dough.inventory.InvUtils; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link ProduceCollector} allows you to collect produce from animals. @@ -74,9 +77,9 @@ protected void registerDefaultRecipes() { })); // Mushroom Stew from Mooshrooms - addProduce(new AnimalProduce(new ItemStack(Material.BOWL), new ItemStack(Material.MUSHROOM_STEW), n -> { - if (n instanceof MushroomCow mushroomCow) { - return mushroomCow.isAdult(); + addProduce(new AnimalProduce(new ItemStack(Material.BOWL), MaterialCompat.stack(XMaterial.MUSHROOM_STEW), n -> { + if (n instanceof MushroomCow) { + MushroomCow mushroomCow = (MushroomCow) n; return mushroomCow.isAdult(); } else { return false; } @@ -125,7 +128,7 @@ public boolean isSynchronized() { } displayRecipes.add(CustomItemStack.create(Material.BOWL, null, "&fRequires &bMooshroom &fnearby")); - displayRecipes.add(new ItemStack(Material.MUSHROOM_STEW)); + displayRecipes.add(MaterialCompat.stack(XMaterial.MUSHROOM_STEW)); return displayRecipes; } @@ -153,13 +156,13 @@ public boolean isSynchronized() { @ParametersAreNonnullByDefault private boolean isAnimalNearby(Block b, Predicate predicate) { int radius = range.getValue(); - return !b.getWorld().getNearbyEntities(b.getLocation(), radius, radius, radius, n -> isValidAnimal(n, predicate)).isEmpty(); + return !EntityCompat.getNearbyEntities(b.getWorld(), b.getLocation(), radius, radius, radius, n -> isValidAnimal(n, predicate)).isEmpty(); } @ParametersAreNonnullByDefault private boolean isValidAnimal(Entity n, Predicate predicate) { - if (n instanceof LivingEntity livingEntity) { - return predicate.test(livingEntity); + if (n instanceof LivingEntity) { + LivingEntity livingEntity = (LivingEntity) n; return predicate.test(livingEntity); } else { return false; } @@ -176,3 +179,4 @@ private boolean isValidAnimal(Entity n, Predicate predicate) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/WitherAssembler.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/WitherAssembler.java index 9ebb73f8b2..86fc3c1dd9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/WitherAssembler.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/WitherAssembler.java @@ -1,19 +1,21 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Wither; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link WitherAssembler} is an electrical machine that can automatically spawn @@ -43,12 +45,12 @@ public int getEnergyConsumption() { @Override public ItemStack getHead() { - return new ItemStack(Material.WITHER_SKELETON_SKULL, 3); + return MaterialCompat.stack(XMaterial.WITHER_SKELETON_SKULL, 3); } @Override public Material getHeadBorder() { - return Material.BLACK_STAINED_GLASS_PANE; + return XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(); } @Override @@ -58,14 +60,14 @@ public ItemStack getBody() { @Override public Material getBodyBorder() { - return Material.BROWN_STAINED_GLASS_PANE; + return XMaterial.BROWN_STAINED_GLASS_PANE.parseMaterial(); } @Override protected void constructMenu(BlockMenuPreset preset) { preset.addItem(1, CustomItemStack.create(getHead(), "&7Wither Skeleton Skull Slot", "", "&fThis Slot accepts Wither Skeleton Skulls"), ChestMenuUtils.getEmptyClickHandler()); preset.addItem(7, CustomItemStack.create(getBody(), "&7Soul Sand Slot", "", "&fThis Slot accepts Soul Sand"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(13, CustomItemStack.create(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, CustomItemStack.create(XMaterial.CLOCK.parseMaterial(), "&7Cooldown: &b30 Seconds", "", "&fThis Machine takes up to half a Minute to operate", "&fso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); } @Override @@ -74,3 +76,4 @@ public Wither spawnEntity(Location l) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/package-info.java similarity index 54% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/package-info.java index d7723caf74..b04655b410 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/entities/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/entities/package-info.java @@ -1,6 +1,6 @@ /** * This package contains any electric machines related to {@link org.bukkit.entity.Entity} interactions, most notably * the - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.AbstractEntityAssembler}. + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities.AbstractEntityAssembler}. */ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/package-info.java new file mode 100644 index 0000000000..7e4d4828a8 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/machines/package-info.java @@ -0,0 +1,8 @@ +/** + * This package contains the different implementations of + * {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} that are also an + * {@link io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent} with the type {@code CONSUMER}. + * + * Machines do not generate power, they consume it. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/package-info.java new file mode 100644 index 0000000000..2b7e04bc1c --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/package-info.java @@ -0,0 +1,6 @@ +/** + * This package contains the different implementations of + * {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} that also implement the interface + * {@link io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent} + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.electric; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/NetherStarReactor.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/NetherStarReactor.java index 56ece1a036..566b5f0ae4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NetherStarReactor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/NetherStarReactor.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -11,11 +12,11 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -43,9 +44,9 @@ protected void registerDefaultFuelTypes() { @Override public void extraTick(@Nonnull Location l) { Slimefun.runSync(() -> { - for (Entity entity : l.getWorld().getNearbyEntities(l, 5, 5, 5, n -> n instanceof LivingEntity && n.isValid())) { - if (entity instanceof LivingEntity livingEntity) { - livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 60, 1)); + for (Entity entity : EntityCompat.getNearbyEntities(l.getWorld(), l, 5, 5, 5, n -> n instanceof LivingEntity && n.isValid())) { + if (entity instanceof LivingEntity) { + LivingEntity livingEntity = (LivingEntity) entity; livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 60, 1)); } } }); @@ -67,3 +68,4 @@ public ItemStack getProgressBar() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/NuclearReactor.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/NuclearReactor.java index 7e30bf7e93..8b017e1356 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/NuclearReactor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/NuclearReactor.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,11 +6,11 @@ import org.bukkit.Location; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactive; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -60,3 +60,4 @@ public void extraTick(@Nonnull Location l) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/Reactor.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/Reactor.java index aeb3477799..8f1cef8d4c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/Reactor.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors; import java.util.HashMap; import java.util.HashSet; @@ -13,6 +13,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -21,23 +22,23 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.events.ReactorExplodeEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider; -import io.github.thebusybiscuit.slimefun4.implementation.operations.FuelOperation; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.events.ReactorExplodeEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun5.core.attributes.MachineProcessHolder; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineProcessor; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.ReactorAccessPort; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.AbstractEnergyProvider; +import io.github.thebusybiscuit.slimefun5.implementation.operations.FuelOperation; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -167,7 +168,7 @@ protected void updateInventory(@Nonnull BlockMenu menu, @Nonnull Block b) { BlockMenu port = getAccessPort(b.getLocation()); if (port != null) { - menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(Material.GREEN_WOOL, "&7Access Port", "", "&6Detected", "", "&7> Click to view Access Port")); + menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(XMaterial.GREEN_WOOL.parseMaterial(), "&7Access Port", "", "&6Detected", "", "&7> Click to view Access Port")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { port.open(p); updateInventory(menu, b); @@ -175,7 +176,7 @@ protected void updateInventory(@Nonnull BlockMenu menu, @Nonnull Block b) { return false; }); } else { - menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(Material.RED_WOOL, "&7Access Port", "", "&cNot detected", "", "&7Access Port must be", "&7placed 3 blocks above", "&7a reactor!")); + menu.replaceExistingItem(INFO_SLOT, CustomItemStack.create(XMaterial.RED_WOOL.parseMaterial(), "&7Access Port", "", "&cNot detected", "", "&7Access Port must be", "&7placed 3 blocks above", "&7a reactor!")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { updateInventory(menu, b); menu.open(p); @@ -190,19 +191,19 @@ private void constructMenu(@Nonnull BlockMenuPreset preset) { } for (int i : border_1) { - preset.addItem(i, CustomItemStack.create(Material.LIME_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(XMaterial.LIME_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); } for (int i : border_3) { - preset.addItem(i, CustomItemStack.create(Material.GREEN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(XMaterial.GREEN_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); } - preset.addItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(22, CustomItemStack.create(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); preset.addItem(1, CustomItemStack.create(getFuelIcon(), "&7Fuel Slot", "", "&fThis Slot accepts radioactive Fuel such as:", "&2Uranium &for &aNeptunium"), ChestMenuUtils.getEmptyClickHandler()); for (int i : border_2) { - preset.addItem(i, CustomItemStack.create(Material.CYAN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(i, CustomItemStack.create(XMaterial.CYAN_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); } if (needsCooling()) { @@ -364,7 +365,7 @@ private void checkForWaterBlocks(Location l) { } private void createByproduct(@Nonnull Location l, @Nonnull BlockMenu inv, @Nullable BlockMenu accessPort, @Nonnull FuelOperation operation) { - inv.replaceExistingItem(22, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " ")); + inv.replaceExistingItem(22, CustomItemStack.create(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), " ")); ItemStack result = operation.getResult(); if (result != null) { @@ -488,3 +489,4 @@ protected BlockMenu getAccessPort(@Nonnull Location l) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/ReactorMode.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/ReactorMode.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/ReactorMode.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/ReactorMode.java index 82fd1c354e..2dba17230e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/ReactorMode.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/ReactorMode.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors; import java.util.Locale; @@ -32,3 +32,4 @@ public String toString() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/package-info.java new file mode 100644 index 0000000000..6f2c575468 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/electric/reactors/package-info.java @@ -0,0 +1,5 @@ +/** + * This package contains the different implementations of + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.Reactor}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/ElevatorFloor.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/ElevatorFloor.java index be9245e51a..b0f5444433 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorFloor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/ElevatorFloor.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.elevator; +package io.github.thebusybiscuit.slimefun5.implementation.items.elevator; import javax.annotation.Nonnull; @@ -88,4 +88,4 @@ public int getNumber() { return number; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/ElevatorPlate.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/ElevatorPlate.java index 44fde1a2b8..70c9d2e7ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/ElevatorPlate.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/ElevatorPlate.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.elevator; +package io.github.thebusybiscuit.slimefun5.implementation.items.elevator; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.WorldCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import java.util.HashSet; import java.util.LinkedList; @@ -20,15 +24,15 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -94,7 +98,7 @@ public void onPlayerPlace(BlockPlaceEvent e) { LinkedList floors = new LinkedList<>(); int index = 0; - for (int y = b.getWorld().getMinHeight(); y < b.getWorld().getMaxHeight(); y++) { + for (int y = WorldCompat.getMinHeight(b.getWorld()); y < b.getWorld().getMaxHeight(); y++) { if (y == b.getY()) { String name = ChatColors.color(BlockStorage.getLocationInfo(b.getLocation(), DATA_KEY)); floors.addFirst(new ElevatorFloor(name, index, b)); @@ -193,7 +197,7 @@ private void teleport(Player player, ElevatorFloor floor) { PaperLib.teleportAsync(player, destination).thenAccept(teleported -> { if (teleported.booleanValue()) { - player.sendTitle(ChatColor.WHITE + ChatColors.color(floor.getName()), null, 20, 60, 20); + ReflectionCompat.invoke(player, "sendTitle", ChatColor.WHITE + ChatColors.color(floor.getName()), null, 20, 60, 20); } }); }); @@ -227,3 +231,4 @@ public void openEditor(Player p, Block b) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/package-info.java new file mode 100644 index 0000000000..282e23b04a --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/elevator/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds the {@link io.github.thebusybiscuit.slimefun5.implementation.items.elevator.ElevatorPlate} and any + * related classes to making the elevator work. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.elevator; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/BirthdayCake.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/BirthdayCake.java similarity index 60% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/BirthdayCake.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/BirthdayCake.java index 9544132ad0..3e34dfb0aa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/BirthdayCake.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/BirthdayCake.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; /** * The {@link BirthdayCake} is a seasonal item which only appears in october. @@ -25,3 +25,4 @@ public BirthdayCake(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/DietCookie.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/DietCookie.java similarity index 50% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/DietCookie.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/DietCookie.java index 08bf524e5d..7f23583913 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/DietCookie.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/DietCookie.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,13 +7,14 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link DietCookie} gives you a {@link PotionEffect} of Type {@code PotionEffectType.LEVITATION} @@ -38,11 +39,15 @@ public DietCookie(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe Slimefun.getLocalization().sendMessage(p, "messages.diet-cookie"); SoundEffect.DIET_COOKIE_CONSUME_SOUND.playFor(p); - if (p.hasPotionEffect(PotionEffectType.LEVITATION)) { - p.removePotionEffect(PotionEffectType.LEVITATION); - } + // LEVITATION is 1.9+ (null on older servers, where this effect simply cannot apply). + if (VersionedPotionEffectType.LEVITATION != null) { + if (p.hasPotionEffect(VersionedPotionEffectType.LEVITATION)) { + p.removePotionEffect(VersionedPotionEffectType.LEVITATION); + } - p.addPotionEffect(PotionEffectType.LEVITATION.createEffect(60, 1)); + p.addPotionEffect(VersionedPotionEffectType.LEVITATION.createEffect(60, 1)); + } }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/FortuneCookie.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/FortuneCookie.java index c39ec147d7..dfb8b2742f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/FortuneCookie.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import java.util.List; import java.util.concurrent.ThreadLocalRandom; @@ -9,14 +9,14 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.core.services.LocalizationService; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link FortuneCookie} is a rather simple {@link SlimefunItem}, it's a cookie which @@ -44,3 +44,4 @@ public ItemConsumptionHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/HeavyCream.java similarity index 59% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/HeavyCream.java index e5ac3be9aa..45ff6dc9ce 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/HeavyCream.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/HeavyCream.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import java.util.Optional; @@ -8,12 +8,13 @@ import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * This {@link SlimefunItem} can be obtained by crafting, it's @@ -35,10 +36,10 @@ public ItemUseHandler getItemHandler() { return e -> { Optional block = e.getClickedBlock(); - if (!block.isPresent() || !block.get().getType().isInteractable()) { + if (!block.isPresent() || !MaterialCompat.isInteractable(block.get().getType())) { e.cancel(); } }; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/Juice.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/Juice.java index f8b61543e1..d07af2208c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/Juice.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.List; @@ -14,15 +16,15 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.Cooler; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.CoolerListener; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This class represents a {@link SlimefunItem} that can be stored inside @@ -49,8 +51,8 @@ public Juice(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemMeta meta = item.getItemMeta(); - if (meta instanceof PotionMeta potionMeta) { - effects = potionMeta.getCustomEffects(); + if (meta instanceof PotionMeta) { + PotionMeta potionMeta = (PotionMeta) meta; effects = potionMeta.getCustomEffects(); } else { effects = new ArrayList<>(); } @@ -84,15 +86,15 @@ public ItemConsumptionHandler getItemHandler() { */ @ParametersAreNonnullByDefault private void removeGlassBottle(Player p, ItemStack item) { - if (SlimefunUtils.isItemSimilar(item, p.getInventory().getItemInMainHand(), true)) { - if (p.getInventory().getItemInMainHand().getAmount() == 1) { - p.getEquipment().getItemInMainHand().setAmount(0); + if (SlimefunUtils.isItemSimilar(item, HandCompat.getMainHand(p.getInventory()), true)) { + if (HandCompat.getMainHand(p.getInventory()).getAmount() == 1) { + HandCompat.getMainHand(p.getEquipment()).setAmount(0); } else { p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1)); } - } else if (SlimefunUtils.isItemSimilar(item, p.getInventory().getItemInOffHand(), true)) { - if (p.getInventory().getItemInOffHand().getAmount() == 1) { - p.getEquipment().getItemInOffHand().setAmount(0); + } else if (SlimefunUtils.isItemSimilar(item, HandCompat.getOffHand(p.getInventory()), true)) { + if (HandCompat.getOffHand(p.getInventory()).getAmount() == 1) { + HandCompat.getOffHand(p.getEquipment()).setAmount(0); } else { p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1)); } @@ -100,3 +102,4 @@ private void removeGlassBottle(Player p, ItemStack item) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MagicSugar.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MagicSugar.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MagicSugar.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MagicSugar.java index ae5c85e63e..424b000c9a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MagicSugar.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MagicSugar.java @@ -1,22 +1,23 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.GameMode; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * {@link MagicSugar} is one of the oldest items in Slimefun, it is a special @@ -39,7 +40,7 @@ public MagicSugar(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe if (e.getClickedBlock().isPresent()) { Material block = e.getClickedBlock().get().getType(); - if (block == Material.DISPENSER || block == Material.ENCHANTING_TABLE) { + if (block == Material.DISPENSER || block == XMaterial.ENCHANTING_TABLE.parseMaterial()) { return; } } @@ -56,3 +57,4 @@ public MagicSugar(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MeatJerky.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MeatJerky.java index e4e6459e44..2bd911613a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MeatJerky.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * {@link MeatJerky} is just a piece of meat that gives some extra saturation. @@ -38,3 +38,4 @@ public ItemConsumptionHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MonsterJerky.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MonsterJerky.java index bdd55c2df4..0502649606 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/MonsterJerky.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,12 +6,12 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * {@link MonsterJerky} is basically just Rotten Flesh but without the Hunger Effect. @@ -40,3 +40,4 @@ public ItemConsumptionHandler getItemHandler() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/package-info.java new file mode 100644 index 0000000000..fb63ffb074 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are related to food. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.food; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/GEOMiner.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/GEOMiner.java index f7975920ae..e91d8f357b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/GEOMiner.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.geo; +package io.github.thebusybiscuit.slimefun5.implementation.items.geo; import java.util.LinkedList; import java.util.List; @@ -10,30 +10,31 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemState; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.SimpleBlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.operations.GEOMiningOperation; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemState; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.attributes.HologramOwner; +import io.github.thebusybiscuit.slimefun5.core.attributes.MachineProcessHolder; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineProcessor; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.SimpleBlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.operations.GEOMiningOperation; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock; @@ -258,7 +259,7 @@ protected void constructMenu(@Nonnull BlockMenuPreset preset) { preset.addItem(i, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); } - preset.addItem(4, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(4, CustomItemStack.create(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), " "), ChestMenuUtils.getEmptyClickHandler()); for (int i : OUTPUT_SLOTS) { preset.addMenuClickHandler(i, ChestMenuUtils.getDefaultOutputHandler()); @@ -296,7 +297,7 @@ protected void tick(@Nonnull Block b) { removeCharge(b.getLocation(), getEnergyConsumption()); operation.addProgress(getSpeed()); } else { - inv.replaceExistingItem(4, CustomItemStack.create(Material.BLACK_STAINED_GLASS_PANE, " ")); + inv.replaceExistingItem(4, CustomItemStack.create(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), " ")); inv.pushItem(operation.getResult(), OUTPUT_SLOTS); processor.endOperation(b); @@ -336,3 +337,4 @@ private void start(@Nonnull Block b, @Nonnull BlockMenu inv) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/GEOScanner.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/GEOScanner.java index 735e407964..8c1b0dbf9c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/GEOScanner.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.geo; +package io.github.thebusybiscuit.slimefun5.implementation.items.geo; import java.util.Optional; @@ -10,12 +10,12 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; public class GEOScanner extends SimpleSlimefunItem { @@ -48,3 +48,4 @@ private boolean hasAccess(Player p, Location l) { return p.hasPermission("slimefun.gps.bypass") || (Slimefun.getProtectionManager().hasPermission(p, l, Interaction.INTERACT_BLOCK)); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/OilPump.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/OilPump.java index 412a65ad7b..870d022d9c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/OilPump.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.geo; +package io.github.thebusybiscuit.slimefun5.implementation.items.geo; import java.util.Arrays; import java.util.List; @@ -7,26 +7,28 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class OilPump extends AContainer implements RecipeDisplayItem { @@ -38,7 +40,7 @@ public class OilPump extends AContainer implements RecipeDisplayItem { public OilPump(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe); - oil = Slimefun.getRegistry().getGEOResources().get(new NamespacedKey(Slimefun.instance(), "oil")).orElse(null); + oil = Slimefun.getRegistry().getGEOResources().get(new NamespacedKey(Slimefun.instance(), "oil")); new BlockMenuPreset(getId(), getInventoryTitle()) { @@ -84,7 +86,7 @@ public String getMachineIdentifier() { @Override public ItemStack getProgressBar() { - return new ItemStack(Material.DIAMOND_SHOVEL); + return MaterialCompat.stack(XMaterial.DIAMOND_SHOVEL); } @Override @@ -119,3 +121,4 @@ protected MachineRecipe findNextRecipe(BlockMenu inv) { return null; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/PortableGEOScanner.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/PortableGEOScanner.java index 88350314ca..6af8505aaf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/PortableGEOScanner.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.geo; +package io.github.thebusybiscuit.slimefun5.implementation.items.geo; import java.util.Optional; @@ -7,12 +7,12 @@ import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; public class PortableGEOScanner extends SimpleSlimefunItem { @@ -32,3 +32,4 @@ public ItemUseHandler getItemHandler() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/package-info.java new file mode 100644 index 0000000000..0786f7c360 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/geo/package-info.java @@ -0,0 +1,8 @@ +/** + * This package holds implementations of any {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} that + * deals with the {@link io.github.thebusybiscuit.slimefun5.api.geo.GEOResource} API. + * The most prominent example of this being the + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOScanner} and the + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOMiner}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.geo; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSControlPanel.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSControlPanel.java index 2857da1b0d..51d794cb13 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSControlPanel.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.gps; +package io.github.thebusybiscuit.slimefun5.implementation.items.gps; import java.util.Optional; @@ -10,12 +10,12 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; public class GPSControlPanel extends SimpleSlimefunItem { @@ -47,3 +47,4 @@ private boolean hasAccess(Player p, Location l) { return p.hasPermission("slimefun.gps.bypass") || (Slimefun.getProtectionManager().hasPermission(p, l, Interaction.INTERACT_BLOCK)); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSMarkerTool.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSMarkerTool.java index 65c430237a..43b75a465b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSMarkerTool.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.gps; +package io.github.thebusybiscuit.slimefun5.implementation.items.gps; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,14 +6,14 @@ import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.gps.Waypoint; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link GPSMarkerTool} allows you to create a {@link Waypoint} at your current @@ -43,3 +43,4 @@ public ItemUseHandler getItemHandler() { }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSTransmitter.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSTransmitter.java index db34d6cbdd..a7e377b769 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/GPSTransmitter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.gps; +package io.github.thebusybiscuit.slimefun5.implementation.items.gps; import java.util.List; import java.util.UUID; @@ -12,16 +12,16 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -102,3 +102,4 @@ public EnergyNetComponentType getEnergyComponentType() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/package-info.java new file mode 100644 index 0000000000..8b491ad982 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/gps/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are related to the {@link io.github.thebusybiscuit.slimefun5.api.gps.GPSNetwork}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.gps; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/BeeWings.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/BeeWings.java similarity index 59% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/BeeWings.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/BeeWings.java index a632c9facf..27b1fe9955 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/BeeWings.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/BeeWings.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeWingsListener; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.BeeWingsTask; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BeeWingsListener; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.BeeWingsTask; /** * The {@link BeeWings} are a special form of the elytra which gives you a slow falling effect @@ -30,3 +30,4 @@ public BeeWings(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTy } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfernalBonemeal.java similarity index 60% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfernalBonemeal.java index a49e08e922..137c66565d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfernalBonemeal.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; import java.util.Optional; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,17 +8,17 @@ import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; -import org.bukkit.block.data.Ageable; import org.bukkit.event.Event.Result; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link InfernalBonemeal} is a special type of bone meal which will work on @@ -42,12 +43,12 @@ public ItemUseHandler getItemHandler() { if (block.isPresent()) { Block b = block.get(); - if (b.getType() == Material.NETHER_WART) { - Ageable ageable = (Ageable) b.getBlockData(); + if (b.getType() == XMaterial.NETHER_WART.parseMaterial()) { + Object ageable = BlockDataCompat.getBlockData(b); - if (ageable.getAge() < ageable.getMaximumAge()) { - ageable.setAge(ageable.getMaximumAge()); - b.setBlockData(ageable); + if (BlockDataCompat.getInt(ageable, "getAge") < BlockDataCompat.getInt(ageable, "getMaximumAge")) { + BlockDataCompat.set(ageable, "setAge", BlockDataCompat.getInt(ageable, "getMaximumAge")); + BlockDataCompat.setBlockData(b, ageable); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK); if (e.getPlayer().getGameMode() != GameMode.CREATIVE) { @@ -60,3 +61,4 @@ public ItemUseHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedHopper.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfusedHopper.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedHopper.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfusedHopper.java index ba780ba2e7..594b22491c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedHopper.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfusedHopper.java @@ -1,27 +1,28 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.data.type.Hopper; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.DoubleRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.handlers.VanillaInventoryDropHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -67,13 +68,14 @@ public void tick(Block b, SlimefunItem sfItem, Config data) { // Check if this was enabled in the config if (toggleable.getValue()) { - Hopper hopper = (Hopper) b.getBlockData(); + Object hopper = BlockDataCompat.getBlockData(b); /* * If the Hopper was disabled by a redstone signal, - * we just don't do anything. + * we just don't do anything. (On legacy servers without block data we can't + * tell, so we assume it is enabled.) */ - if (!hopper.isEnabled()) { + if (Boolean.FALSE.equals(BlockDataCompat.get(hopper, "isEnabled"))) { return; } } @@ -83,7 +85,7 @@ public void tick(Block b, SlimefunItem sfItem, Config data) { boolean playSound = false; // Check for any nearby Items that can be picked up - for (Entity item : b.getWorld().getNearbyEntities(l, range, range, range, n -> isValidItem(l, n))) { + for (Entity item : EntityCompat.getNearbyEntities(b.getWorld(), l, range, range, range, n -> isValidItem(l, n))) { item.setVelocity(new Vector(0, 0.1, 0)); item.teleport(l); playSound = true; @@ -106,11 +108,12 @@ public boolean isSynchronized() { } private boolean isValidItem(@Nonnull Location l, @Nonnull Entity entity) { - if (entity instanceof Item item && entity.isValid()) { - // Check if the item cannot be picked up or has the "no pickup" metadata + if (entity instanceof Item && entity.isValid()) { + Item item = (Item) entity; // Check if the item cannot be picked up or has the "no pickup" metadata return item.getPickupDelay() <= 0 && !SlimefunUtils.hasNoPickupFlag(item) && item.getLocation().distanceSquared(l) > 0.25; } return false; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedMagnet.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfusedMagnet.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedMagnet.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfusedMagnet.java index 9cd3017583..e5a7c40ad4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfusedMagnet.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/InfusedMagnet.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,13 +6,13 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.DoubleRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.UnplaceableBlock; /** * The {@link InfusedMagnet} is a {@link SlimefunItem} that allows a {@link Player} to @@ -43,3 +43,4 @@ public double getRadius() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeFlask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/KnowledgeFlask.java similarity index 64% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeFlask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/KnowledgeFlask.java index 6efdebe787..38a6680aaf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeFlask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/KnowledgeFlask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,14 +7,15 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link KnowledgeFlask} is a magical {@link SlimefunItem} which allows you to store @@ -36,7 +37,7 @@ public KnowledgeFlask(ItemGroup itemGroup, SlimefunItemStack item, RecipeType re e.cancel(); Player p = e.getPlayer(); - if (p.getLevel() >= 1 && (e.getClickedBlock().isEmpty() || !(e.getClickedBlock().get().getType().isInteractable()))) { + if (p.getLevel() >= 1 && (!e.getClickedBlock().isPresent() || !(MaterialCompat.isInteractable(e.getClickedBlock().get().getType())))) { p.setLevel(p.getLevel() - 1); ItemStack item = SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.item(); @@ -53,3 +54,4 @@ public KnowledgeFlask(ItemGroup itemGroup, SlimefunItemStack item, RecipeType re } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/KnowledgeTome.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/KnowledgeTome.java index d22a41ef04..21670f41b8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/KnowledgeTome.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; import java.util.List; import java.util.UUID; @@ -15,15 +15,15 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link KnowledgeTome} allows you to copy every unlocked {@link Research} @@ -77,3 +77,4 @@ public KnowledgeTome(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/MagicEyeOfEnder.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/MagicEyeOfEnder.java index 9475a0cc01..4c129e8c1a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/MagicEyeOfEnder.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,14 +8,14 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * The {@link MagicEyeOfEnder} allows you to launch an {@link EnderPearl} @@ -54,3 +54,4 @@ private boolean hasArmor(@Nonnull PlayerInventory inv) { // @formatter:on } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/MagicalZombiePills.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/MagicalZombiePills.java index d08f61d5d2..053b7e73f3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/MagicalZombiePills.java @@ -1,11 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCompat; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.PigZombie; @@ -16,16 +19,16 @@ import io.github.bakedlibs.dough.items.ItemUtils; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * This {@link SlimefunItem} allows you to convert any {@link ZombieVillager} to @@ -57,11 +60,11 @@ public MagicalZombiePills(ItemGroup itemGroup, SlimefunItemStack item, RecipeTyp Player p = e.getPlayer(); - if (entity instanceof ZombieVillager zombieVillager) { - useItem(p, item); + if (entity instanceof ZombieVillager) { + ZombieVillager zombieVillager = (ZombieVillager) entity; useItem(p, item); healZombieVillager(zombieVillager, p); - } else if (entity instanceof PigZombie pigZombie) { - useItem(p, item); + } else if (entity instanceof PigZombie) { + PigZombie pigZombie = (PigZombie) entity; useItem(p, item); healZombifiedPiglin(pigZombie); } }; @@ -82,18 +85,19 @@ private void useItem(@Nonnull Player p, @Nonnull ItemStack item) { } // This is supposed to be a vanilla sound. No need for a SoundEffect - p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CONVERTED, 1, 1); + SoundCompat.playFor(p, p.getLocation(), "ENTITY_ZOMBIE_VILLAGER_CONVERTED", null, 1, 1); } private void healZombieVillager(@Nonnull ZombieVillager zombieVillager, @Nonnull Player p) { - zombieVillager.setConversionTime(1); - zombieVillager.setConversionPlayer(p); + ReflectionCompat.invoke(zombieVillager, "setConversionTime", 1); + ReflectionCompat.invoke(zombieVillager, "setConversionPlayer", p); } private void healZombifiedPiglin(@Nonnull PigZombie zombiePiglin) { Location loc = zombiePiglin.getLocation(); zombiePiglin.remove(); - loc.getWorld().spawnEntity(loc, EntityType.PIGLIN); + loc.getWorld().spawnEntity(loc, EntityCompat.entityType("PIGLIN")); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/SoulboundItem.java similarity index 52% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/SoulboundItem.java index 5eba932e4c..27325a4459 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/SoulboundItem.java @@ -1,17 +1,17 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.SoulboundRune; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.attributes.Soulbound; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes.SoulboundRune; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.SoulboundListener; /** * Represents an Item that will not drop upon death. @@ -31,3 +31,4 @@ public SoulboundItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType typ } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/TelepositionScroll.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/TelepositionScroll.java index f71aaf0d53..b733d2e922 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/TelepositionScroll.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,14 +8,14 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link TelepositionScroll} is a magical {@link SlimefunItem} that makes nearby any {@link LivingEntity} @@ -56,3 +56,4 @@ public ItemUseHandler getItemHandler() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/package-info.java new file mode 100644 index 0000000000..3089c44f2c --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are considered magical items. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.magical; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/ElementalRune.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/ElementalRune.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/ElementalRune.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/ElementalRune.java index 91bd28fdde..779de69146 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/ElementalRune.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/ElementalRune.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientAltar; /** * An {@link ElementalRune} is a very simple and basic crafting component @@ -33,3 +33,5 @@ public ElementalRune(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] re } } + + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/EnchantmentRune.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/EnchantmentRune.java index 40b1a9e24e..d285b92348 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/EnchantmentRune.java @@ -1,4 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEnchantment; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import java.util.ArrayList; import java.util.Collection; @@ -14,22 +19,22 @@ import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemDropHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemDropHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; /** * This {@link SlimefunItem} allows you to enchant any enchantable {@link ItemStack} with a random @@ -50,17 +55,21 @@ public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r super(itemGroup, item, recipeType, recipe); for (Material mat : Material.values()) { - if (mat.isLegacy() || !mat.isItem()) continue; + if (MaterialCompat.isLegacy(mat) || !MaterialCompat.isItem(mat)) continue; List enchantments = new ArrayList<>(); for (Enchantment enchantment : Enchantment.values()) { - if (enchantment.equals(Enchantment.BINDING_CURSE) || enchantment.equals(Enchantment.VANISHING_CURSE)) { + if (enchantment.equals(VersionedEnchantment.BINDING_CURSE) || enchantment.equals(VersionedEnchantment.VANISHING_CURSE)) { continue; } - if (enchantment.canEnchantItem(new ItemStack(mat))) { - enchantments.add(enchantment); + try { + if (enchantment.canEnchantItem(new ItemStack(mat))) { + enchantments.add(enchantment); + } + } catch (Exception | LinkageError ex) { + // Legacy NMS (1.8) throws for some material/enchantment combinations - skip them. } } @@ -96,7 +105,7 @@ private void addRandomEnchantment(@Nonnull Player p, @Nonnull Item rune) { } Location l = rune.getLocation(); - Collection entites = l.getWorld().getNearbyEntities(l, RANGE, RANGE, RANGE, this::findCompatibleItem); + Collection entites = EntityCompat.getNearbyEntities(l.getWorld(), l, RANGE, RANGE, RANGE, this::findCompatibleItem); Optional optional = entites.stream().findFirst(); if (optional.isPresent()) { @@ -142,7 +151,7 @@ private void addRandomEnchantment(@Nonnull Player p, @Nonnull Item rune) { // Being sure entities are still valid and not picked up or whatsoever. if (rune.isValid() && item.isValid() && itemStack.getAmount() == 1) { - l.getWorld().spawnParticle(VersionedParticle.ENCHANTED_HIT, l, 1); + ParticleCompat.spawn(l.getWorld(), VersionedParticle.ENCHANTED_HIT, l, 1); SoundEffect.ENCHANTMENT_RUNE_ADD_ENCHANT_SOUND.playAt(l, SoundCategory.PLAYERS); item.remove(); @@ -186,11 +195,13 @@ private void removeIllegalEnchantments(@Nonnull ItemStack target, @Nonnull List< } private boolean findCompatibleItem(@Nonnull Entity n) { - if (n instanceof Item item) { - return !isItem(item.getItemStack()); + if (n instanceof Item) { + Item item = (Item) n; return !isItem(item.getItemStack()); } return false; } } + + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/SoulboundRune.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/SoulboundRune.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/SoulboundRune.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/SoulboundRune.java index c015bce75a..116014dc9d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/SoulboundRune.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/SoulboundRune.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import java.util.Collection; import java.util.Optional; @@ -7,23 +8,23 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemDropHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Soulbound; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemDropHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.SoulboundItem; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This {@link SlimefunItem} allows you to convert any {@link ItemStack} into a @@ -70,7 +71,7 @@ private void activate(@Nonnull Player p, @Nonnull Item rune) { } Location l = rune.getLocation(); - Collection entites = l.getWorld().getNearbyEntities(l, RANGE, RANGE, RANGE, this::findCompatibleItem); + Collection entites = EntityCompat.getNearbyEntities(l.getWorld(), l, RANGE, RANGE, RANGE, this::findCompatibleItem); Optional optional = entites.stream().findFirst(); if (optional.isPresent()) { @@ -116,10 +117,12 @@ private void activate(@Nonnull Player p, @Nonnull Item rune) { * @return Whether this {@link Entity} is compatible */ private boolean findCompatibleItem(@Nonnull Entity entity) { - if (entity instanceof Item item) { - return item.getPickupDelay() <= 0 && !SlimefunUtils.isSoulbound(item.getItemStack()) && !isItem(item.getItemStack()); + if (entity instanceof Item) { + Item item = (Item) entity; return item.getPickupDelay() <= 0 && !SlimefunUtils.isSoulbound(item.getItemStack()) && !isItem(item.getItemStack()); } return false; } } + + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/VillagerRune.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/VillagerRune.java similarity index 52% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/VillagerRune.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/VillagerRune.java index fe5195e22c..2c20cd3d5e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/VillagerRune.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/VillagerRune.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VillagerCompat; import java.util.concurrent.ThreadLocalRandom; @@ -7,22 +10,22 @@ import org.bukkit.GameMode; import org.bukkit.Particle; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; /** * This {@link SlimefunItem} allows you to reset a {@link Villager} profession. @@ -46,8 +49,8 @@ public VillagerRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci return; } - if (e.getRightClicked() instanceof Villager villager) { - if (villager.getProfession() == Profession.NONE || villager.getProfession() == Profession.NITWIT) { + if (e.getRightClicked() instanceof Villager) { + Villager villager = (Villager) e.getRightClicked(); if (villager.getProfession() == VillagerCompat.profession("NONE") || villager.getProfession() == VillagerCompat.profession("NITWIT")) { return; } @@ -56,17 +59,22 @@ public VillagerRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci } // Reset Villager - villager.setVillagerExperience(0); - villager.setVillagerLevel(1); - villager.setProfession(Profession.NONE); + VillagerCompat.setVillagerExperience(villager, 0); + VillagerCompat.setVillagerLevel(villager, 1); + Profession none = VillagerCompat.profession("NONE"); + if (none != null) { + villager.setProfession(none); + } e.setCancelled(true); double offset = ThreadLocalRandom.current().nextDouble(0.5); SoundEffect.VILLAGER_RUNE_TRANSFORM_SOUND.playAt(villager.getLocation(), SoundCategory.NEUTRAL); - villager.getWorld().spawnParticle(Particle.CRIMSON_SPORE, villager.getLocation(), 10, 0, offset / 2, 0, 0); - villager.getWorld().spawnParticle(VersionedParticle.ENCHANT, villager.getLocation(), 5, 0.04, 1, 0.04); + ParticleCompat.spawn(villager.getWorld(), Particle.CRIMSON_SPORE, villager.getLocation(), 10, 0, offset / 2, 0, 0); + ParticleCompat.spawn(villager.getWorld(), VersionedParticle.ENCHANT, villager.getLocation(), 5, 0.04, 1, 0.04); } }; } } + + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/package-info.java new file mode 100644 index 0000000000..d2fe02d991 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/runes/package-info.java @@ -0,0 +1,6 @@ +/** + * This package holds any implementation of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that is an ancient rune with functionality. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes; + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/StormStaff.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/StormStaff.java similarity index 80% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/StormStaff.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/StormStaff.java index f0fcab3310..d6e5acd3d7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/StormStaff.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/StormStaff.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,8 +6,9 @@ import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; +import java.util.Set; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.World; import org.bukkit.entity.LightningStrike; import org.bukkit.entity.Player; @@ -15,13 +16,13 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.LimitedUseItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.LimitedUseItem; /** * This {@link SlimefunItem} casts a {@link LightningStrike} where you are pointing. @@ -57,7 +58,7 @@ public StormStaff(ItemGroup group, SlimefunItemStack item, RecipeType recipeType if (p.getFoodLevel() >= 4 || p.getGameMode() == GameMode.CREATIVE) { // Get a target block with max. 30 blocks of distance - Location loc = p.getTargetBlock(null, 30).getLocation(); + Location loc = p.getTargetBlock((Set) null, 30).getLocation(); if (loc.getWorld() != null && loc.getChunk().isLoaded()) { if (loc.getWorld().getPVP() && Slimefun.getProtectionManager().hasPermission(p, loc, Interaction.ATTACK_PLAYER)) { @@ -97,3 +98,4 @@ private void useItem(Player p, ItemStack item, Location loc) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WaterStaff.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/WaterStaff.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WaterStaff.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/WaterStaff.java index 9bb07f603b..2c24f40f51 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WaterStaff.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/WaterStaff.java @@ -1,17 +1,17 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link WaterStaff} is a magical {@link SlimefunItem}. @@ -38,3 +38,4 @@ public ItemUseHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WindStaff.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/WindStaff.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WindStaff.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/WindStaff.java index 4e253149e7..3180c01080 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/WindStaff.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/WindStaff.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -10,15 +10,15 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link WindStaff} is a powerful staff which launches the {@link Player} forward when right clicked. @@ -63,3 +63,4 @@ public WindStaff(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeT }; } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/package-info.java new file mode 100644 index 0000000000..6e12ff7b86 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/staves/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds any implementation of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} that is + * considered a "Magical Staff". + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/EnderTalisman.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/EnderTalisman.java index 96db7a6b53..6d201e0ea5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/EnderTalisman.java @@ -1,16 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.NamespacedKey; -import org.bukkit.block.EnderChest; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.groups.LockedItemGroup; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; /** * An {@link EnderTalisman} is a special version of {@link Talisman} @@ -44,3 +43,4 @@ public void postRegister() { */ } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/MagicianTalisman.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/MagicianTalisman.java index 6c5ad0ffb7..4fdd6cfac5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/MagicianTalisman.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans; import java.util.HashSet; import java.util.List; @@ -17,10 +17,10 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.settings.TalismanEnchantment; /** * The {@link MagicianTalisman} is a special kind of {@link Talisman} which awards a {@link Player} @@ -109,3 +109,4 @@ public boolean isEnchantmentBookAllowed() { return allowEnchantmentBooks.getValue(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/Talisman.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/Talisman.java index fe06a0aafe..70f429ae8a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/Talisman.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans; +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans; import java.util.ArrayList; import java.util.List; @@ -12,7 +12,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -28,15 +28,15 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.events.TalismanActivateEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.TalismanActivateEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; public class Talisman extends SlimefunItem { @@ -164,9 +164,10 @@ public static boolean trigger(Event e, SlimefunItem item) { @ParametersAreNonnullByDefault public static boolean trigger(Event e, SlimefunItem item, boolean sendMessage) { - if (!(item instanceof Talisman talisman)) { + if (!(item instanceof Talisman)) { return false; } + Talisman talisman = (Talisman) item; if (ThreadLocalRandom.current().nextInt(100) > talisman.getChance()) { return false; @@ -250,8 +251,8 @@ private static void applyTalismanEffects(Player p, Talisman talisman) { @ParametersAreNonnullByDefault private static void cancelEvent(Event e, Talisman talisman) { - if (e instanceof Cancellable cancellable && talisman.isEventCancelled()) { - cancellable.setCancelled(true); + if (e instanceof Cancellable && talisman.isEventCancelled()) { + Cancellable cancellable = (Cancellable) e; cancellable.setCancelled(true); } } @@ -312,20 +313,21 @@ private boolean canEffectsBeApplied(@Nonnull Player p) { @Nullable private static Player getPlayerByEventType(@Nonnull Event e) { - if (e instanceof EntityDeathEvent entityDeathEvent) { - return entityDeathEvent.getEntity().getKiller(); - } else if (e instanceof BlockBreakEvent blockBreakEvent) { - return blockBreakEvent.getPlayer(); - } else if (e instanceof BlockDropItemEvent blockDropItemEvent) { - return blockDropItemEvent.getPlayer(); - } else if (e instanceof PlayerEvent playerEvent) { - return playerEvent.getPlayer(); - } else if (e instanceof EntityEvent entityEvent) { - return (Player) entityEvent.getEntity(); - } else if (e instanceof EnchantItemEvent enchantItemEvent) { - return enchantItemEvent.getEnchanter(); + if (e instanceof EntityDeathEvent) { + EntityDeathEvent entityDeathEvent = (EntityDeathEvent) e; return entityDeathEvent.getEntity().getKiller(); + } else if (e instanceof BlockBreakEvent) { + BlockBreakEvent blockBreakEvent = (BlockBreakEvent) e; return blockBreakEvent.getPlayer(); + } else if (e instanceof BlockDropItemEvent) { + BlockDropItemEvent blockDropItemEvent = (BlockDropItemEvent) e; return blockDropItemEvent.getPlayer(); + } else if (e instanceof PlayerEvent) { + PlayerEvent playerEvent = (PlayerEvent) e; return playerEvent.getPlayer(); + } else if (e instanceof EntityEvent) { + EntityEvent entityEvent = (EntityEvent) e; return (Player) entityEvent.getEntity(); + } else if (e instanceof EnchantItemEvent) { + EnchantItemEvent enchantItemEvent = (EnchantItemEvent) e; return enchantItemEvent.getEnchanter(); } return null; } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/package-info.java new file mode 100644 index 0000000000..e2ca8c5dad --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/magical/talismans/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds any {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} related to the + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.Talisman}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Bandage.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Bandage.java index b87882cf6d..cd264ba62f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Bandage.java @@ -1,22 +1,22 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.medical; +package io.github.thebusybiscuit.slimefun5.implementation.items.medical; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; -import org.bukkit.attribute.Attribute; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; /** * A {@link Bandage} or Rag is a medical supply which heals the {@link Player} and extinguishes @@ -42,7 +42,7 @@ public ItemUseHandler getItemHandler() { Player p = e.getPlayer(); // Player is neither burning nor injured - if (p.getFireTicks() <= 0 && p.getHealth() >= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + if (p.getFireTicks() <= 0 && p.getHealth() >= p.getMaxHealth()) { return; } @@ -50,7 +50,7 @@ public ItemUseHandler getItemHandler() { ItemUtils.consumeItem(e.getItem(), false); } - p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL); + p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, XMaterial.WHITE_WOOL.parseMaterial()); p.addPotionEffect(new PotionEffect(VersionedPotionEffectType.INSTANT_HEALTH, 1, healingLevel)); p.setFireTicks(0); @@ -59,3 +59,4 @@ public ItemUseHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/MedicalSupply.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/MedicalSupply.java index 350376eab8..95e3760157 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/MedicalSupply.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.medical; +package io.github.thebusybiscuit.slimefun5.implementation.items.medical; import java.util.Collections; import java.util.HashSet; @@ -7,18 +7,17 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.attribute.Attribute; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; public abstract class MedicalSupply extends SimpleSlimefunItem { @@ -38,7 +37,7 @@ protected MedicalSupply(ItemGroup itemGroup, int healAmount, SlimefunItemStack i curedEffects.add(PotionEffectType.WEAKNESS); curedEffects.add(VersionedPotionEffectType.NAUSEA); curedEffects.add(PotionEffectType.BLINDNESS); - curedEffects.add(PotionEffectType.BAD_OMEN); + curedEffects.add(VersionedPotionEffectType.BAD_OMEN); } /** @@ -73,8 +72,9 @@ public void clearNegativeEffects(@Nonnull LivingEntity n) { */ public void heal(@Nonnull LivingEntity n) { double health = n.getHealth() + healAmount; - double maxHealth = n.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + double maxHealth = n.getMaxHealth(); n.setHealth(Math.min(health, maxHealth)); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Medicine.java similarity index 63% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Medicine.java index 01d06a79fa..3e0393698b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Medicine.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.medical; +package io.github.thebusybiscuit.slimefun5.implementation.items.medical; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.utils.RadiationUtils; public class Medicine extends MedicalSupply { @@ -28,3 +28,4 @@ public ItemConsumptionHandler getItemHandler() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Splint.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Splint.java similarity index 64% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Splint.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Splint.java index 0a510ff28a..cc77dc1003 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Splint.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Splint.java @@ -1,22 +1,21 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.medical; +package io.github.thebusybiscuit.slimefun5.implementation.items.medical; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.GameMode; -import org.bukkit.attribute.Attribute; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; public class Splint extends SimpleSlimefunItem { @@ -31,7 +30,7 @@ public Splint(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType Player p = e.getPlayer(); // Player is neither burning nor injured - if (p.getFireTicks() <= 0 && p.getHealth() >= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { + if (p.getFireTicks() <= 0 && p.getHealth() >= p.getMaxHealth()) { return; } @@ -46,3 +45,4 @@ public Splint(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Vitamins.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Vitamins.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Vitamins.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Vitamins.java index bbd822bda3..a06311fc70 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Vitamins.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/Vitamins.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.medical; +package io.github.thebusybiscuit.slimefun5.implementation.items.medical; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,12 +8,12 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.utils.RadiationUtils; public class Vitamins extends MedicalSupply { @@ -40,3 +40,4 @@ public Vitamins(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTy }; } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/package-info.java new file mode 100644 index 0000000000..21faf828f1 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/medical/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} that are + * related to healing yourself. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.medical; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/AlloyIngot.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/AlloyIngot.java similarity index 59% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/AlloyIngot.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/AlloyIngot.java index b13e811b6a..c77dc4301c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/AlloyIngot.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/AlloyIngot.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.Smeltery; /** * An {@link AlloyIngot} is a blend of different metals and resources. @@ -27,3 +27,4 @@ public AlloyIngot(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] recip } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/BasicCircuitBoard.java similarity index 64% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/BasicCircuitBoard.java index 3f8d123ea7..7ba133b2d3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/BasicCircuitBoard.java @@ -1,20 +1,20 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.entity.IronGolem; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.attributes.RandomMobDrop; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link BasicCircuitBoard} is a basic crafting component which can be @@ -51,4 +51,4 @@ public ItemUseHandler getItemHandler() { return PlayerRightClickEvent::cancel; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/CoolantCell.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/CoolantCell.java similarity index 64% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/CoolantCell.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/CoolantCell.java index de7a24a652..bda5b46f13 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/CoolantCell.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/CoolantCell.java @@ -1,18 +1,18 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.UnplaceableBlock; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.ReactorAccessPort; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.NetherStarReactor; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.NuclearReactor; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.Reactor; /** * A {@link CoolantCell} is an {@link ItemStack} that is used to cool a {@link Reactor}. @@ -38,3 +38,4 @@ public CoolantCell(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recip } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/GoldIngot.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/GoldIngot.java index 689df4264d..9c630d9231 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/GoldIngot.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/GoldIngot.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.Smeltery; /** * The {@link GoldIngot} from Slimefun is a simple resource which is divided into different @@ -58,3 +58,4 @@ public int getCaratRating() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFertilizer.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/OrganicFertilizer.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFertilizer.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/OrganicFertilizer.java index d3a156b741..61644e501d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFertilizer.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/OrganicFertilizer.java @@ -1,16 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.FoodComposter; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators.CropGrowthAccelerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators.TreeGrowthAccelerator; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.FoodComposter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators.CropGrowthAccelerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators.TreeGrowthAccelerator; /** * {@link OrganicFertilizer} is used to fuel a {@link CropGrowthAccelerator} @@ -32,3 +32,4 @@ public OrganicFertilizer(ItemGroup itemGroup, SlimefunItemStack item, SlimefunIt } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/OrganicFood.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/OrganicFood.java new file mode 100644 index 0000000000..bf6d51883d --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/OrganicFood.java @@ -0,0 +1,36 @@ +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.FoodFabricator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators.AnimalGrowthAccelerator; + +/** + * {@link OrganicFood} is created using a {@link FoodFabricator} and can + * be used to fuel an {@link AnimalGrowthAccelerator}. + * + * @author TheBusyBiscuit + * + * @see AnimalGrowthAccelerator + * + */ +public class OrganicFood extends SlimefunItem { + + public static final int OUTPUT = 2; + + @ParametersAreNonnullByDefault + public OrganicFood(ItemGroup itemGroup, SlimefunItemStack item, Material ingredient) { + // Java-8 universal port: the ingredient may not exist on a legacy server (null); substitute a + // placeholder so the item still registers instead of crashing in new ItemStack(null). + super(itemGroup, item, RecipeType.FOOD_FABRICATOR, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(ingredient != null ? ingredient : Material.PAPER), null, null, null, null, null, null, null }, new SlimefunItemStack(item, OUTPUT).item()); + } +} + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/SteelThruster.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/SteelThruster.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/SteelThruster.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/SteelThruster.java index 6468b79b19..e8eea512bf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/SteelThruster.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/SteelThruster.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,13 +6,13 @@ import org.bukkit.entity.Cow; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; /** * The {@link SteelThruster} is a pretty basic crafting component. @@ -46,4 +46,4 @@ private EntityInteractHandler onRightClickEntity() { }; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/StrangeNetherGoo.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/StrangeNetherGoo.java index 754a5f88b6..751c8a6e85 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/StrangeNetherGoo.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; import java.util.Optional; @@ -8,7 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.GameMode; -import org.bukkit.Tag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.entity.Piglin; import org.bukkit.entity.Sheep; @@ -17,17 +17,17 @@ import org.bukkit.potion.PotionEffectType; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.VillagerRune; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.PiglinBarterDrop; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes.VillagerRune; /** * This {@link SlimefunItem} can only be obtained via bartering with a {@link Piglin}, its @@ -70,8 +70,8 @@ public ItemUseHandler getItemHandler() { private EntityInteractHandler onRightClickEntity() { return (e, item, hand) -> { - if (e.getRightClicked() instanceof Sheep sheep) { - if (sheep.getCustomName() != null) { + if (e.getRightClicked() instanceof Sheep) { + Sheep sheep = (Sheep) e.getRightClicked(); if (sheep.getCustomName() != null) { e.setCancelled(true); return; } @@ -90,3 +90,4 @@ private EntityInteractHandler onRightClickEntity() { }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/SyntheticEmerald.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/SyntheticEmerald.java similarity index 64% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/SyntheticEmerald.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/SyntheticEmerald.java index b6cd366d01..6f97a53be8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/SyntheticEmerald.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/SyntheticEmerald.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.entity.Villager; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.VillagerTradingListener; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.VillagerTradingListener; /** * The {@link SyntheticEmerald} is an almost normal emerald. @@ -30,3 +30,4 @@ public SyntheticEmerald(ItemGroup itemGroup, SlimefunItemStack item, RecipeType } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/package-info.java new file mode 100644 index 0000000000..235d703ae0 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/misc/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds any miscellaneous {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * implementations. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.misc; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractCraftingTable.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AbstractCraftingTable.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractCraftingTable.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AbstractCraftingTable.java index 0a51c63a96..95bd0e076e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractCraftingTable.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AbstractCraftingTable.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; import java.util.Optional; @@ -20,15 +20,15 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SlimefunBackpack; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This abstract super class is responsible for some utility methods for machines which @@ -140,3 +140,4 @@ protected void upgradeBackpack(Player p, Inventory inv, SlimefunBackpack backpac } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AbstractSmeltery.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AbstractSmeltery.java index 7f2f27f0cb..cef5d2dbef 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AbstractSmeltery.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; @@ -15,14 +15,14 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.inventory.InvUtils; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; /** @@ -43,8 +43,8 @@ public void onInteract(Player p, Block b) { Block possibleDispenser = b.getRelative(BlockFace.DOWN); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); List inputs = RecipeType.getRecipeInputList(this); for (int i = 0; i < inputs.size(); i++) { @@ -99,3 +99,4 @@ protected void craft(Player p, Block b, Inventory inv, ItemStack[] recipe, ItemS p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/ArmorForge.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/ArmorForge.java index 4a86c04ce3..851633357d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/ArmorForge.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; @@ -16,13 +16,14 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.InventoryCompat; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; public class ArmorForge extends AbstractCraftingTable { @@ -37,8 +38,8 @@ public void onInteract(Player p, Block b) { Block possibleDispenser = b.getRelative(BlockFace.DOWN); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); List inputs = RecipeType.getRecipeInputList(this); for (ItemStack[] input : inputs) { @@ -55,7 +56,7 @@ public void onInteract(Player p, Block b) { } } - if (inv.isEmpty()) { + if (InventoryCompat.isEmpty(inv)) { Slimefun.getLocalization().sendMessage(p, "machines.inventory-empty", true); } else { Slimefun.getLocalization().sendMessage(p, "machines.pattern-not-found", true); @@ -105,3 +106,4 @@ private void craft(Player p, ItemStack output, Inventory inv, Block dispenser) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AutomatedPanningMachine.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AutomatedPanningMachine.java index ca2d0c7124..0351a87f50 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/AutomatedPanningMachine.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.List; @@ -11,6 +13,7 @@ import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -19,16 +22,17 @@ import io.github.bakedlibs.dough.items.ItemUtils; import io.github.bakedlibs.dough.scheduling.TaskQueue; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.NetherGoldPan; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.OutputChest; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GoldPan; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.NetherGoldPan; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link AutomatedPanningMachine} is a {@link MultiBlockMachine} that @@ -48,7 +52,7 @@ public class AutomatedPanningMachine extends MultiBlockMachine { @ParametersAreNonnullByDefault public AutomatedPanningMachine(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_TRAPDOOR), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, MaterialCompat.stack(XMaterial.OAK_TRAPDOOR), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF); } @Override @@ -63,7 +67,7 @@ public AutomatedPanningMachine(ItemGroup itemGroup, SlimefunItemStack item) { @Override public void onInteract(Player p, Block b) { - ItemStack input = p.getInventory().getItemInMainHand(); + ItemStack input = HandCompat.getMainHand(p.getInventory()); Material material = input.getType(); ItemStack output; @@ -110,3 +114,4 @@ public void onInteract(Player p, Block b) { queue.execute(Slimefun.instance()); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Compressor.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Compressor.java index 555c215dad..340d6919ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Compressor.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; import java.util.stream.Collectors; @@ -8,6 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -17,22 +18,23 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class Compressor extends MultiBlockMachine { @ParametersAreNonnullByDefault public Compressor(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON) }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, MaterialCompat.stack(XMaterial.NETHER_BRICK_FENCE), null, MaterialCompat.stack(XMaterial.PISTON), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), MaterialCompat.stack(XMaterial.PISTON) }, BlockFace.SELF); } @Override @@ -46,7 +48,7 @@ protected void registerDefaultRecipes(List recipes) { recipes.add(new ItemStack(Material.COAL_BLOCK, 8)); recipes.add(new SlimefunItemStack(SlimefunItems.CARBON, 9).item()); - recipes.add(new ItemStack(Material.CHARCOAL, 4)); + recipes.add(MaterialCompat.stack(XMaterial.CHARCOAL, 4)); recipes.add(new ItemStack(Material.COAL)); } @@ -60,8 +62,8 @@ public void onInteract(Player p, Block b) { Block dispBlock = b.getRelative(BlockFace.DOWN); BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); for (ItemStack item : inv.getContents()) { for (ItemStack recipeInput : RecipeType.getRecipeInputs(this)) { @@ -113,3 +115,4 @@ private void craft(Player p, ItemStack output, Block dispenser, Inventory dispIn } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/EnhancedCraftingTable.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/EnhancedCraftingTable.java index 4486197b62..34ddf02000 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/EnhancedCraftingTable.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; @@ -6,6 +6,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -15,22 +16,24 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.InventoryCompat; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SlimefunBackpack; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class EnhancedCraftingTable extends AbstractCraftingTable { @ParametersAreNonnullByDefault public EnhancedCraftingTable(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.CRAFTING_TABLE), null, null, new ItemStack(Material.DISPENSER), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, MaterialCompat.stack(XMaterial.CRAFTING_TABLE), null, null, new ItemStack(Material.DISPENSER), null }, BlockFace.SELF); } @Override @@ -38,8 +41,8 @@ public void onInteract(Player p, Block b) { Block possibleDispenser = b.getRelative(BlockFace.DOWN); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); List inputs = RecipeType.getRecipeInputList(this); for (ItemStack[] input : inputs) { @@ -56,7 +59,7 @@ public void onInteract(Player p, Block b) { } } - if (inv.isEmpty()) { + if (InventoryCompat.isEmpty(inv)) { Slimefun.getLocalization().sendMessage(p, "machines.inventory-empty", true); } else { Slimefun.getLocalization().sendMessage(p, "machines.pattern-not-found", true); @@ -71,8 +74,8 @@ private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack if (outputInv != null) { SlimefunItem sfItem = SlimefunItem.getByItem(output); - if (sfItem instanceof SlimefunBackpack backpack) { - upgradeBackpack(p, inv, backpack, output); + if (sfItem instanceof SlimefunBackpack) { + SlimefunBackpack backpack = (SlimefunBackpack) sfItem; upgradeBackpack(p, inv, backpack, output); } for (int j = 0; j < 9; j++) { @@ -106,3 +109,4 @@ private boolean isCraftable(Inventory inv, ItemStack[] recipe) { return true; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/GrindStone.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/GrindStone.java index 754585d8d5..0567db58fb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/GrindStone.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; import java.util.stream.Collectors; @@ -8,6 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -17,23 +18,24 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class GrindStone extends MultiBlockMachine { @ParametersAreNonnullByDefault public GrindStone(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, MaterialCompat.stack(XMaterial.OAK_FENCE), null, null, CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override @@ -42,24 +44,24 @@ protected void registerDefaultRecipes(@Nonnull List recipes) { recipes.add(new ItemStack(Material.BLAZE_POWDER, 4)); recipes.add(new ItemStack(Material.BONE)); - recipes.add(new ItemStack(Material.BONE_MEAL, 4)); + recipes.add(MaterialCompat.stack(XMaterial.BONE_MEAL, 4)); - recipes.add(new ItemStack(Material.BONE_BLOCK)); - recipes.add(new ItemStack(Material.BONE_MEAL, 9)); + recipes.add(MaterialCompat.stack(XMaterial.BONE_BLOCK)); + recipes.add(MaterialCompat.stack(XMaterial.BONE_MEAL, 9)); recipes.add(new ItemStack(Material.COBBLESTONE)); recipes.add(new ItemStack(Material.GRAVEL)); - recipes.add(new ItemStack(Material.ANDESITE)); + recipes.add(MaterialCompat.stack(XMaterial.ANDESITE)); recipes.add(new ItemStack(Material.GRAVEL)); - recipes.add(new ItemStack(Material.BLACKSTONE)); + recipes.add(MaterialCompat.stack(XMaterial.BLACKSTONE)); recipes.add(new ItemStack(Material.GRAVEL)); - recipes.add(new ItemStack(Material.DIORITE)); + recipes.add(MaterialCompat.stack(XMaterial.DIORITE)); recipes.add(new ItemStack(Material.GRAVEL)); - recipes.add(new ItemStack(Material.GRANITE)); + recipes.add(MaterialCompat.stack(XMaterial.GRANITE)); recipes.add(new ItemStack(Material.GRAVEL)); recipes.add(new ItemStack(Material.DIRT)); @@ -69,28 +71,28 @@ protected void registerDefaultRecipes(@Nonnull List recipes) { recipes.add(new ItemStack(Material.SAND, 4)); recipes.add(new ItemStack(Material.RED_SANDSTONE)); - recipes.add(new ItemStack(Material.RED_SAND, 4)); + recipes.add(MaterialCompat.stack(XMaterial.RED_SAND, 4)); - recipes.add(new ItemStack(Material.PRISMARINE_BRICKS)); + recipes.add(MaterialCompat.stack(XMaterial.PRISMARINE_BRICKS)); recipes.add(new ItemStack(Material.PRISMARINE, 2)); recipes.add(new ItemStack(Material.PRISMARINE)); recipes.add(new ItemStack(Material.PRISMARINE_SHARD, 4)); - recipes.add(new ItemStack(Material.NETHER_WART_BLOCK)); - recipes.add(new ItemStack(Material.NETHER_WART, 9)); + recipes.add(MaterialCompat.stack(XMaterial.NETHER_WART_BLOCK)); + recipes.add(MaterialCompat.stack(XMaterial.NETHER_WART, 9)); recipes.add(new ItemStack(Material.QUARTZ_BLOCK)); recipes.add(new ItemStack(Material.QUARTZ, 4)); - recipes.add(new ItemStack(Material.BASALT, 2)); - recipes.add(new ItemStack(Material.BLACKSTONE)); + recipes.add(MaterialCompat.stack(XMaterial.BASALT, 2)); + recipes.add(MaterialCompat.stack(XMaterial.BLACKSTONE)); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - recipes.add(new ItemStack(Material.AMETHYST_BLOCK)); - recipes.add(new ItemStack(Material.AMETHYST_SHARD, 4)); + recipes.add(MaterialCompat.stack(XMaterial.AMETHYST_BLOCK)); + recipes.add(MaterialCompat.stack(XMaterial.AMETHYST_SHARD, 4)); - recipes.add(new ItemStack(Material.COBBLED_DEEPSLATE)); + recipes.add(MaterialCompat.stack(XMaterial.COBBLED_DEEPSLATE)); recipes.add(new ItemStack(Material.GRAVEL)); } @@ -120,8 +122,8 @@ public void onInteract(Player p, Block b) { Block possibleDispenser = b.getRelative(BlockFace.DOWN); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); for (ItemStack current : inv.getContents()) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) { @@ -153,3 +155,4 @@ public void onInteract(Player p, Block b) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Juicer.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Juicer.java index da99ce748f..49fb53da74 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Juicer.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; import java.util.stream.Collectors; @@ -9,6 +9,7 @@ import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -18,16 +19,17 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.Juice; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link Juicer} is a {@link MultiBlockMachine} which can be used to @@ -43,7 +45,7 @@ public class Juicer extends MultiBlockMachine { @ParametersAreNonnullByDefault public Juicer(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.GLASS), null, null, MaterialCompat.stack(XMaterial.NETHER_BRICK_FENCE), null, null, CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override @@ -56,8 +58,8 @@ public void onInteract(Player p, Block b) { Block possibleDispenser = b.getRelative(BlockFace.DOWN); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); for (ItemStack current : inv.getContents()) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) { @@ -93,3 +95,4 @@ public void onInteract(Player p, Block b) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/MagicWorkbench.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/MagicWorkbench.java index cd2e0a86ec..6d9ff57ba3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/MagicWorkbench.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; @@ -7,6 +7,7 @@ import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -16,22 +17,24 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.InventoryCompat; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SlimefunBackpack; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class MagicWorkbench extends AbstractCraftingTable { @ParametersAreNonnullByDefault public MagicWorkbench(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, null, null, new ItemStack(Material.BOOKSHELF), new ItemStack(Material.CRAFTING_TABLE), new ItemStack(Material.DISPENSER) }, BlockFace.UP); + super(itemGroup, item, new ItemStack[] { null, null, null, null, null, null, new ItemStack(Material.BOOKSHELF), MaterialCompat.stack(XMaterial.CRAFTING_TABLE), new ItemStack(Material.DISPENSER) }, BlockFace.UP); } @Override @@ -45,8 +48,8 @@ public void onInteract(Player p, Block b) { BlockState state = PaperLib.getBlockState(possibleDispener, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); List inputs = RecipeType.getRecipeInputList(this); for (ItemStack[] input : inputs) { @@ -63,7 +66,7 @@ public void onInteract(Player p, Block b) { } } - if (inv.isEmpty()) { + if (InventoryCompat.isEmpty(inv)) { Slimefun.getLocalization().sendMessage(p, "machines.inventory-empty", true); } else { Slimefun.getLocalization().sendMessage(p, "machines.pattern-not-found", true); @@ -79,8 +82,8 @@ private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack if (outputInv != null) { SlimefunItem sfItem = SlimefunItem.getByItem(output); - if (sfItem instanceof SlimefunBackpack backpack) { - upgradeBackpack(p, inv, backpack, output); + if (sfItem instanceof SlimefunBackpack) { + SlimefunBackpack backpack = (SlimefunBackpack) sfItem; upgradeBackpack(p, inv, backpack, output); } for (int j = 0; j < 9; j++) { @@ -149,3 +152,4 @@ private boolean isCraftable(Inventory inv, ItemStack[] recipe) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/MakeshiftSmeltery.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/MakeshiftSmeltery.java index 7405a0694c..13dd9d4ee9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/MakeshiftSmeltery.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.ArrayList; import java.util.List; @@ -7,6 +7,7 @@ import org.bukkit.Effect; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -14,8 +15,9 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link MakeshiftSmeltery} is a simpler version of the {@link Smeltery}. @@ -30,7 +32,7 @@ public class MakeshiftSmeltery extends AbstractSmeltery { @ParametersAreNonnullByDefault public MakeshiftSmeltery(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); + super(itemGroup, item, new ItemStack[] { null, MaterialCompat.stack(XMaterial.OAK_FENCE), null, MaterialCompat.stack(XMaterial.BRICKS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), MaterialCompat.stack(XMaterial.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); } @Override @@ -55,3 +57,4 @@ protected void craft(Player p, Block b, Inventory inv, ItemStack[] recipe, ItemS } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/OreCrusher.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/OreCrusher.java index 07e5df7735..23bc162820 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/OreCrusher.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.Arrays; import java.util.List; @@ -10,6 +10,7 @@ import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -19,18 +20,19 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link OreCrusher} is a {@link MultiBlockMachine} which allows you to double ores @@ -45,15 +47,15 @@ public class OreCrusher extends MultiBlockMachine { @ParametersAreNonnullByDefault public OreCrusher(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, BlockFace.SELF); + super(itemGroup, item, new ItemStack[] { null, null, null, null, MaterialCompat.stack(XMaterial.NETHER_BRICK_FENCE), null, MaterialCompat.stack(XMaterial.IRON_BARS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), MaterialCompat.stack(XMaterial.IRON_BARS) }, BlockFace.SELF); addItemSetting(doubleOres); } @Override protected void registerDefaultRecipes(List recipes) { - recipes.add(new ItemStack(Material.BLACKSTONE, 8)); - recipes.add(new ItemStack(Material.RED_SAND, 1)); + recipes.add(MaterialCompat.stack(XMaterial.BLACKSTONE, 8)); + recipes.add(MaterialCompat.stack(XMaterial.RED_SAND, 1)); recipes.add(new ItemStack(Material.COBBLESTONE, 8)); recipes.add(new ItemStack(Material.SAND, 1)); @@ -94,7 +96,7 @@ protected void registerDefaultRecipes(List recipes) { recipes.add(new ItemStack(Material.GRAVEL)); recipes.add(new ItemStack(Material.SAND)); - recipes.add(new ItemStack(Material.MAGMA_BLOCK)); + recipes.add(MaterialCompat.stack(XMaterial.MAGMA_BLOCK)); recipes.add(SlimefunItems.SULFATE.item()); recipes.add(SlimefunItems.CARBON.item()); @@ -104,7 +106,7 @@ protected void registerDefaultRecipes(List recipes) { recipes.add(new SlimefunItemStack(SlimefunItems.CARBON, 4).item()); if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - recipes.add(new ItemStack(Material.COBBLED_DEEPSLATE, 8)); + recipes.add(MaterialCompat.stack(XMaterial.COBBLED_DEEPSLATE, 8)); recipes.add(new ItemStack(Material.SAND, 1)); } } @@ -124,26 +126,26 @@ public void postRegister() { new ItemStack(Material.REDSTONE_ORE), doubleOres.getRedstone(), new ItemStack(Material.DIAMOND_ORE), doubleOres.getDiamond(), new ItemStack(Material.EMERALD_ORE), doubleOres.getEmerald(), - new ItemStack(Material.NETHER_QUARTZ_ORE), doubleOres.getNetherQuartz() + MaterialCompat.stack(XMaterial.NETHER_QUARTZ_ORE), doubleOres.getNetherQuartz() )); // @formatter:on // Gold ore variants (1.16+) - displayRecipes.add(new ItemStack(Material.NETHER_GOLD_ORE)); + displayRecipes.add(MaterialCompat.stack(XMaterial.NETHER_GOLD_ORE)); displayRecipes.add(doubleOres.getGoldNuggets()); - displayRecipes.add(new ItemStack(Material.GILDED_BLACKSTONE)); + displayRecipes.add(MaterialCompat.stack(XMaterial.GILDED_BLACKSTONE)); displayRecipes.add(doubleOres.getGoldNuggets()); // Raw metal ores (1.17+) if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - displayRecipes.add(new ItemStack(Material.RAW_IRON)); + displayRecipes.add(MaterialCompat.stack(XMaterial.RAW_IRON)); displayRecipes.add(SlimefunItems.IRON_DUST.item()); - displayRecipes.add(new ItemStack(Material.RAW_COPPER)); + displayRecipes.add(MaterialCompat.stack(XMaterial.RAW_COPPER)); displayRecipes.add(SlimefunItems.COPPER_DUST.item()); - displayRecipes.add(new ItemStack(Material.RAW_GOLD)); + displayRecipes.add(MaterialCompat.stack(XMaterial.RAW_GOLD)); displayRecipes.add(SlimefunItems.GOLD_DUST.item()); } @@ -151,25 +153,25 @@ public void postRegister() { if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { // @formatter:off displayRecipes.addAll(Arrays.asList( - new ItemStack(Material.DEEPSLATE_COAL_ORE), doubleOres.getCoal(), - new ItemStack(Material.DEEPSLATE_LAPIS_ORE), doubleOres.getLapisLazuli(), - new ItemStack(Material.DEEPSLATE_REDSTONE_ORE), doubleOres.getRedstone(), - new ItemStack(Material.DEEPSLATE_DIAMOND_ORE), doubleOres.getDiamond(), - new ItemStack(Material.DEEPSLATE_EMERALD_ORE), doubleOres.getEmerald() + MaterialCompat.stack(XMaterial.DEEPSLATE_COAL_ORE), doubleOres.getCoal(), + MaterialCompat.stack(XMaterial.DEEPSLATE_LAPIS_ORE), doubleOres.getLapisLazuli(), + MaterialCompat.stack(XMaterial.DEEPSLATE_REDSTONE_ORE), doubleOres.getRedstone(), + MaterialCompat.stack(XMaterial.DEEPSLATE_DIAMOND_ORE), doubleOres.getDiamond(), + MaterialCompat.stack(XMaterial.DEEPSLATE_EMERALD_ORE), doubleOres.getEmerald() )); // @formatter:on // More deepslate ores and copper ore - displayRecipes.add(new ItemStack(Material.DEEPSLATE_IRON_ORE)); + displayRecipes.add(MaterialCompat.stack(XMaterial.DEEPSLATE_IRON_ORE)); displayRecipes.add(new SlimefunItemStack(SlimefunItems.IRON_DUST, isOreDoublingEnabled() ? 2 : 1).item()); - displayRecipes.add(new ItemStack(Material.DEEPSLATE_GOLD_ORE)); + displayRecipes.add(MaterialCompat.stack(XMaterial.DEEPSLATE_GOLD_ORE)); displayRecipes.add(new SlimefunItemStack(SlimefunItems.GOLD_DUST, isOreDoublingEnabled() ? 2 : 1).item()); - displayRecipes.add(new ItemStack(Material.DEEPSLATE_COPPER_ORE)); + displayRecipes.add(MaterialCompat.stack(XMaterial.DEEPSLATE_COPPER_ORE)); displayRecipes.add(new SlimefunItemStack(SlimefunItems.COPPER_DUST, isOreDoublingEnabled() ? 2 : 1).item()); - displayRecipes.add(new ItemStack(Material.COPPER_ORE)); + displayRecipes.add(MaterialCompat.stack(XMaterial.COPPER_ORE)); displayRecipes.add(new SlimefunItemStack(SlimefunItems.COPPER_DUST, isOreDoublingEnabled() ? 2 : 1).item()); } } @@ -184,8 +186,8 @@ public void onInteract(Player p, Block b) { Block possibleDispenser = b.getRelative(BlockFace.DOWN); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); for (ItemStack current : inv.getContents()) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) { @@ -219,7 +221,7 @@ public void onInteract(Player p, Block b) { private class DoubleOreSetting extends ItemSetting { private final ItemStack coal = new ItemStack(Material.COAL, 1); - private final ItemStack lapis = new ItemStack(Material.LAPIS_LAZULI, 7); + private final ItemStack lapis = MaterialCompat.stack(XMaterial.LAPIS_LAZULI, 7); private final ItemStack redstone = new ItemStack(Material.REDSTONE, 4); private final ItemStack diamond = new ItemStack(Material.DIAMOND, 1); private final ItemStack emerald = new ItemStack(Material.EMERALD, 1); @@ -293,3 +295,4 @@ public void reload() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/OreWasher.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/OreWasher.java index b8b7bcae6f..23fee809ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/OreWasher.java @@ -1,7 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -10,6 +11,7 @@ import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -18,15 +20,16 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link OreWasher} is a special {@link MultiBlockMachine} which allows you to @@ -59,7 +62,7 @@ public OreWasher(ItemGroup itemGroup, SlimefunItemStack item) { // @formatter:off super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.DISPENSER), null, - null, new ItemStack(Material.OAK_FENCE), null, + null, MaterialCompat.stack(XMaterial.OAK_FENCE), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF); // @formatter:on @@ -86,7 +89,7 @@ protected void registerDefaultRecipes(List recipes) { @Override public @Nonnull List getDisplayRecipes() { - return recipes.stream().map(items -> items[0]).toList(); + return recipes.stream().map(items -> items[0]).collect(Collectors.toList()); } @Override @@ -94,8 +97,8 @@ public void onInteract(Player p, Block b) { Block dispBlock = b.getRelative(BlockFace.UP); BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); - if (state instanceof Dispenser disp) { - Inventory inv = disp.getInventory(); + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; Inventory inv = disp.getInventory(); for (ItemStack input : inv.getContents()) { if (input != null) { @@ -189,3 +192,4 @@ private void removeItem(Player p, Block b, Inventory inputInv, @Nullable Invento } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/PressureChamber.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/PressureChamber.java index 50f42828bb..7deeb08e28 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/PressureChamber.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.List; import java.util.stream.Collectors; @@ -9,6 +9,7 @@ import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -18,21 +19,22 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; public class PressureChamber extends MultiBlockMachine { @ParametersAreNonnullByDefault public PressureChamber(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { new ItemStack(Material.SMOOTH_STONE_SLAB), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing down)"), new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, BlockFace.UP); + super(itemGroup, item, new ItemStack[] { MaterialCompat.stack(XMaterial.SMOOTH_STONE_SLAB), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing down)"), MaterialCompat.stack(XMaterial.SMOOTH_STONE_SLAB), MaterialCompat.stack(XMaterial.PISTON), new ItemStack(Material.GLASS), MaterialCompat.stack(XMaterial.PISTON), MaterialCompat.stack(XMaterial.PISTON), new ItemStack(Material.CAULDRON), MaterialCompat.stack(XMaterial.PISTON) }, BlockFace.UP); } @Override @@ -45,8 +47,8 @@ public void onInteract(Player p, Block b) { Block possibleDispenser = b.getRelative(BlockFace.UP).getRelative(BlockFace.UP); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState(); - if (state instanceof Dispenser dispenser) { - Inventory inv = dispenser.getInventory(); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; Inventory inv = dispenser.getInventory(); for (ItemStack current : inv.getContents()) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) { @@ -99,3 +101,4 @@ private void craft(Player p, Block b, ItemStack output, Inventory dispInv, Block } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Smeltery.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Smeltery.java index 6140929b93..0394d1ad4f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/Smeltery.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; import java.util.ArrayList; import java.util.Arrays; @@ -11,6 +11,7 @@ import org.bukkit.Effect; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -18,13 +19,14 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.IgnitionChamber; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.AlloyIngot; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.IgnitionChamber; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.AlloyIngot; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link Smeltery} is an upgraded version of the {@link MakeshiftSmeltery} @@ -50,7 +52,7 @@ public class Smeltery extends AbstractSmeltery { @ParametersAreNonnullByDefault public Smeltery(ItemGroup itemGroup, SlimefunItemStack item) { - super(itemGroup, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); + super(itemGroup, item, new ItemStack[] { null, MaterialCompat.stack(XMaterial.NETHER_BRICK_FENCE), null, MaterialCompat.stack(XMaterial.NETHER_BRICKS), CustomItemStack.create(Material.DISPENSER, "Dispenser (Facing up)"), MaterialCompat.stack(XMaterial.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); addItemSetting(fireBreakingChance); } @@ -98,3 +100,4 @@ private void consumeFire(Player p, Block dispenser, Block b) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/TableSaw.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/TableSaw.java index 40bb1b2fdd..65022b6014 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/TableSaw.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.List; @@ -12,7 +14,8 @@ import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -20,12 +23,13 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockCraftEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockCraftEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.OutputChest; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link TableSaw} is an implementation of a {@link MultiBlockMachine} that allows @@ -49,7 +53,7 @@ public TableSaw(ItemGroup group, SlimefunItemStack item) { // @formatter:off super(group, item, new ItemStack[] { null, null, null, - new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), + MaterialCompat.stack(XMaterial.SMOOTH_STONE_SLAB), MaterialCompat.stack(XMaterial.STONECUTTER), MaterialCompat.stack(XMaterial.SMOOTH_STONE_SLAB), null, new ItemStack(Material.IRON_BLOCK), null }, BlockFace.SELF); // @formatter:on @@ -73,7 +77,7 @@ null, new ItemStack(Material.IRON_BLOCK), null * This method returns the corresponding plank {@link Material} for a given wood {@link Material}. * The result is wrapped by an {@link Optional}. *

- * {@literal Material.OAK_LOG} for example will return {@literal Material.OAK_PLANKS}. + * {@literal XMaterial.OAK_LOG.parseMaterial()} for example will return {@literal Material.OAK_PLANKS}. * * @param log * The log type. @@ -101,7 +105,7 @@ public List getDisplayRecipes() { @Override public void onInteract(@Nonnull Player p, @Nonnull Block b) { - ItemStack item = p.getInventory().getItemInMainHand(); + ItemStack item = HandCompat.getMainHand(p.getInventory()); ItemStack output = getOutputFromMaterial(item.getType()); if (output == null) { @@ -150,3 +154,4 @@ private void outputItems(@Nonnull Block b, @Nonnull ItemStack output) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java index 5cec6e1b1e..3d22f07de2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/AdvancedIndustrialMiner.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -36,3 +36,4 @@ protected void registerDefaultFuelTypes() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/IndustrialMiner.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/IndustrialMiner.java index 77c61ff7b4..aa3914d8a1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/IndustrialMiner.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner; import java.util.ArrayList; import java.util.HashMap; @@ -13,7 +13,8 @@ import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Tag; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; @@ -23,16 +24,17 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link IndustrialMiner} is a {@link MultiBlockMachine} that can mine any @@ -63,8 +65,8 @@ public IndustrialMiner(ItemGroup itemGroup, SlimefunItemStack item, Material bas // @formatter:off super(itemGroup, item, new ItemStack[] { null, null, null, - CustomItemStack.create(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), CustomItemStack.create(Material.PISTON, "Piston (facing up)"), - new ItemStack(baseMaterial), new ItemStack(Material.BLAST_FURNACE), new ItemStack(baseMaterial) + CustomItemStack.create(XMaterial.PISTON.parseMaterial(), "Piston (facing up)"), new ItemStack(Material.CHEST), CustomItemStack.create(XMaterial.PISTON.parseMaterial(), "Piston (facing up)"), + new ItemStack(baseMaterial), MaterialCompat.stack(XMaterial.BLAST_FURNACE), new ItemStack(baseMaterial) }, BlockFace.UP); // @formatter:on @@ -108,10 +110,10 @@ public int getRange() { protected void registerDefaultFuelTypes() { // Coal & Charcoal fuelTypes.add(new MachineFuel(4, new ItemStack(Material.COAL))); - fuelTypes.add(new MachineFuel(4, new ItemStack(Material.CHARCOAL))); + fuelTypes.add(new MachineFuel(4, MaterialCompat.stack(XMaterial.CHARCOAL))); fuelTypes.add(new MachineFuel(40, new ItemStack(Material.COAL_BLOCK))); - fuelTypes.add(new MachineFuel(10, new ItemStack(Material.DRIED_KELP_BLOCK))); + fuelTypes.add(new MachineFuel(10, MaterialCompat.stack(XMaterial.DRIED_KELP_BLOCK))); fuelTypes.add(new MachineFuel(4, new ItemStack(Material.BLAZE_ROD))); // Logs @@ -195,7 +197,7 @@ public void onInteract(Player p, Block b) { private @Nonnull Block[] findPistons(@Nonnull Block chest) { Block northern = chest.getRelative(BlockFace.NORTH); - if (northern.getType() == Material.PISTON) { + if (northern.getType() == XMaterial.PISTON.parseMaterial()) { return new Block[] { northern, chest.getRelative(BlockFace.SOUTH) }; } else { return new Block[] { chest.getRelative(BlockFace.WEST), chest.getRelative(BlockFace.EAST) }; @@ -214,7 +216,7 @@ public boolean canMine(@Nonnull Block block) { MinecraftVersion version = Slimefun.getMinecraftVersion(); Material type = block.getType(); - if (type == Material.ANCIENT_DEBRIS) { + if (type == XMaterial.ANCIENT_DEBRIS.parseMaterial()) { return canMineAncientDebris.getValue() && !BlockStorage.hasBlockInfo(block); } else if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_17) && SlimefunTag.DEEPSLATE_ORES.isTagged(type)) { return canMineDeepslateOres.getValue() && !BlockStorage.hasBlockInfo(block); @@ -224,3 +226,4 @@ public boolean canMine(@Nonnull Block block) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MinerStoppingReason.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/MinerStoppingReason.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MinerStoppingReason.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/MinerStoppingReason.java index 0c54810346..3a03ff6406 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MinerStoppingReason.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/MinerStoppingReason.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner; import javax.annotation.Nonnull; @@ -6,7 +6,7 @@ import org.bukkit.block.data.type.Piston; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlock; /** * This enum holds various different reasons as to why an {@link IndustrialMiner} @@ -61,3 +61,4 @@ String getErrorMessage() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/MiningTask.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/MiningTask.java index 0169f0f846..e7eb53ec8f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/MiningTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/MiningTask.java @@ -1,4 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.WorldCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import java.util.UUID; import java.util.logging.Level; @@ -10,14 +15,14 @@ import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.Sound; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCompat; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.Chest; -import org.bukkit.block.data.type.Piston; -import org.bukkit.block.data.type.PistonHead; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -27,9 +32,9 @@ import io.github.bakedlibs.dough.items.ItemUtils; import io.github.bakedlibs.dough.protection.Interaction; import io.github.bakedlibs.dough.scheduling.TaskQueue; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -190,7 +195,7 @@ public void run() { furnace.getWorld().playEffect(furnace.getLocation(), Effect.STEP_SOUND, Material.STONE); World world = start.getWorld(); - for (int y = height; y > world.getMinHeight(); y--) { + for (int y = height; y > WorldCompat.getMinHeight(world); y--) { Block b = world.getBlockAt(x, y, z); if (!Slimefun.getProtectionManager().hasPermission(Bukkit.getOfflinePlayer(owner), b, Interaction.BREAK_BLOCK)) { @@ -240,7 +245,7 @@ private void nextColumn() { Player p = Bukkit.getPlayer(owner); if (p != null) { - p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.4F, 1F); + SoundCompat.playFor(p, p.getLocation(), "ENTITY_ARROW_HIT_PLAYER", null, 0.4F, 1F); Slimefun.getLocalization().sendMessage(p, "machines.INDUSTRIAL_MINER.finished", msg -> msg.replace("%ores%", String.valueOf(ores))); } @@ -270,8 +275,8 @@ private boolean push(@Nonnull ItemStack item) { if (chest.getType() == Material.CHEST) { BlockState state = PaperLib.getBlockState(chest, false).getState(); - if (state instanceof Chest chestState) { - Inventory inv = chestState.getBlockInventory(); + if (state instanceof Chest) { + Chest chestState = (Chest) state; Inventory inv = chestState.getBlockInventory(); if (InvUtils.fits(inv, item)) { inv.addItem(item); @@ -301,8 +306,8 @@ private void consumeFuel() { if (chest.getType() == Material.CHEST) { BlockState state = PaperLib.getBlockState(chest, false).getState(); - if (state instanceof Chest chestState) { - Inventory inv = chestState.getBlockInventory(); + if (state instanceof Chest) { + Chest chestState = (Chest) state; Inventory inv = chestState.getBlockInventory(); this.fuelLevel = grabFuelFrom(inv); } } @@ -341,20 +346,20 @@ private void setPistonState(@Nonnull Block block, boolean extended) { try { // Smoke Particles around the Chest for dramatic effect Location particleLoc = chest.getLocation().clone().add(0, -1, 0); - block.getWorld().spawnParticle(VersionedParticle.SMOKE, particleLoc, 20, 0.7, 0.7, 0.7, 0); + ParticleCompat.spawn(block.getWorld(), VersionedParticle.SMOKE, particleLoc, 20, 0.7, 0.7, 0.7, 0); - if (block.getType() == Material.MOVING_PISTON) { + if (block.getType() == XMaterial.MOVING_PISTON.parseMaterial()) { // Yeah it isn't really cool when this happens block.getRelative(BlockFace.UP).setType(Material.AIR); - } else if (block.getType() == Material.PISTON) { + } else if (block.getType() == XMaterial.PISTON.parseMaterial()) { Block above = block.getRelative(BlockFace.UP); // Check if the above block is valid - if (above.isEmpty() || above.getType() == Material.PISTON_HEAD) { - Piston piston = (Piston) block.getBlockData(); + if (above.isEmpty() || above.getType() == XMaterial.PISTON_HEAD.parseMaterial()) { + Object piston = BlockDataCompat.getBlockData(block); // Check if the piston is actually facing upwards - if (piston.getFacing() == BlockFace.UP) { + if (BlockDataCompat.get(piston, "getFacing") == BlockFace.UP) { setExtended(block, piston, extended); } else { // The pistons must be facing upwards @@ -374,21 +379,22 @@ private void setPistonState(@Nonnull Block block, boolean extended) { } } - private void setExtended(@Nonnull Block block, @Nonnull Piston piston, boolean extended) { - piston.setExtended(extended); - block.setBlockData(piston, false); + private void setExtended(@Nonnull Block block, @Nonnull Object piston, boolean extended) { + BlockDataCompat.set(piston, "setExtended", extended); + BlockDataCompat.setBlockData(block, piston, false); // Updating the Piston Head if (extended) { - PistonHead head = (PistonHead) Material.PISTON_HEAD.createBlockData(); - head.setFacing(BlockFace.UP); + Object head = BlockDataCompat.createBlockData(XMaterial.PISTON_HEAD.parseMaterial()); + BlockDataCompat.set(head, "setFacing", BlockFace.UP); - block.getRelative(BlockFace.UP).setBlockData(head, false); + BlockDataCompat.setBlockData(block.getRelative(BlockFace.UP), head, false); } else { block.getRelative(BlockFace.UP).setType(Material.AIR); } - block.getWorld().playSound(block.getLocation(), extended ? Sound.BLOCK_PISTON_EXTEND : Sound.BLOCK_PISTON_CONTRACT, 0.1F, 1F); + SoundCompat.playAt(block.getLocation(), extended ? "BLOCK_PISTON_EXTEND" : "BLOCK_PISTON_CONTRACT", null, 0.1F, 1F); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary.java index 21fb557569..811185dea9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner; +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner; import java.util.Random; @@ -8,7 +8,7 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; /** * Simple interface to map ore blocks to their respective item(s). @@ -32,3 +32,4 @@ interface OreDictionary { } } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary16.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary16.java new file mode 100644 index 0000000000..9a886e5123 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary16.java @@ -0,0 +1,37 @@ +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner; + +import java.util.Random; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * Our {@link OreDictionary} implementation for MC 1.16 or higher. + * + * @author TheBusyBiscuit + * + */ +class OreDictionary16 implements OreDictionary { + + @Override + public ItemStack getDrops(@Nonnull Material material, @Nonnull Random random) { + switch (material.name()) { + case "COAL_ORE": return new ItemStack(Material.COAL); + case "DIAMOND_ORE": return new ItemStack(Material.DIAMOND); + case "EMERALD_ORE": return new ItemStack(Material.EMERALD); + case "REDSTONE_ORE": return new ItemStack(Material.REDSTONE, 4 + random.nextInt(2)); + case "LAPIS_ORE": return new ItemStack(Material.valueOf("LAPIS_LAZULI"), 4 + random.nextInt(4)); + case "NETHER_QUARTZ_ORE": return new ItemStack(Material.QUARTZ); + case "IRON_ORE": return new ItemStack(Material.IRON_ORE); + case "GOLD_ORE": return new ItemStack(Material.GOLD_ORE); + case "NETHER_GOLD_ORE": return new ItemStack(Material.GOLD_NUGGET, 2 + random.nextInt(4)); + case "ANCIENT_DEBRIS": return new ItemStack(Material.valueOf("ANCIENT_DEBRIS")); + default: return new ItemStack(material); + } + } + +} + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary17.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary17.java new file mode 100644 index 0000000000..b1ceed133b --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/OreDictionary17.java @@ -0,0 +1,52 @@ +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner; + +import java.util.Random; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * Our {@link OreDictionary} implementation for MC 1.17 or higher. + * + * @author TheBusyBiscuit + * + */ +class OreDictionary17 extends OreDictionary16 { + + @Override + public ItemStack getDrops(@Nonnull Material material, @Nonnull Random random) { + switch (material.name()) { + case "COAL_ORE": + case "DEEPSLATE_COAL_ORE": + return new ItemStack(Material.COAL); + case "DIAMOND_ORE": + case "DEEPSLATE_DIAMOND_ORE": + return new ItemStack(Material.DIAMOND); + case "EMERALD_ORE": + case "DEEPSLATE_EMERALD_ORE": + return new ItemStack(Material.EMERALD); + case "REDSTONE_ORE": + case "DEEPSLATE_REDSTONE_ORE": + return new ItemStack(Material.REDSTONE, 4 + random.nextInt(2)); + case "LAPIS_ORE": + case "DEEPSLATE_LAPIS_ORE": + return new ItemStack(Material.valueOf("LAPIS_LAZULI"), 4 + random.nextInt(4)); + case "COPPER_ORE": + case "DEEPSLATE_COPPER_ORE": + return new ItemStack(Material.valueOf("RAW_COPPER")); + case "IRON_ORE": + case "DEEPSLATE_IRON_ORE": + return new ItemStack(Material.valueOf("RAW_IRON")); + case "GOLD_ORE": + case "DEEPSLATE_GOLD_ORE": + return new ItemStack(Material.valueOf("RAW_GOLD")); + default: + return super.getDrops(material, random); + } + } + +} + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/package-info.java new file mode 100644 index 0000000000..922b38c7cf --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/miner/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds classes associated with the + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner.IndustrialMiner}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/package-info.java new file mode 100644 index 0000000000..78164423ee --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/multiblocks/package-info.java @@ -0,0 +1,5 @@ +/** + * This package contains all the different implementations of + * {@link io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlockMachine} + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/package-info.java new file mode 100644 index 0000000000..9d5abdb0c2 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/package-info.java @@ -0,0 +1,5 @@ +/** + * This package contains the different classes for each + * {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + */ +package io.github.thebusybiscuit.slimefun5.implementation.items; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/ChristmasPresent.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/ChristmasPresent.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/ChristmasPresent.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/ChristmasPresent.java index 37ec6cc244..02555f8cda 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/ChristmasPresent.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/ChristmasPresent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.seasonal; +package io.github.thebusybiscuit.slimefun5.implementation.items.seasonal; import java.util.concurrent.ThreadLocalRandom; @@ -10,16 +10,16 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.FireworkUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * The {@link ChristmasPresent} is a seasonal {@link SlimefunItem} that drops a random @@ -61,3 +61,4 @@ public ChristmasPresent(ItemGroup itemGroup, SlimefunItemStack item, RecipeType } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/EasterEgg.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/EasterEgg.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/EasterEgg.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/EasterEgg.java index 2c31638ada..c310179d0a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/EasterEgg.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/EasterEgg.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.seasonal; +package io.github.thebusybiscuit.slimefun5.implementation.items.seasonal; import java.util.concurrent.ThreadLocalRandom; @@ -10,15 +10,15 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.FireworkUtils; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This {@link SlimefunItem} represents an {@link EasterEgg}. @@ -58,3 +58,4 @@ public EasterEgg(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeT } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/package-info.java similarity index 54% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/package-info.java index 9ddd2c8ba6..234c8943d4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/seasonal/package-info.java @@ -1,6 +1,6 @@ /** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that can be encountered in a {@link io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup}. + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that can be encountered in a {@link io.github.thebusybiscuit.slimefun5.api.items.groups.SeasonalItemGroup}. * These items only show up at a certain time of the year. */ -package io.github.thebusybiscuit.slimefun4.implementation.items.seasonal; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.items.seasonal; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/AbstractTeleporterPlate.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/AbstractTeleporterPlate.java similarity index 77% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/AbstractTeleporterPlate.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/AbstractTeleporterPlate.java index 477444b7e1..d0a4f80b1d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/AbstractTeleporterPlate.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/AbstractTeleporterPlate.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.teleporter; +package io.github.thebusybiscuit.slimefun5.implementation.items.teleporter; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,11 +7,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.TeleporterListener; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.TeleporterListener; /** * The {@link AbstractTeleporterPlate} is the abstract super class @@ -47,3 +47,4 @@ protected AbstractTeleporterPlate(ItemGroup itemGroup, SlimefunItemStack item, R public abstract boolean hasAccess(@Nonnull Player p, @Nonnull Block block); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PersonalActivationPlate.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/PersonalActivationPlate.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PersonalActivationPlate.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/PersonalActivationPlate.java index e9fc6dfbb9..95b18fa5ff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PersonalActivationPlate.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/PersonalActivationPlate.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.teleporter; +package io.github.thebusybiscuit.slimefun5.implementation.items.teleporter; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,10 +8,10 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -50,3 +50,4 @@ public boolean hasAccess(Player p, Block b) { return BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString()); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PortableTeleporter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/PortableTeleporter.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PortableTeleporter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/PortableTeleporter.java index 2f1261f201..b110df0b6a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/PortableTeleporter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/PortableTeleporter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.teleporter; +package io.github.thebusybiscuit.slimefun5.implementation.items.teleporter; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,15 +7,15 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * This item allows a {@link Player} to access and teleport to his waypoints @@ -58,3 +58,4 @@ public float getMaxItemCharge(ItemStack item) { return CAPACITY; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/SharedActivationPlate.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/SharedActivationPlate.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/SharedActivationPlate.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/SharedActivationPlate.java index 8cf9e163f9..7ac95e5198 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/SharedActivationPlate.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/SharedActivationPlate.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.teleporter; +package io.github.thebusybiscuit.slimefun5.implementation.items.teleporter; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,9 +6,9 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; /** * The {@link SharedActivationPlate} is a teleporter activation plate @@ -33,3 +33,4 @@ public boolean hasAccess(Player p, Block b) { return true; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/Teleporter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/Teleporter.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/Teleporter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/Teleporter.java index 6537a5a85d..8f87544cae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/Teleporter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/Teleporter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.teleporter; +package io.github.thebusybiscuit.slimefun5.implementation.items.teleporter; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,14 +6,14 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork; -import io.github.thebusybiscuit.slimefun4.api.gps.TeleportationManager; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.gps.GPSNetwork; +import io.github.thebusybiscuit.slimefun5.api.gps.TeleportationManager; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -46,3 +46,4 @@ public void onPlayerPlace(BlockPlaceEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/TeleporterPylon.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/TeleporterPylon.java similarity index 56% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/TeleporterPylon.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/TeleporterPylon.java index ba9e10ecab..5920c17818 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/TeleporterPylon.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/TeleporterPylon.java @@ -1,15 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.teleporter; +package io.github.thebusybiscuit.slimefun5.implementation.items.teleporter; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.RainbowTickHandler; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.RainbowTickHandler; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.RainbowBlock; /** * The {@link TeleporterPylon} is a special kind of {@link RainbowBlock} which is required @@ -25,7 +26,8 @@ public class TeleporterPylon extends RainbowBlock { @ParametersAreNonnullByDefault public TeleporterPylon(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { - super(itemGroup, item, recipeType, recipe, recipeOutput, new RainbowTickHandler(Material.CYAN_STAINED_GLASS, Material.PURPLE_STAINED_GLASS)); + super(itemGroup, item, recipeType, recipe, recipeOutput, new RainbowTickHandler(XMaterial.CYAN_STAINED_GLASS.parseMaterial(), XMaterial.PURPLE_STAINED_GLASS.parseMaterial())); } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/package-info.java new file mode 100644 index 0000000000..9c77ef2274 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/teleporter/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are related to the {@link io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.Teleporter}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.teleporter; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ClimbingPick.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ClimbingPick.java index dbd9cdad9a..85a5b06bb7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ClimbingPick.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import java.util.ArrayList; import java.util.Collection; @@ -27,20 +31,20 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.settings.ClimbableSurface; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.events.ClimbingPickLaunchEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.settings.ClimbableSurface; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEnchantment; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * The {@link ClimbingPick} launches you 1 block upwards when you right click @@ -174,14 +178,14 @@ public ItemUseHandler getItemHandler() { } // Check for dual wielding - if (isDualWieldingEnabled() && !isItem(getOtherHandItem(p, e.getHand()))) { + if (isDualWieldingEnabled() && !isItem(getOtherHandItem(p, HandCompat.getHand(e)))) { Slimefun.getLocalization().sendMessage(p, "messages.climbing-pick.dual-wielding"); return; } // Top and bottom faces won't be allowed if (e.getClickedFace() != BlockFace.DOWN && e.getClickedFace() != BlockFace.UP) { - climb(p, e.getHand(), e.getItem(), block); + climb(p, HandCompat.getHand(e), e.getItem(), block); } }; } @@ -190,9 +194,9 @@ public ItemUseHandler getItemHandler() { @ParametersAreNonnullByDefault private ItemStack getOtherHandItem(Player p, EquipmentSlot hand) { if (hand == EquipmentSlot.HAND) { - return p.getInventory().getItemInOffHand(); + return HandCompat.getOffHand(p.getInventory()); } else { - return p.getInventory().getItemInMainHand(); + return HandCompat.getMainHand(p.getInventory()); } } @@ -224,11 +228,11 @@ private void climb(Player p, EquipmentSlot hand, ItemStack item, Block block) { private void swing(Player p, Block b, EquipmentSlot hand, ItemStack item) { if (isDualWieldingEnabled()) { if (ThreadLocalRandom.current().nextBoolean()) { - damageItem(p, p.getInventory().getItemInMainHand()); + damageItem(p, HandCompat.getMainHand(p.getInventory())); playAnimation(p, b, EquipmentSlot.HAND); } else { - damageItem(p, p.getInventory().getItemInOffHand()); - playAnimation(p, b, EquipmentSlot.OFF_HAND); + damageItem(p, HandCompat.getOffHand(p.getInventory())); + playAnimation(p, b, HandCompat.OFF_HAND); } } else { damageItem(p, item); @@ -256,9 +260,9 @@ private void playAnimation(Player p, Block b, EquipmentSlot hand) { p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); if (hand == EquipmentSlot.HAND) { - p.swingMainHand(); + ReflectionCompat.invoke(p, "swingMainHand"); } else { - p.swingOffHand(); + ReflectionCompat.invoke(p, "swingOffHand"); } } } @@ -268,7 +272,7 @@ public List getDisplayRecipes() { List display = new ArrayList<>(); for (Material mat : surfaces.keySet()) { - if (mat.isItem()) { + if (MaterialCompat.isItem(mat)) { display.add(new ItemStack(mat)); } } @@ -281,3 +285,4 @@ public String getLabelLocalPath() { return "guide.tooltips.recipes.climbing-pick"; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosivePickaxe.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosivePickaxe.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosivePickaxe.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosivePickaxe.java index ae4d016ca6..dc1250b190 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosivePickaxe.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosivePickaxe.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; /** * The {@link ExplosivePickaxe} is a pickaxe which can destroy {@link Block}s @@ -27,3 +27,4 @@ public ExplosivePickaxe(ItemGroup itemGroup, SlimefunItemStack item, RecipeType } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosiveShovel.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosiveShovel.java index 784d8c897b..c4f794c82d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveShovel.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosiveShovel.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,11 +8,11 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * The {@link ExplosiveShovel} works similar to the {@link ExplosivePickaxe}. @@ -37,3 +37,4 @@ protected boolean canBreak(@Nonnull Player p, Block b) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosiveTool.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosiveTool.java index 59fcd86d00..e30399de50 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/ExplosiveTool.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ItemsAdderCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.WorldCompat; import java.lang.reflect.Constructor; import java.util.ArrayList; @@ -8,33 +11,32 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import dev.lone.itemsadder.api.CustomBlock; import org.bukkit.Bukkit; import org.bukkit.Effect; -import org.bukkit.ExplosionResult; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.events.ExplosiveToolBreakBlocksEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ToolUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -53,6 +55,10 @@ public class ExplosiveTool extends SimpleSlimefunItem implements private final ItemSetting callExplosionEvent = new ItemSetting<>(this, "call-explosion-event", false); private static Constructor pre21ExplodeEventConstructor; + // The 1.21 BlockExplodeEvent ctor takes an org.bukkit.ExplosionResult, a type absent on the 1.8.8 + // floor — resolved reflectively so it is never referenced as a type. Null on older servers. + private static Constructor explodeEventConstructor1_21; + private static Object explosionResultDestroy; static { if (Slimefun.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_21)) { try { @@ -60,6 +66,14 @@ public class ExplosiveTool extends SimpleSlimefunItem implements } catch (Exception e) { Slimefun.logger().log(Level.SEVERE, "Could not find constructor for BlockExplodeEvent", e); } + } else { + try { + Class resultClass = Class.forName("org.bukkit.ExplosionResult"); + explosionResultDestroy = Enum.valueOf(resultClass.asSubclass(Enum.class), "DESTROY"); + explodeEventConstructor1_21 = BlockExplodeEvent.class.getConstructor(Block.class, BlockState.class, List.class, float.class, resultClass); + } catch (Exception e) { + Slimefun.logger().log(Level.SEVERE, "Could not find 1.21 constructor for BlockExplodeEvent", e); + } } } @@ -100,8 +114,8 @@ private void breakBlocks(BlockBreakEvent e, Player p, ItemStack item, Block b, L for (Block block : blockExplodeEvent.blockList()) { if (canBreak(p, block)) { if (Slimefun.getIntegrations().isCustomBlock(block)) { - drops.addAll(CustomBlock.byAlreadyPlaced(block).getLoot()); - CustomBlock.remove(block.getLocation()); + drops.addAll(ItemsAdderCompat.getLoot(block)); + ItemsAdderCompat.remove(block.getLocation()); } blocksToDestroy.add(block); } @@ -111,8 +125,8 @@ private void breakBlocks(BlockBreakEvent e, Player p, ItemStack item, Block b, L for (Block block : blocks) { if (canBreak(p, block)) { if (Slimefun.getIntegrations().isCustomBlock(block)) { - drops.addAll(CustomBlock.byAlreadyPlaced(block).getLoot()); - CustomBlock.remove(block.getLocation()); + drops.addAll(ItemsAdderCompat.getLoot(block)); + ItemsAdderCompat.remove(block.getLocation()); } blocksToDestroy.add(block); } @@ -159,7 +173,7 @@ protected boolean canBreak(@Nonnull Player p, @Nonnull Block b) { return false; } else if (SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(b.getType())) { return false; - } else if (!b.getWorld().getWorldBorder().isInside(b.getLocation())) { + } else if (!WorldCompat.isInside(b.getWorld(), b.getLocation())) { return false; } else { return Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.BREAK_BLOCK); @@ -206,9 +220,17 @@ private BlockExplodeEvent createNewBlockExplodeEvent( List blocks, float yield ) { - var version = Slimefun.getMinecraftVersion(); + MinecraftVersion version = Slimefun.getMinecraftVersion(); if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_21)) { - return new BlockExplodeEvent(block, block.getState(), blocks, yield, ExplosionResult.DESTROY); + if (explodeEventConstructor1_21 != null && explosionResultDestroy != null) { + try { + return (BlockExplodeEvent) explodeEventConstructor1_21.newInstance(block, block.getState(), blocks, yield, explosionResultDestroy); + } catch (Exception e) { + Slimefun.logger().log(Level.SEVERE, "Could not construct BlockExplodeEvent", e); + } + } + + return null; } else if (pre21ExplodeEventConstructor != null) { try { return (BlockExplodeEvent) pre21ExplodeEventConstructor.newInstance(block, blocks, yield); @@ -222,3 +244,4 @@ private BlockExplodeEvent createNewBlockExplodeEvent( } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/GoldPan.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/GoldPan.java index e8bd5c99d6..8c27ead68f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/GoldPan.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import java.util.ArrayList; import java.util.Arrays; @@ -14,27 +14,29 @@ import org.bukkit.Effect; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.entity.ItemFrame; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.collections.RandomizedSet; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricGoldPan; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.AutomatedPanningMachine; -import io.github.thebusybiscuit.slimefun4.implementation.settings.GoldPanDrop; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricGoldPan; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.AutomatedPanningMachine; +import io.github.thebusybiscuit.slimefun5.implementation.settings.GoldPanDrop; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * A {@link GoldPan} is a {@link SlimefunItem} which allows you to obtain various @@ -67,7 +69,7 @@ public GoldPan(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTyp * @deprecated since RC-36 * Use {@link GoldPan#getInputMaterials()} instead. */ - @Deprecated(since = "RC-36") + @Deprecated public Material getInputMaterial() { return Material.GRAVEL; } @@ -92,7 +94,7 @@ public Material getInputMaterial() { settings.add(new GoldPanDrop(this, "chance.FLINT", 40, new ItemStack(Material.FLINT))); settings.add(new GoldPanDrop(this, "chance.CLAY", 20, new ItemStack(Material.CLAY_BALL))); settings.add(new GoldPanDrop(this, "chance.SIFTED_ORE", 35, SlimefunItems.SIFTED_ORE.item())); - settings.add(new GoldPanDrop(this, "chance.IRON_NUGGET", 5, new ItemStack(Material.IRON_NUGGET))); + settings.add(new GoldPanDrop(this, "chance.IRON_NUGGET", 5, MaterialCompat.stack(XMaterial.IRON_NUGGET))); return settings; } @@ -225,3 +227,4 @@ public boolean isValidInputMaterial(@Nonnull Material material) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/GrapplingHook.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/GrapplingHook.java index 0caf733724..c0dd7ad3bc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/GrapplingHook.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.UUID; @@ -7,6 +10,7 @@ import org.bukkit.GameMode; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Arrow; import org.bukkit.entity.Bat; import org.bukkit.entity.EntityType; @@ -15,16 +19,16 @@ import org.bukkit.util.Vector; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.GrapplingHookListener; /** * The {@link GrapplingHook} is a simple {@link SlimefunItem} which allows a {@link Player} @@ -56,17 +60,17 @@ public GrapplingHook(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec UUID uuid = p.getUniqueId(); boolean isConsumed = consumeOnUse.getValue() && p.getGameMode() != GameMode.CREATIVE; - if (e.getClickedBlock().isEmpty() && !Slimefun.getGrapplingHookListener().isGrappling(uuid)) { + if (!e.getClickedBlock().isPresent() && !Slimefun.getGrapplingHookListener().isGrappling(uuid)) { e.cancel(); - if (p.getInventory().getItemInOffHand().getType() == Material.BOW) { + if (HandCompat.getOffHand(p.getInventory()).getType() == Material.BOW) { // Cancel, to fix dupe #740 return; } ItemStack item = e.getItem(); - if (item.getType() == Material.LEAD && isConsumed) { + if (item.getType() == XMaterial.LEAD.parseMaterial() && isConsumed) { // If consume on use is enabled, consume one item ItemUtils.consumeItem(item, false); } @@ -77,11 +81,11 @@ public GrapplingHook(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec arrow.setVelocity(direction); Bat bat = (Bat) p.getWorld().spawnEntity(p.getLocation(), EntityType.BAT); - bat.setInvulnerable(true); + ReflectionCompat.invoke(bat, "setInvulnerable", true); bat.setCanPickupItems(false); - bat.setAI(false); - bat.setSilent(true); - bat.setInvisible(true); + ReflectionCompat.invoke(bat, "setAI", false); + ReflectionCompat.invoke(bat, "setSilent", true); + ReflectionCompat.invoke(bat, "setInvisible", true); bat.setLeashHolder(arrow); boolean state = item.getType() != Material.SHEARS; @@ -90,3 +94,4 @@ public GrapplingHook(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/LumberAxe.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/LumberAxe.java index faf6e0a44d..976112c131 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/LumberAxe.java @@ -1,29 +1,28 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; import java.util.List; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.Axis; import org.bukkit.Effect; import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.Tag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; -import org.bukkit.block.data.Orientable; import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.blocks.Vein; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ToolUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -90,13 +89,15 @@ private boolean isUnstrippedLog(@Nonnull Block block) { private void stripLog(@Nonnull Block b) { // No need for a SoundEffect here, this is supposed to be a vanilla sound. - b.getWorld().playSound(b.getLocation(), Sound.ITEM_AXE_STRIP, 1, 1); - Axis axis = ((Orientable) b.getBlockData()).getAxis(); + SoundCompat.playAt(b.getLocation(), "ITEM_AXE_STRIP", null, 1, 1); + // Block data is held as an opaque Object and its axis read/written reflectively, so this + // class references no 1.13+ block.data type in its bytecode (required for legacy loading). + Object axis = BlockDataCompat.get(BlockDataCompat.getBlockData(b), "getAxis"); b.setType(Material.valueOf("STRIPPED_" + b.getType().name())); - Orientable orientable = (Orientable) b.getBlockData(); - orientable.setAxis(axis); - b.setBlockData(orientable); + Object orientable = BlockDataCompat.getBlockData(b); + BlockDataCompat.set(orientable, "setAxis", axis); + BlockDataCompat.setBlockData(b, orientable); } private void breakLog(@Nonnull Block b) { @@ -109,3 +110,4 @@ private void breakLog(@Nonnull Block b) { b.setType(Material.AIR); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/NetherGoldPan.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/NetherGoldPan.java index 18c996547a..4b8286ead4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/NetherGoldPan.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/NetherGoldPan.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import java.util.Arrays; import java.util.HashSet; @@ -8,12 +8,14 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.settings.GoldPanDrop; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.settings.GoldPanDrop; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link NetherGoldPan} is a variant of the regular {@link GoldPan} @@ -25,7 +27,7 @@ */ public class NetherGoldPan extends GoldPan { - private final Set inputMaterials = new HashSet<>(Arrays.asList(Material.SOUL_SAND, Material.SOUL_SOIL)); + private final Set inputMaterials = new HashSet<>(Arrays.asList(Material.SOUL_SAND, XMaterial.SOUL_SOIL.parseMaterial())); @ParametersAreNonnullByDefault public NetherGoldPan(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -33,7 +35,7 @@ public NetherGoldPan(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec } @Override - @Deprecated(since = "RC-36") + @Deprecated public Material getInputMaterial() { return Material.SOUL_SAND; } @@ -49,7 +51,7 @@ public Material getInputMaterial() { settings.add(new GoldPanDrop(this, "chance.QUARTZ", 50, new ItemStack(Material.QUARTZ))); settings.add(new GoldPanDrop(this, "chance.GOLD_NUGGET", 25, new ItemStack(Material.GOLD_NUGGET))); - settings.add(new GoldPanDrop(this, "chance.NETHER_WART", 10, new ItemStack(Material.NETHER_WART))); + settings.add(new GoldPanDrop(this, "chance.NETHER_WART", 10, MaterialCompat.stack(XMaterial.NETHER_WART))); settings.add(new GoldPanDrop(this, "chance.BLAZE_POWDER", 8, new ItemStack(Material.BLAZE_POWDER))); settings.add(new GoldPanDrop(this, "chance.GLOWSTONE_DUST", 5, new ItemStack(Material.GLOWSTONE_DUST))); settings.add(new GoldPanDrop(this, "chance.GHAST_TEAR", 2, new ItemStack(Material.GHAST_TEAR))); @@ -58,3 +60,4 @@ public Material getInputMaterial() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfContainment.java similarity index 62% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfContainment.java index 86499f2bee..e0649b87c4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfContainment.java @@ -1,29 +1,32 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.AbstractMonsterSpawner; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BrokenSpawner; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ToolUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.AbstractMonsterSpawner; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.BrokenSpawner; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.RepairedSpawner; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.api.BlockStorage; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * The {@link PickaxeOfContainment} is a Pickaxe that allows you to break Spawners. @@ -48,12 +51,12 @@ public PickaxeOfContainment(ItemGroup itemGroup, SlimefunItemStack item, RecipeT return (e, tool, fortune, drops) -> { Block b = e.getBlock(); - if (b.getType() == Material.SPAWNER) { + if (b.getType() == XMaterial.SPAWNER.parseMaterial()) { ItemStack spawner = breakSpawner(b); SlimefunUtils.spawnItem(b.getLocation(), spawner, ItemSpawnReason.BROKEN_SPAWNER_DROP, true, e.getPlayer()); e.setExpToDrop(0); - e.setDropItems(false); + ReflectionCompat.invoke(e, "setDropItems", false); } }; } @@ -73,12 +76,13 @@ public PickaxeOfContainment(ItemGroup itemGroup, SlimefunItemStack item, RecipeT BlockState state = PaperLib.getBlockState(b, false).getState(); - if (state instanceof CreatureSpawner creatureSpawner) { - EntityType entityType = creatureSpawner.getSpawnedType(); + if (state instanceof CreatureSpawner) { + CreatureSpawner creatureSpawner = (CreatureSpawner) state; EntityType entityType = creatureSpawner.getSpawnedType(); return spawner.getItemForEntityType(entityType); } - return new ItemStack(Material.SPAWNER); + return MaterialCompat.stack(XMaterial.SPAWNER); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfTheSeeker.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfTheSeeker.java index 1aab6007c7..28f06fd764 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfTheSeeker.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -10,16 +10,16 @@ import org.bukkit.event.Event.Result; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * The {@link PickaxeOfTheSeeker} will make you face the nearest ore upon right clicking. @@ -101,3 +101,4 @@ public boolean isDamageable() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfVeinMining.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfVeinMining.java index 41a293a7f3..a66a241af1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PickaxeOfVeinMining.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import java.util.List; @@ -15,15 +15,15 @@ import io.github.bakedlibs.dough.blocks.Vein; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.ToolUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * The {@link PickaxeOfVeinMining} is a powerful tool which allows you to mine an entire vein of ores @@ -73,3 +73,4 @@ private void breakBlocks(Player p, List blocks, int fortune, ItemStack to } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PortableCrafter.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PortableCrafter.java index 3cf3443d4f..6abfaea224 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PortableCrafter.java @@ -1,20 +1,20 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.entity.Player; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link PortableCrafter} is one of the oldest items in Slimefun. @@ -41,3 +41,4 @@ public PortableCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableDustbin.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PortableDustbin.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableDustbin.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PortableDustbin.java index 0b21792473..4ba38fbb2c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableDustbin.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/PortableDustbin.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -9,14 +9,14 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.TrashCan; /** * The {@link PortableDustbin} is one of the oldest items in Slimefun. @@ -44,3 +44,4 @@ public PortableDustbin(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r }; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/SmeltersPickaxe.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/SmeltersPickaxe.java index 3f5f051c44..4da21837a0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/SmeltersPickaxe.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.Collection; import java.util.Optional; @@ -10,14 +12,14 @@ import org.bukkit.block.Block; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.ToolUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -43,7 +45,7 @@ public SmeltersPickaxe(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r Collection blockDrops = b.getDrops(tool); for (ItemStack drop : blockDrops) { - if (drop != null && !drop.getType().isAir()) { + if (drop != null && !MaterialCompat.isAir(drop.getType())) { smelt(b, drop, fortune); drops.add(drop); } @@ -73,3 +75,4 @@ public boolean isDamageable() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TapeMeasure.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TapeMeasure.java index db94cdfa86..cc12fbd2a4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TapeMeasure.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.text.DecimalFormat; import java.util.Optional; @@ -9,7 +11,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Location; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -18,15 +20,15 @@ import com.google.gson.JsonObject; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.JsonUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.JsonUtils; /** * The {@link TapeMeasure} is used to measure the distance between two {@link Block Blocks}. @@ -71,7 +73,7 @@ private void setAnchor(Player p, ItemStack item, Block block) { json.addProperty("y", block.getY()); json.addProperty("z", block.getZ()); - meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, json.toString()); + PdcCompat.set(meta, key, "STRING", json.toString()); String anchor = block.getX() + " | " + block.getY() + " | " + block.getZ(); Slimefun.getLocalization().sendMessage(p, "messages.tape-measure.anchor-set", msg -> msg.replace("%anchor%", anchor)); @@ -94,7 +96,7 @@ private void measure(Player p, ItemStack item, Block block) { public @Nonnull Optional getAnchor(Player p, ItemStack item) { ItemMeta meta = item.getItemMeta(); - String data = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING); + String data = (String) PdcCompat.get(meta, key, "STRING"); if (data != null) { JsonObject json = JsonUtils.parseString(data).getAsJsonObject(); @@ -129,3 +131,4 @@ private void measure(Player p, ItemStack item, Block block) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/package-info.java new file mode 100644 index 0000000000..2f1d301f09 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/package-info.java @@ -0,0 +1,5 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are tools. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/ExplosiveBow.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/ExplosiveBow.java index 1477549c9f..88bcc7377d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/ExplosiveBow.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; +package io.github.thebusybiscuit.slimefun5.implementation.items.weapons; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import java.util.Collection; @@ -6,7 +9,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Bukkit; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -15,13 +18,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.core.handlers.BowShootHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; /** * The {@link ExplosiveBow} is a {@link SlimefunBow} which creates a fake explosion when it hits @@ -49,11 +52,11 @@ public ExplosiveBow(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] rec @Override public BowShootHandler onShoot() { return (e, target) -> { - target.getWorld().spawnParticle(VersionedParticle.EXPLOSION, target.getLocation(), 1); + ParticleCompat.spawn(target.getWorld(), VersionedParticle.EXPLOSION, target.getLocation(), 1); SoundEffect.EXPLOSIVE_BOW_HIT_SOUND.playAt(target.getLocation(), SoundCategory.PLAYERS); int radius = range.getValue(); - Collection entities = target.getWorld().getNearbyEntities(target.getLocation(), radius, radius, radius, this::canDamage); + Collection entities = EntityCompat.getNearbyEntities(target.getWorld(), target.getLocation(), radius, radius, radius, this::canDamage); for (Entity nearby : entities) { LivingEntity entity = (LivingEntity) nearby; @@ -81,3 +84,4 @@ private boolean canDamage(@Nonnull Entity entity) { return entity instanceof LivingEntity && !(entity instanceof ArmorStand) && entity.isValid(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/IcyBow.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/IcyBow.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/IcyBow.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/IcyBow.java index b3e54f15ed..a53c7c0b99 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/IcyBow.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/IcyBow.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; +package io.github.thebusybiscuit.slimefun5.implementation.items.weapons; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -10,12 +10,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.core.handlers.BowShootHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; /** * The {@link IcyBow} is a special kind of bow which slows down any @@ -36,14 +37,14 @@ public IcyBow(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] recipe) { @Override public BowShootHandler onShoot() { return (e, n) -> { - if (n instanceof Player player) { - // Fixes #3060 - Don't apply effects if the arrow was successfully blocked. + if (n instanceof Player) { + Player player = (Player) n; // Fixes #3060 - Don't apply effects if the arrow was successfully blocked. if (player.isBlocking() && e.getFinalDamage() <= 0) { return; } if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { - player.setFreezeTicks(60); + ReflectionCompat.invoke(player, "setFreezeTicks", 60); } } n.getWorld().playEffect(n.getLocation(), Effect.STEP_SOUND, Material.ICE); @@ -54,3 +55,4 @@ public BowShootHandler onShoot() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SeismicAxe.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SeismicAxe.java index 93d9095c03..d418e1e452 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SeismicAxe.java @@ -1,4 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; +package io.github.thebusybiscuit.slimefun5.implementation.items.weapons; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.WorldCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.HashSet; import java.util.List; @@ -25,14 +30,14 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link SeismicAxe} is an interesting weapon. It spawns ghostly block entities in a straight line @@ -60,7 +65,7 @@ public SeismicAxe(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe public ItemUseHandler getItemHandler() { return e -> { Player p = e.getPlayer(); - List blocks = p.getLineOfSight(null, RANGE); + List blocks = p.getLineOfSight((Set) null, RANGE); Set pushedEntities = new HashSet<>(); // Skip the first two, too close to the player. @@ -73,7 +78,7 @@ public ItemUseHandler getItemHandler() { // Check if they have room above. Block blockAbove = ground.getRelative(BlockFace.UP); - if (blockAbove.getType().isAir()) { + if (MaterialCompat.isAir(blockAbove.getType())) { createJumpingBlock(ground, blockAbove, i); } @@ -100,7 +105,7 @@ && canReach(p.getLocation(), n.getLocation(), groundLocation) @ParametersAreNonnullByDefault private void createJumpingBlock(Block ground, Block blockAbove, int index) { Location loc = ground.getRelative(BlockFace.UP).getLocation().add(0.5, 0.0, 0.5); - FallingBlock block = ground.getWorld().spawnFallingBlock(loc, ground.getBlockData()); + FallingBlock block = BlockDataCompat.spawnFallingBlock(ground.getWorld(), loc, ground); block.setDropItem(false); block.setVelocity(new Vector(0, 0.4 + index * 0.01, 0)); block.setMetadata("seismic_axe", new FixedMetadataValue(Slimefun.instance(), "fake_block")); @@ -150,7 +155,7 @@ private void pushEntity(Player p, Entity entity) { private @Nonnull Block findGround(@Nonnull Block b) { if (b.getType() == Material.AIR) { - int minHeight = b.getWorld().getMinHeight(); + int minHeight = WorldCompat.getMinHeight(b.getWorld()); for (int y = 0; b.getY() - y > minHeight; y++) { Block block = b.getRelative(0, -y, 0); @@ -169,3 +174,4 @@ public boolean isDamageable() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SlimefunBow.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SlimefunBow.java similarity index 70% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SlimefunBow.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SlimefunBow.java index 09ffcdbe49..345f678fb9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SlimefunBow.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SlimefunBow.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; +package io.github.thebusybiscuit.slimefun5.implementation.items.weapons; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,11 +6,11 @@ import org.bukkit.entity.Arrow; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.BowShootHandler; /** * This class represents a {@link SlimefunItem} that is a Bow. @@ -37,3 +37,4 @@ public void preRegister() { public abstract BowShootHandler onShoot(); } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SwordOfBeheading.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SwordOfBeheading.java new file mode 100644 index 0000000000..cf24ad2da5 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/SwordOfBeheading.java @@ -0,0 +1,121 @@ +package io.github.thebusybiscuit.slimefun5.implementation.items.weapons; + +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Piglin; +import org.bukkit.entity.Player; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Zombie; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SkullMeta; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; + +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityKillHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; + +/** + * The {@link SwordOfBeheading} is a special kind of sword which allows you to obtain + * {@link Zombie}, {@link Skeleton}, {@link Creeper} and {@link Piglin} skulls when killing the respective + * {@link Monster}. + * Additionally, you can also obtain the head of a {@link Player} by killing them too. + * This sword also allows you to have a higher chance of getting the skull of a {@link WitherSkeleton} too. + * + * All chances are managed by an {@link ItemSetting} and can be configured. + * + * @author TheBusyBiscuit + * + */ +public class SwordOfBeheading extends SimpleSlimefunItem { + + private final ItemSetting chanceZombie = new IntRangeSetting(this, "chance.ZOMBIE", 0, 40, 100); + private final ItemSetting chanceSkeleton = new IntRangeSetting(this, "chance.SKELETON", 0, 40, 100); + private final ItemSetting chanceWitherSkeleton = new IntRangeSetting(this, "chance.WITHER_SKELETON", 0, 25, 100); + private final ItemSetting chanceCreeper = new IntRangeSetting(this, "chance.CREEPER", 0, 40, 100); + private final ItemSetting chancePiglin = new IntRangeSetting(this, "chance.PIGLIN", 0, 40, 100); + private final ItemSetting chancePlayer = new IntRangeSetting(this, "chance.PLAYER", 0, 70, 100); + + @ParametersAreNonnullByDefault + public SwordOfBeheading(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(itemGroup, item, recipeType, recipe); + + addItemSetting(chanceZombie, chanceSkeleton, chanceWitherSkeleton, chanceCreeper, chancePiglin, chancePlayer); + } + + @Override + public EntityKillHandler getItemHandler() { + return (e, entity, killer, item) -> { + Random random = ThreadLocalRandom.current(); + + // Java-8 universal port: the original used a fall-through switch on EntityType (no breaks), + // so a matching case also rolls every subsequent case's chance. That behaviour is preserved + // here with a cascading "fall" flag, while EntityCompat.entityType resolves constants that do + // not exist at the 1.8.8 compile floor (WITHER_SKELETON, PIGLIN) without breaking the build. + EntityType type = e.getEntityType(); + boolean fall = false; + + if (fall || type == EntityCompat.entityType("ZOMBIE")) { + fall = true; + if (random.nextInt(100) < chanceZombie.getValue()) { + e.getDrops().add(MaterialCompat.stack(XMaterial.ZOMBIE_HEAD)); + } + } + if (fall || type == EntityCompat.entityType("SKELETON")) { + fall = true; + if (random.nextInt(100) < chanceSkeleton.getValue()) { + e.getDrops().add(MaterialCompat.stack(XMaterial.SKELETON_SKULL)); + } + } + if (fall || type == EntityCompat.entityType("CREEPER")) { + fall = true; + if (random.nextInt(100) < chanceCreeper.getValue()) { + e.getDrops().add(MaterialCompat.stack(XMaterial.CREEPER_HEAD)); + } + } + if (fall || type == EntityCompat.entityType("WITHER_SKELETON")) { + fall = true; + if (random.nextInt(100) < chanceWitherSkeleton.getValue()) { + e.getDrops().add(MaterialCompat.stack(XMaterial.WITHER_SKELETON_SKULL)); + } + } + if (fall || type == EntityCompat.entityType("PIGLIN")) { + fall = true; + if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_20) && + random.nextInt(100) < chancePiglin.getValue()) { + e.getDrops().add(MaterialCompat.stack(XMaterial.PIGLIN_HEAD)); + } + } + if (fall || type == EntityCompat.entityType("PLAYER")) { + fall = true; + if (random.nextInt(100) < chancePlayer.getValue()) { + ItemStack skull = MaterialCompat.stack(XMaterial.PLAYER_HEAD); + + ItemMeta meta = skull.getItemMeta(); + ReflectionCompat.invoke((SkullMeta) meta, "setOwningPlayer", (Player) e.getEntity()); + skull.setItemMeta(meta); + + e.getDrops().add(skull); + } + } + }; + } + +} + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/VampireBlade.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/VampireBlade.java index 006db130e2..b3e5a49cc4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/VampireBlade.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/VampireBlade.java @@ -1,23 +1,22 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; +package io.github.thebusybiscuit.slimefun5.implementation.items.weapons; import java.util.concurrent.ThreadLocalRandom; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.attribute.Attribute; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.WeaponUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.settings.IntRangeSetting; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.handlers.WeaponUseHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.SimpleSlimefunItem; /** * The {@link VampireBlade} is a weapon that applies a Healing effect to any {@link Player} @@ -45,7 +44,7 @@ public VampireBlade(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci if (ThreadLocalRandom.current().nextInt(100) < getChance()) { SoundEffect.VAMPIRE_BLADE_HEALING_SOUND.playFor(p); double health = p.getHealth() + HEALING_AMOUNT; - double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); + double maxHealth = p.getMaxHealth(); p.setHealth(Math.min(health, maxHealth)); } }; @@ -60,3 +59,4 @@ public int getChance() { return chance.getValue(); } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/package-info.java new file mode 100644 index 0000000000..254b9289e6 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/items/weapons/package-info.java @@ -0,0 +1,6 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} + * that are weapons, implementations of + * {@link io.github.thebusybiscuit.slimefun5.implementation.items.weapons.SlimefunBow} for example. + */ +package io.github.thebusybiscuit.slimefun5.implementation.items.weapons; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/AncientAltarListener.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/AncientAltarListener.java index 81b66442a3..3b3a7e1eb7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/AncientAltarListener.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.HashSet; @@ -14,6 +18,7 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.EntityType; @@ -30,18 +35,18 @@ import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AltarRecipe; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AltarRecipe; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientAltar; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.RepairedSpawner; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.AncientAltarTask; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -96,7 +101,7 @@ public void onInteract(PlayerRightClickEvent e) { } Block b = blockOptional.get(); - if (b.getType() != Material.ENCHANTING_TABLE && b.getType() != Material.DISPENSER) { + if (b.getType() != XMaterial.ENCHANTING_TABLE.parseMaterial() && b.getType() != Material.DISPENSER) { return; } @@ -140,9 +145,9 @@ private void usePedestal(@Nonnull Block pedestal, @Nonnull Player p) { if (!stack.isPresent()) { // Check if the Item in hand is valid - if (p.getInventory().getItemInMainHand().getType() != Material.AIR) { + if (HandCompat.getMainHand(p.getInventory()).getType() != Material.AIR) { // Check for pedestal obstructions - if (!pedestal.getRelative(0, 1, 0).getType().isAir()) { + if (!MaterialCompat.isAir(pedestal.getRelative(0, 1, 0).getType())) { Slimefun.getLocalization().sendMessage(p, "machines.ANCIENT_PEDESTAL.obstructed", true); return; } @@ -179,7 +184,7 @@ private void useAltar(@Nonnull Block altar, @Nonnull Player p) { return; } - ItemStack catalyst = CustomItemStack.create(p.getInventory().getItemInMainHand(), 1); + ItemStack catalyst = CustomItemStack.create(HandCompat.getMainHand(p.getInventory()), 1); List pedestals = getPedestals(altar); if (!altars.contains(altar)) { @@ -229,7 +234,7 @@ private void startRitual(Player p, Block b, List pedestals, ItemStack cat consumed.add(catalyst); if (p.getGameMode() != GameMode.CREATIVE) { - ItemUtils.consumeItem(p.getInventory().getItemInMainHand(), false); + ItemUtils.consumeItem(HandCompat.getMainHand(p.getInventory()), false); } SoundEffect.ANCIENT_ALTAR_START_SOUND.playAt(b); @@ -365,3 +370,4 @@ public void onItemDespawn(ItemDespawnEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AutoCrafterListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/AutoCrafterListener.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AutoCrafterListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/AutoCrafterListener.java index 9dddeb628d..6d4653e0bd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AutoCrafterListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/AutoCrafterListener.java @@ -1,11 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import java.util.Optional; import javax.annotation.ParametersAreNonnullByDefault; -import org.bukkit.GameRule; -import org.bukkit.Keyed; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event.Result; @@ -15,13 +16,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractAutoCrafter; -import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.EnhancedAutoCrafter; -import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.VanillaAutoCrafter; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Multimeter; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters.AbstractAutoCrafter; +import io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters.EnhancedAutoCrafter; +import io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters.VanillaAutoCrafter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.Multimeter; /** * This {@link Listener} is responsible for providing interactions to the auto crafters. @@ -47,7 +48,7 @@ public void onInteract(PlayerRightClickEvent e) { Optional clickedBlock = e.getClickedBlock(); // We want to make sure we used the main hand, the interaction was not cancelled and a Block was clicked. - if (e.getHand() == EquipmentSlot.HAND && e.useBlock() != Result.DENY && clickedBlock.isPresent()) { + if (HandCompat.getHand(e) == EquipmentSlot.HAND && e.useBlock() != Result.DENY && clickedBlock.isPresent()) { Optional slimefunBlock = e.getSlimefunBlock(); // Check if the clicked Block is a Slimefun block. @@ -58,8 +59,8 @@ public void onInteract(PlayerRightClickEvent e) { SlimefunItem block = slimefunBlock.get(); // Fixes #2957 - if (block instanceof AbstractAutoCrafter crafter && crafter.canUse(e.getPlayer(), true)) { - Optional slimefunItem = e.getSlimefunItem(); + if (block instanceof AbstractAutoCrafter && ((AbstractAutoCrafter) block).canUse(e.getPlayer(), true)) { + AbstractAutoCrafter crafter = (AbstractAutoCrafter) block; Optional slimefunItem = e.getSlimefunItem(); if (!e.getPlayer().isSneaking() && slimefunItem.isPresent() && slimefunItem.get() instanceof Multimeter) { // Allow Multimeters to pass through and do their job @@ -71,7 +72,8 @@ public void onInteract(PlayerRightClickEvent e) { // Check for the "doLimitedCrafting" gamerule when using a Vanilla Auto-Crafter if (block instanceof VanillaAutoCrafter) { - boolean doLimitedCrafting = e.getPlayer().getWorld().getGameRuleValue(GameRule.DO_LIMITED_CRAFTING); + // GameRule typed accessor is 1.13+; the deprecated String overload exists on 1.8. + boolean doLimitedCrafting = Boolean.parseBoolean(e.getPlayer().getWorld().getGameRuleValue("doLimitedCrafting")); // Check if the recipe of the item is disabled. if (doLimitedCrafting && !hasUnlockedRecipe(e.getPlayer(), e.getItem())) { @@ -93,7 +95,11 @@ public void onInteract(PlayerRightClickEvent e) { @ParametersAreNonnullByDefault private boolean hasUnlockedRecipe(Player p, ItemStack item) { for (Recipe recipe : Slimefun.getMinecraftRecipeService().getRecipesFor(item)) { - if (recipe instanceof Keyed keyed && !p.hasDiscoveredRecipe(keyed.getKey())) { + // recipe is a real org.bukkit Recipe; its key (Keyed, 1.12+) and hasDiscoveredRecipe (1.12+) + // are reached reflectively so we never reference org.bukkit.Keyed (absent on 1.8-1.11). + Object key = ReflectionCompat.invoke(recipe, "getKey"); + + if (key != null && !Boolean.TRUE.equals(ReflectionCompat.invoke(p, "hasDiscoveredRecipe", key))) { return false; } } @@ -101,3 +107,4 @@ private boolean hasUnlockedRecipe(Player p, ItemStack item) { return true; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BackpackListener.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BackpackListener.java index cb6b5ce070..0382e63381 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BackpackListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.HashMap; @@ -14,7 +16,7 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -26,13 +28,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.Cooler; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SlimefunBackpack; /** * This {@link Listener} is responsible for all events centered around a {@link SlimefunBackpack}. @@ -96,8 +98,8 @@ public void onClick(InventoryClickEvent e) { if (item != null) { SlimefunItem backpack = SlimefunItem.getByItem(item); - if (backpack instanceof SlimefunBackpack slimefunBackpack) { - if (e.getClick() == ClickType.NUMBER_KEY) { + if (backpack instanceof SlimefunBackpack) { + SlimefunBackpack slimefunBackpack = (SlimefunBackpack) backpack; if (e.getClick() == ClickType.NUMBER_KEY) { // Prevent disallowed items from being moved using number keys. if (e.getClickedInventory().getType() != InventoryType.PLAYER) { ItemStack hotbarItem = e.getWhoClicked().getInventory().getItem(e.getHotbarButton()); @@ -106,10 +108,10 @@ public void onClick(InventoryClickEvent e) { e.setCancelled(true); } } - } else if (e.getClick() == ClickType.SWAP_OFFHAND) { + } else if ("SWAP_OFFHAND".equals(e.getClick().name())) { if (e.getClickedInventory().getType() != InventoryType.PLAYER) { // Fixes #3265 - Don't move disallowed items using the off hand. - ItemStack offHandItem = e.getWhoClicked().getInventory().getItemInOffHand(); + ItemStack offHandItem = HandCompat.getOffHand(e.getWhoClicked().getInventory()); if (!isAllowed(slimefunBackpack, offHandItem)) { e.setCancelled(true); @@ -213,3 +215,4 @@ public void setBackpackId(@Nonnull OfflinePlayer backpackOwner, @Nonnull ItemSta item.setItemMeta(im); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingsListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BeeWingsListener.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingsListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BeeWingsListener.java index 987409d561..833a15401c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingsListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BeeWingsListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import javax.annotation.Nonnull; @@ -8,9 +10,9 @@ import org.bukkit.event.entity.EntityToggleGlideEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.BeeWings; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.BeeWingsTask; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.BeeWings; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.BeeWingsTask; /** * This {@link Listener} is responsible for the slow falling effect given to the {@link Player} @@ -37,7 +39,7 @@ public BeeWingsListener(@Nonnull Slimefun plugin, @Nonnull BeeWings wings) { @EventHandler(ignoreCancelled = true) public void onApproachGround(EntityToggleGlideEvent e) { - if (wings == null || !e.isGliding() || wings.isDisabled() || !(e.getEntity() instanceof Player)) { + if (wings == null || !EntityCompat.isGliding(e) || wings.isDisabled() || !(e.getEntity() instanceof Player)) { return; } @@ -49,3 +51,4 @@ public void onApproachGround(EntityToggleGlideEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BlockListener.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BlockListener.java index 40b976e345..0a3c5166b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BlockListener.java @@ -1,4 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.List; @@ -29,18 +35,18 @@ import org.bukkit.inventory.meta.ItemMeta; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent; -import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockBreakEvent; -import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.events.ExplosiveToolBreakBlocksEvent; +import io.github.thebusybiscuit.slimefun5.api.events.SlimefunBlockBreakEvent; +import io.github.thebusybiscuit.slimefun5.api.events.SlimefunBlockPlaceEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ToolUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEnchantment; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -71,12 +77,12 @@ public void onBlockPlaceExisting(BlockPlaceEvent e) { Block block = e.getBlock(); // Fixes #2636 - This will solve the "ghost blocks" issue - if (e.getBlockReplacedState().getType().isAir() && BlockStorage.hasBlockInfo(block) && !Slimefun.getTickerTask().isDeletedSoon(block.getLocation())) { + if (MaterialCompat.isAir(e.getBlockReplacedState().getType()) && BlockStorage.hasBlockInfo(block) && !Slimefun.getTickerTask().isDeletedSoon(block.getLocation())) { SlimefunItem sfItem = BlockStorage.check(block); if (sfItem != null) { for (ItemStack item : sfItem.getDrops()) { - if (item != null && !item.getType().isAir()) { + if (item != null && !MaterialCompat.isAir(item.getType())) { block.getWorld().dropItemNaturally(block.getLocation(), item); } } @@ -150,7 +156,7 @@ public void onBlockBreak(BlockBreakEvent e) { return; } - ItemStack item = e.getPlayer().getInventory().getItemInMainHand(); + ItemStack item = HandCompat.getMainHand(e.getPlayer().getInventory()); SlimefunItem sfItem = BlockStorage.check(e.getBlock()); // If there is a Slimefun Block here, call our BreakEvent and, if cancelled, cancel this event and return @@ -166,7 +172,7 @@ public void onBlockBreak(BlockBreakEvent e) { List drops = new ArrayList<>(); - if (!item.getType().isAir()) { + if (!MaterialCompat.isAir(item.getType())) { int fortune = getBonusDropsWithFortune(item, e.getBlock()); callToolHandler(e, item, fortune, drops); } @@ -247,9 +253,9 @@ private void dropItems(BlockBreakEvent e, List drops) { } // Fixes #2560 - if (e.isDropItems()) { - // Disable normal block drops - e.setDropItems(false); + if (!Boolean.FALSE.equals(ReflectionCompat.invoke(e, "isDropItems"))) { + // Disable normal block drops (setDropItems is 1.13+, a no-op on older servers) + ReflectionCompat.invoke(e, "setDropItems", false); for (ItemStack drop : drops) { // Prevent null or air from being dropped @@ -293,9 +299,9 @@ private void checkForSensitiveBlockAbove(Player player, Block block, ItemStack i sfItem.callItemHandler(BlockBreakHandler.class, handler -> handler.onPlayerBreak(dummyEvent, item, drops)); blockAbove.setType(Material.AIR); - if (!dummyEvent.isCancelled() && dummyEvent.isDropItems()) { + if (!dummyEvent.isCancelled() && !Boolean.FALSE.equals(ReflectionCompat.invoke(dummyEvent, "isDropItems"))) { for (ItemStack drop : drops) { - if (drop != null && !drop.getType().isAir()) { + if (drop != null && !MaterialCompat.isAir(drop.getType())) { blockAbove.getWorld().dropItemNaturally(blockAbove.getLocation(), drop); } } @@ -320,7 +326,9 @@ private void checkForSensitiveBlockAbove(Player player, Block block, ItemStack i // There is additionally a second bug with `getMaxChainedNeighborUpdates` not existing in 1.17 @ParametersAreNonnullByDefault private void checkForSensitiveBlocks(Block block, int count, boolean isDropItems) { - if (count >= Bukkit.getServer().getMaxChainedNeighborUpdates()) { + // getMaxChainedNeighborUpdates() is 1.19+; treat as unlimited (never short-circuit) on older servers. + Object maxUpdates = ReflectionCompat.invoke(Bukkit.getServer(), "getMaxChainedNeighborUpdates"); + if (count >= (maxUpdates instanceof Integer ? (Integer) maxUpdates : Integer.MAX_VALUE)) { return; } @@ -328,7 +336,7 @@ private void checkForSensitiveBlocks(Block block, int count, boolean isDropItems // We set the block to air to make use of BlockData#isSupported. block.setType(Material.AIR, false); for (BlockFace face : CARDINAL_BLOCKFACES) { - if (!isSupported(block.getRelative(face).getBlockData(), block.getRelative(face))) { + if (!isSupported(BlockDataCompat.getBlockData(block.getRelative(face)), block.getRelative(face))) { Block relative = block.getRelative(face); if (!isDropItems) { for (ItemStack drop : relative.getDrops()) { @@ -339,7 +347,7 @@ private void checkForSensitiveBlocks(Block block, int count, boolean isDropItems } } // Set the BlockData back: this makes it so containers and spawners drop correctly. This is a hacky fix. - block.setBlockData(state.getBlockData(), false); + BlockDataCompat.setBlockData(block, BlockDataCompat.getBlockData(state), false); state.update(true, false); } @@ -355,9 +363,11 @@ private void checkForSensitiveBlocks(Block block, int count, boolean isDropItems * Whether the {@link BlockData} would be supported at the given {@link Block} */ @ParametersAreNonnullByDefault - private boolean isSupported(BlockData blockData, Block block) { + private boolean isSupported(Object blockData, Block block) { if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_19)) { - return blockData.isSupported(block); + // BlockData#isSupported(Block) is 1.19+; invoke reflectively to avoid a stub-type + // reference in this class's bytecode (which would break legacy class loading). + return Boolean.TRUE.equals(ReflectionCompat.invoke(blockData, "isSupported", block)); } else { // TODO: Make 1.16-1.18 version. BlockData::isSupported is 1.19+. return true; @@ -367,7 +377,7 @@ private boolean isSupported(BlockData blockData, Block block) { private int getBonusDropsWithFortune(@Nullable ItemStack item, @Nonnull Block b) { int amount = 1; - if (item != null && !item.getType().isAir() && item.hasItemMeta()) { + if (item != null && !MaterialCompat.isAir(item.getType()) && item.hasItemMeta()) { /* * Small performance optimization: * ItemStack#getEnchantmentLevel() calls ItemStack#getItemMeta(), so if @@ -388,3 +398,4 @@ private int getBonusDropsWithFortune(@Nullable ItemStack item, @Nonnull Block b) return amount; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BlockPhysicsListener.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BlockPhysicsListener.java index d63289aa46..4c65f3c37a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/BlockPhysicsListener.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; import javax.annotation.Nonnull; import org.bukkit.Location; @@ -19,8 +20,8 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -49,7 +50,7 @@ public void onBlockFall(EntityChangeBlockEvent e) { FallingBlock block = (FallingBlock) e.getEntity(); if (block.getDropItem()) { - block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(block.getBlockData().getMaterial(), 1)); + block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(BlockDataCompat.getMaterial(block), 1)); } } } @@ -113,3 +114,4 @@ public void onBucketUse(PlayerBucketEmptyEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ButcherAndroidListener.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ButcherAndroidListener.java index 9e63107680..0565177b7d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ButcherAndroidListener.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -9,6 +10,7 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.ExperienceOrb; @@ -19,10 +21,11 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.AndroidInstance; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.ButcherAndroid; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * This {@link Listener} handles the collection of drops from an {@link Entity} that was @@ -49,7 +52,8 @@ public void onDeath(EntityDeathEvent e) { // Collect any nearby dropped items for (Entity n : e.getEntity().getNearbyEntities(0.5D, 0.5D, 0.5D)) { - if (n instanceof Item item && n.isValid() && !SlimefunUtils.hasNoPickupFlag(item)) { + if (n instanceof Item && n.isValid() && !SlimefunUtils.hasNoPickupFlag((Item) n)) { + Item item = (Item) n; items.add(item.getItemStack()); n.remove(); } @@ -81,16 +85,17 @@ public void onDeath(EntityDeathEvent e) { private void addExtraDrops(List drops, EntityType entityType) { Random random = ThreadLocalRandom.current(); - if (entityType == EntityType.WITHER_SKELETON && random.nextInt(250) < 2) { - drops.add(new ItemStack(Material.WITHER_SKELETON_SKULL)); + if (entityType == EntityCompat.entityType("WITHER_SKELETON") && random.nextInt(250) < 2) { + drops.add(MaterialCompat.stack(XMaterial.WITHER_SKELETON_SKULL)); } if (entityType == EntityType.BLAZE) { drops.add(new ItemStack(Material.BLAZE_ROD, 1 + random.nextInt(1))); } - if (entityType == EntityType.VINDICATOR) { + if (entityType == EntityCompat.entityType("VINDICATOR")) { drops.add(new ItemStack(Material.EMERALD, 1 + random.nextInt(2))); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/CargoNodeListener.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/CargoNodeListener.java index 0cb86a6d9b..87333728fb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/CargoNodeListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import javax.annotation.Nonnull; @@ -8,9 +10,9 @@ import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoNode; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.CargoNode; /** * This {@link Listener} is solely responsible for preventing Cargo Nodes from being placed @@ -29,7 +31,7 @@ public CargoNodeListener(@Nonnull Slimefun plugin) { public void onCargoNodePlace(BlockPlaceEvent e) { Block b = e.getBlock(); - if ((b.getY() != e.getBlockAgainst().getY() || !e.getBlockReplacedState().getType().isAir()) && isCargoNode(e.getItemInHand())) { + if ((b.getY() != e.getBlockAgainst().getY() || !MaterialCompat.isAir(e.getBlockReplacedState().getType())) && isCargoNode(e.getItemInHand())) { Slimefun.getLocalization().sendMessage(e.getPlayer(), "machines.CARGO_NODES.must-be-placed", true); e.setCancelled(true); } @@ -39,3 +41,4 @@ private boolean isCargoNode(@Nonnull ItemStack item) { return SlimefunItem.getByItem(item) instanceof CargoNode; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/CoolerListener.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/CoolerListener.java index d8c62a9370..0d8ed2717b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/CoolerListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -15,13 +15,13 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.events.CoolerFeedPlayerEvent; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice; +import io.github.thebusybiscuit.slimefun5.api.events.CoolerFeedPlayerEvent; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.Cooler; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.Juice; /** * This {@link Listener} listens for a {@link FoodLevelChangeEvent} or an {@link EntityDamageEvent} for starvation @@ -51,15 +51,16 @@ public CoolerListener(Slimefun plugin, Cooler cooler) { @EventHandler public void onHungerLoss(FoodLevelChangeEvent e) { - if (e.getEntity() instanceof Player player && e.getFoodLevel() < player.getFoodLevel()) { + if (e.getEntity() instanceof Player && e.getFoodLevel() < ((Player) e.getEntity()).getFoodLevel()) { + Player player = (Player) e.getEntity(); checkAndConsume(player); } } @EventHandler public void onHungerDamage(EntityDamageEvent e) { - if (e.getEntity() instanceof Player player && e.getCause() == DamageCause.STARVATION) { - checkAndConsume(player); + if (e.getEntity() instanceof Player && e.getCause() == DamageCause.STARVATION) { + Player player = (Player) e.getEntity(); checkAndConsume(player); } } @@ -137,3 +138,4 @@ private boolean consumeJuice(@Nonnull Player p, @Nonnull ItemStack coolerItem, @ } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DeathpointListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DeathpointListener.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DeathpointListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DeathpointListener.java index fe81796953..0ac5d741cf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DeathpointListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DeathpointListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -12,9 +12,9 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This {@link Listener} listens to the {@link EntityDeathEvent} to automatically @@ -40,3 +40,4 @@ public void onDeath(PlayerDeathEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DebugFishListener.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DebugFishListener.java index 6bcbffd93b..37f9ba4082 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DebugFishListener.java @@ -1,5 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; import java.util.EnumSet; import java.util.Set; import java.util.logging.Level; @@ -8,11 +11,10 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Skull; -import org.bukkit.block.data.Directional; -import org.bukkit.block.data.Rotatable; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -21,16 +23,16 @@ import org.bukkit.inventory.EquipmentSlot; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.bakedlibs.dough.skins.PlayerHead; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun5.core.attributes.EnergyNetProvider; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPlayerHead; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -55,7 +57,7 @@ public DebugFishListener(@Nonnull Slimefun plugin) { @EventHandler public void onDebug(PlayerInteractEvent e) { - if (e.getAction() == Action.PHYSICAL || e.getHand() != EquipmentSlot.HAND) { + if (e.getAction() == Action.PHYSICAL || HandCompat.getHand(e) != EquipmentSlot.HAND) { return; } @@ -93,9 +95,9 @@ private void onRightClick(Player p, Block b, BlockFace face) { // Fixes #2655 - Delaying the placement to prevent a new event from being fired Slimefun.runSync(() -> { Block block = b.getRelative(face); - block.setType(Material.PLAYER_HEAD); + block.setType(XMaterial.PLAYER_HEAD.parseMaterial()); - PlayerHead.setSkin(block, HeadTexture.MISSING_TEXTURE.getAsSkin(), true); + VersionedPlayerHead.setSkin(block, HeadTexture.MISSING_TEXTURE.getBase64Texture(), true); SoundEffect.DEBUG_FISH_CLICK_SOUND.playFor(p); }, 2L); } else if (BlockStorage.hasBlockInfo(b)) { @@ -140,10 +142,10 @@ private void sendInfo(Player p, Block b) { p.sendMessage(ChatColors.color("&dSkull: " + greenCheckmark)); // Check if the skull is a wall skull, and if so use Directional instead of Rotatable. - if (b.getType() == Material.PLAYER_WALL_HEAD) { - p.sendMessage(ChatColors.color(" &dFacing: &e" + ((Directional) b.getBlockData()).getFacing().toString())); + if (b.getType() == XMaterial.PLAYER_WALL_HEAD.parseMaterial()) { + p.sendMessage(ChatColors.color(" &dFacing: &e" + BlockDataCompat.get(BlockDataCompat.getBlockData(b), "getFacing"))); } else { - p.sendMessage(ChatColors.color(" &dRotation: &e" + ((Rotatable) b.getBlockData()).getRotation().toString())); + p.sendMessage(ChatColors.color(" &dRotation: &e" + BlockDataCompat.get(BlockDataCompat.getBlockData(b), "getRotation"))); } } @@ -168,8 +170,8 @@ private void sendInfo(Player p, Block b) { p.sendMessage(ChatColors.color(" &dChunk Timings: &e" + Slimefun.getProfiler().getTime(b.getChunk()))); } - if (item instanceof EnergyNetComponent component) { - p.sendMessage(ChatColors.color("&dEnergyNet Component")); + if (item instanceof EnergyNetComponent) { + EnergyNetComponent component = (EnergyNetComponent) item; p.sendMessage(ChatColors.color("&dEnergyNet Component")); p.sendMessage(ChatColors.color(" &dType: &e" + component.getEnergyComponentType())); if (component.isChargeable()) { @@ -184,3 +186,4 @@ private void sendInfo(Player p, Block b) { p.sendMessage(" "); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DispenserListener.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DispenserListener.java index 9989508348..0061cff1e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/DispenserListener.java @@ -1,5 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.BlockDataCompat; import javax.annotation.Nonnull; import org.bukkit.Material; @@ -7,14 +8,13 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; -import org.bukkit.block.data.Directional; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockDispenseEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockDispenseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -47,13 +47,26 @@ public void onBlockDispensing(BlockDispenseEvent e) { machine.callItemHandler(BlockDispenseHandler.class, handler -> { BlockState state = PaperLib.getBlockState(b, false).getState(); - if (state instanceof Dispenser dispenser) { - BlockFace face = ((Directional) b.getBlockData()).getFacing(); - Block block = b.getRelative(face); - handler.onBlockDispense(e, dispenser, block, machine); + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; + Object facing = BlockDataCompat.get(BlockDataCompat.getBlockData(b), "getFacing"); + + if (!(facing instanceof BlockFace)) { + // 1.8-1.12 have no BlockData; the facing lives on the legacy MaterialData. + org.bukkit.material.MaterialData data = state.getData(); + if (data instanceof org.bukkit.material.Directional) { + facing = ((org.bukkit.material.Directional) data).getFacing(); + } + } + + if (facing instanceof BlockFace) { + Block block = b.getRelative((BlockFace) facing); + handler.onBlockDispense(e, dispenser, block, machine); + } } }); } } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraImpactListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ElytraImpactListener.java similarity index 61% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraImpactListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ElytraImpactListener.java index 02fc80c56c..53cc116523 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraImpactListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ElytraImpactListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import java.util.HashSet; import java.util.Optional; @@ -15,14 +17,14 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.ElytraCap; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; import org.bukkit.event.entity.EntityToggleGlideEvent; /** @@ -44,8 +46,8 @@ public ElytraImpactListener(@Nonnull Slimefun plugin) { @EventHandler public void onGlideToggle(EntityToggleGlideEvent event) { Entity entity = event.getEntity(); - if (entity instanceof Player player && player.isGliding()) { - UUID uuid = player.getUniqueId(); + if (entity instanceof Player && EntityCompat.isGliding(entity)) { + Player player = (Player) entity; UUID uuid = player.getUniqueId(); gliding.add(uuid); } // We tick 1 tick later because the player is being toggled of at the same tick as it takes damage. @@ -54,17 +56,18 @@ public void onGlideToggle(EntityToggleGlideEvent event) { @EventHandler public void onPlayerCrash(EntityDamageEvent e) { - if (!(e.getEntity() instanceof Player p)) { + if (!(e.getEntity() instanceof Player)) { // We only wanna handle damaged Players return; } + Player p = (Player) e.getEntity(); - if ((e.getCause() == DamageCause.FALL || e.getCause() == DamageCause.FLY_INTO_WALL) - && (p.isGliding() || gliding.contains(p.getUniqueId())) + if ((e.getCause() == DamageCause.FALL || "FLY_INTO_WALL".equals(e.getCause().name())) + && (EntityCompat.isGliding(p) || gliding.contains(p.getUniqueId())) ) { Optional optional = PlayerProfile.find(p); - if (optional.isEmpty()) { + if (!optional.isPresent()) { PlayerProfile.request(p); return; } @@ -79,11 +82,12 @@ public void onPlayerCrash(EntityDamageEvent e) { SoundEffect.ELYTRA_CAP_IMPACT_SOUND.playFor(p); e.setCancelled(true); - if (item instanceof DamageableItem damageableItem) { - damageableItem.damageItem(p, p.getInventory().getHelmet()); + if (item instanceof DamageableItem) { + DamageableItem damageableItem = (DamageableItem) item; damageableItem.damageItem(p, p.getInventory().getHelmet()); } } } } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/EnhancedFurnaceListener.java similarity index 64% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/EnhancedFurnaceListener.java index c03e238c4a..5f6564d247 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/EnhancedFurnaceListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.Optional; @@ -15,10 +15,11 @@ import org.bukkit.inventory.FurnaceInventory; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.EnhancedFurnace; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.EnhancedFurnace; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -40,18 +41,20 @@ public EnhancedFurnaceListener(@Nonnull Slimefun plugin) { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFuelBurn(FurnaceBurnEvent e) { - if (e.getBlock().getType() != Material.FURNACE) { - // We don't care about Smokers, Blast Furnaces and all that fancy stuff + if (!MaterialCompat.isVanillaFurnace(e.getBlock().getType())) { + // We don't care about Smokers, Blast Furnaces and all that fancy stuff. + // (isVanillaFurnace also matches the legacy lit-furnace material on 1.8-1.12.) return; } SlimefunItem furnace = BlockStorage.check(e.getBlock()); // Fixes #2958 - if (furnace instanceof EnhancedFurnace enhancedFurnace - && !enhancedFurnace.isDisabledIn(e.getBlock().getWorld()) - && enhancedFurnace.getFuelEfficiency() > 0 + if (furnace instanceof EnhancedFurnace + && !((EnhancedFurnace) furnace).isDisabledIn(e.getBlock().getWorld()) + && ((EnhancedFurnace) furnace).getFuelEfficiency() > 0 ) { + EnhancedFurnace enhancedFurnace = (EnhancedFurnace) furnace; int burnTime = e.getBurnTime(); int newBurnTime = enhancedFurnace.getFuelEfficiency() * burnTime; @@ -61,18 +64,19 @@ public void onFuelBurn(FurnaceBurnEvent e) { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemSmelt(FurnaceSmeltEvent e) { - if (e.getBlock().getType() != Material.FURNACE) { - // We don't care about Smokers, Blast Furnaces and all that fancy stuff + if (!MaterialCompat.isVanillaFurnace(e.getBlock().getType())) { + // We don't care about Smokers, Blast Furnaces and all that fancy stuff. + // (isVanillaFurnace also matches the legacy lit-furnace material on 1.8-1.12.) return; } SlimefunItem sfItem = BlockStorage.check(e.getBlock()); - if (sfItem instanceof EnhancedFurnace enhancedFurnace && !enhancedFurnace.isDisabledIn(e.getBlock().getWorld())) { - BlockState state = PaperLib.getBlockState(e.getBlock(), false).getState(); + if (sfItem instanceof EnhancedFurnace && !((EnhancedFurnace) sfItem).isDisabledIn(e.getBlock().getWorld())) { + EnhancedFurnace enhancedFurnace = (EnhancedFurnace) sfItem; BlockState state = PaperLib.getBlockState(e.getBlock(), false).getState(); - if (state instanceof Furnace furnace) { - FurnaceInventory inventory = furnace.getInventory(); + if (state instanceof Furnace) { + Furnace furnace = (Furnace) state; FurnaceInventory inventory = furnace.getInventory(); // This if statement fixes #3741 if (inventory.getSmelting() == null) { @@ -94,3 +98,4 @@ public void onItemSmelt(FurnaceSmeltEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ExplosionsListener.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ExplosionsListener.java index 786fdd4973..c9e9c91b67 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ExplosionsListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.util.ArrayList; import java.util.Iterator; @@ -19,10 +21,10 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.WitherProof; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -100,10 +102,11 @@ private void handleExplosion(BlockBreakHandler handler, Block block) { handler.onExplode(block, drops); for (ItemStack drop : drops) { - if (drop != null && !drop.getType().isAir()) { + if (drop != null && !MaterialCompat.isAir(drop.getType())) { block.getWorld().dropItemNaturally(block.getLocation(), drop); } } } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GadgetsListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GadgetsListener.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GadgetsListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GadgetsListener.java index 2b38db7769..b7fb8ab70b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GadgetsListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GadgetsListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -8,18 +8,18 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerToggleSneakEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.Parachute; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfusedMagnet; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.InfusedMagnetTask; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.JetBootsTask; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.JetpackTask; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.player.ParachuteTask; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.Parachute; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.JetBoots; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.Jetpack; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.InfusedMagnet; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.InfusedMagnetTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.JetBootsTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.JetpackTask; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.player.ParachuteTask; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This {@link Listener} is responsible for listening to the {@link PlayerToggleSneakEvent} @@ -70,8 +70,8 @@ private void handleChestplate(@Nonnull Player p, @Nullable SlimefunItem chestpla return; } - if (chestplate instanceof Jetpack jetpack) { - double thrust = jetpack.getThrust(); + if (chestplate instanceof Jetpack) { + Jetpack jetpack = (Jetpack) chestplate; double thrust = jetpack.getThrust(); if (thrust > 0.2) { new JetpackTask(p, (Jetpack) chestplate).scheduleRepeating(0, 3); @@ -82,8 +82,8 @@ private void handleChestplate(@Nonnull Player p, @Nullable SlimefunItem chestpla } private void handleBoots(@Nonnull Player p, @Nullable SlimefunItem boots) { - if (boots instanceof JetBoots jetBoots && boots.canUse(p, true)) { - double speed = jetBoots.getSpeed(); + if (boots instanceof JetBoots && boots.canUse(p, true)) { + JetBoots jetBoots = (JetBoots) boots; double speed = jetBoots.getSpeed(); if (speed > 0.2) { new JetBootsTask(p, (JetBoots) boots).scheduleRepeating(0, 2); @@ -91,3 +91,4 @@ private void handleBoots(@Nonnull Player p, @Nullable SlimefunItem boots) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GrapplingHookEntity.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GrapplingHookEntity.java index 13aac08291..b0072f0374 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookEntity.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GrapplingHookEntity.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -10,7 +10,7 @@ import org.bukkit.entity.Item; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; final class GrapplingHookEntity { @@ -50,4 +50,4 @@ public void remove() { } } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GrapplingHookListener.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GrapplingHookListener.java index fe57d8197a..ed3ccfddfc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/GrapplingHookListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.HashMap; import java.util.HashSet; @@ -28,9 +30,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GrapplingHook; /** * This {@link Listener} is responsible for the mechanics behind the {@link GrapplingHook}. @@ -61,8 +63,8 @@ public void onArrowHitEntity(EntityDamageByEntityEvent e) { return; } - if (e.getDamager() instanceof Arrow arrow) { - handleGrapplingHook(arrow); + if (e.getDamager() instanceof Arrow) { + Arrow arrow = (Arrow) e.getDamager(); handleGrapplingHook(arrow); } } @@ -73,8 +75,8 @@ public void onArrowHitSurface(ProjectileHitEvent e) { } Slimefun.runSync(() -> { - if (e.getEntity() instanceof Arrow arrow) { - handleGrapplingHook(arrow); + if (e.getEntity() instanceof Arrow) { + Arrow arrow = (Arrow) e.getEntity(); handleGrapplingHook(arrow); } }, 2L); } @@ -86,8 +88,8 @@ public void onArrowHitHanging(HangingBreakByEntityEvent e) { } // This is called when the arrow shoots off a painting or an item frame - if (e.getRemover() instanceof Arrow arrow) { - handleGrapplingHook(arrow); + if (e.getRemover() instanceof Arrow) { + Arrow arrow = (Arrow) e.getRemover(); handleGrapplingHook(arrow); } } @@ -130,8 +132,8 @@ public void onPortalEnter(EntityPortalEnterEvent e) { return; } - if (e.getEntity() instanceof Arrow arrow) { - handleGrapplingHook(arrow); + if (e.getEntity() instanceof Arrow) { + Arrow arrow = (Arrow) e.getEntity(); handleGrapplingHook(arrow); } } @@ -144,7 +146,7 @@ public void onLeash(PlayerLeashEntityEvent e) { Player p = e.getPlayer(); - ItemStack item = p.getInventory().getItemInMainHand(); + ItemStack item = HandCompat.getMainHand(p.getInventory()); SlimefunItem slimeItem = SlimefunItem.getByItem(item); if (slimeItem instanceof GrapplingHook) { @@ -153,8 +155,8 @@ public void onLeash(PlayerLeashEntityEvent e) { } private void handleGrapplingHook(@Nullable Arrow arrow) { - if (arrow != null && arrow.isValid() && arrow.getShooter() instanceof Player player) { - GrapplingHookEntity hook = activeHooks.get(player.getUniqueId()); + if (arrow != null && arrow.isValid() && arrow.getShooter() instanceof Player) { + Player player = (Player) arrow.getShooter(); GrapplingHookEntity hook = activeHooks.get(player.getUniqueId()); if (hook != null) { Location target = arrow.getLocation(); @@ -219,3 +221,4 @@ public void addGrapplingHook(Player p, Arrow arrow, Bat bat, boolean dropItem, l }, despawnTicks); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/HopperListener.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/HopperListener.java index bf63a4990c..dde0562c64 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/HopperListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/HopperListener.java @@ -1,15 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import org.bukkit.Location; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotHopperable; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -31,10 +32,11 @@ public HopperListener(@Nonnull Slimefun plugin) { @EventHandler public void onHopperInsert(InventoryMoveItemEvent e) { - Location loc = e.getDestination().getLocation(); + Location loc = (Location) ReflectionCompat.invoke(e.getDestination(), "getLocation"); if (loc != null && e.getSource().getType() == InventoryType.HOPPER && BlockStorage.check(loc) instanceof NotHopperable) { e.setCancelled(true); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemDropListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ItemDropListener.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemDropListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ItemDropListener.java index 647102801a..288b51a1ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemDropListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ItemDropListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; @@ -6,10 +6,10 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerDropItemEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemDropHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.core.SlimefunRegistry; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemDropHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * Listens to the {@link PlayerDropItemEvent} to call any {@link ItemDropHandler}. @@ -35,3 +35,4 @@ public void onItemDrop(PlayerDropItemEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ItemPickupListener.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ItemPickupListener.java index 678c1f2c4b..6622d0f99b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/ItemPickupListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; @@ -8,9 +8,9 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * Listens to the ItemPickup events to prevent it if the item has the "no_pickup" metadata or is an ALTAR_PROBE. @@ -51,3 +51,4 @@ public void onHopperPickup(InventoryPickupItemEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/JoinListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/JoinListener.java similarity index 64% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/JoinListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/JoinListener.java index 28d15851bd..b80298761a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/JoinListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/JoinListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; @@ -8,12 +8,12 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask; +import io.github.thebusybiscuit.slimefun5.api.items.HashedArmorpiece; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.RadiationTask; /** * This {@link Listener} caches the armor of the player on join. @@ -34,11 +34,12 @@ public void onJoin(@Nonnull PlayerJoinEvent e) { final HashedArmorpiece[] hashedArmorpieces = playerProfile.getArmor(); for (int i = 0; i < 4; i++) { final ItemStack armorPiece = armorContents[i]; - if (armorPiece != null && armorPiece.getType() != Material.AIR && SlimefunItem.getByItem(armorPiece) instanceof SlimefunArmorPiece sfArmorPiece) { - hashedArmorpieces[i].update(armorPiece, sfArmorPiece); + if (armorPiece != null && armorPiece.getType() != Material.AIR && SlimefunItem.getByItem(armorPiece) instanceof SlimefunArmorPiece) { + SlimefunArmorPiece sfArmorPiece = (SlimefunArmorPiece) SlimefunItem.getByItem(armorPiece); hashedArmorpieces[i].update(armorPiece, sfArmorPiece); } } }); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MiddleClickListener.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MiddleClickListener.java index b35d48292b..f4c2952b45 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiddleClickListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MiddleClickListener.java @@ -1,10 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import org.bukkit.entity.HumanEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -12,8 +14,8 @@ import org.bukkit.event.inventory.InventoryCreativeEvent; import org.bukkit.event.inventory.InventoryType.SlotType; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -44,7 +46,7 @@ public void onInventoryCreativeEvent(InventoryCreativeEvent e) { if (e.getClick() == ClickType.CREATIVE && e.getSlotType() == SlotType.QUICKBAR) { HumanEntity player = e.getWhoClicked(); // get the block the player is looking at for later - Block b = player.getTargetBlockExact(5); + Block b = (Block) ReflectionCompat.invoke(player, "getTargetBlockExact", 5); // Fixes: #3483 if (b == null || !isActualMiddleClick(e, b)) { @@ -96,8 +98,9 @@ private boolean isActualMiddleClick(InventoryCreativeEvent e, Block b) { * and then the boolean above wont match because WALL_HEAD != PLAYER_HEAD. * This check makes up for that lack. */ - boolean isPlayerWallhead = b.getType() == Material.PLAYER_WALL_HEAD && e.getCursor().getType() == Material.PLAYER_HEAD; + boolean isPlayerWallhead = b.getType() == XMaterial.PLAYER_WALL_HEAD.parseMaterial() && e.getCursor().getType() == XMaterial.PLAYER_HEAD.parseMaterial(); return isOutsideInventoryClick || isPlayerWallhead; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiningAndroidListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MiningAndroidListener.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiningAndroidListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MiningAndroidListener.java index e83370f5a6..f126d6572e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MiningAndroidListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MiningAndroidListener.java @@ -1,14 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.events.AndroidMineEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockBreakHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -44,3 +44,4 @@ public void onAndroidMine(AndroidMineEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MultiBlockListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MultiBlockListener.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MultiBlockListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MultiBlockListener.java index 7e11ac124a..8395ba7979 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MultiBlockListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MultiBlockListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.LinkedList; @@ -8,7 +10,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.Tag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -18,10 +20,10 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.EquipmentSlot; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent; -import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockInteractEvent; +import io.github.thebusybiscuit.slimefun5.core.handlers.MultiBlockInteractionHandler; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlock; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} is responsible for listening to a {@link PlayerInteractEvent} and @@ -42,7 +44,7 @@ public MultiBlockListener(@Nonnull Slimefun plugin) { @EventHandler public void onRightClick(PlayerInteractEvent e) { - if (e.getAction() != Action.RIGHT_CLICK_BLOCK || e.getHand() != EquipmentSlot.HAND) { + if (e.getAction() != Action.RIGHT_CLICK_BLOCK || HandCompat.getHand(e) != EquipmentSlot.HAND) { return; } @@ -108,3 +110,4 @@ private boolean equals(Material a, Material b) { return false; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/NetworkListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/NetworkListener.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/NetworkListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/NetworkListener.java index 3d68b22d19..c775bee61b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/NetworkListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/NetworkListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; @@ -9,10 +9,10 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.events.ExplosiveToolBreakBlocksEvent; +import io.github.thebusybiscuit.slimefun5.api.network.Network; +import io.github.thebusybiscuit.slimefun5.core.networks.NetworkManager; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} is responsible for all updates to a {@link Network}. @@ -54,3 +54,4 @@ public void onExplosiveToolUse(ExplosiveToolBreakBlocksEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PlayerProfileListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/PlayerProfileListener.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PlayerProfileListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/PlayerProfileListener.java index f303a1a592..0f88e07270 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PlayerProfileListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/PlayerProfileListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.Optional; @@ -11,8 +11,8 @@ import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerQuitEvent; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} removes a {@link PlayerProfile} from memory if the corresponding {@link Player} @@ -45,3 +45,4 @@ public void onKick(PlayerKickEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/RadioactivityListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/RadioactivityListener.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/RadioactivityListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/RadioactivityListener.java index 319185bd36..799ccaa73c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/RadioactivityListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/RadioactivityListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; @@ -6,9 +6,9 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask; -import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.armor.RadiationTask; +import io.github.thebusybiscuit.slimefun5.utils.RadiationUtils; /** * {@link RadioactivityListener} handles radioactivity level resets @@ -28,3 +28,4 @@ public void onPlayerDeath(@Nonnull PlayerDeathEvent e) { RadiationTask.addGracePeriod(e.getEntity()); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SeismicAxeListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SeismicAxeListener.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SeismicAxeListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SeismicAxeListener.java index ee5c106e7a..660895160e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SeismicAxeListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SeismicAxeListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; @@ -8,8 +8,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.SeismicAxe; /** * This {@link Listener} is responsible for removing every {@link FallingBlock} that was @@ -42,3 +42,4 @@ public void onBlockFall(EntityChangeBlockEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunBootsListener.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunBootsListener.java index 10f981cd77..ab88fdb161 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunBootsListener.java @@ -1,9 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import org.bukkit.Material; -import org.bukkit.SoundCategory; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.block.Block; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Player; @@ -16,13 +17,13 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.EnderBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.FarmerShoes; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.LongFallBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.StomperBoots; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.EnderBoots; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.FarmerShoes; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.LongFallBoots; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.StomperBoots; /** * This {@link Listener} is responsible for handling all boots provided by @@ -48,8 +49,8 @@ public void onDamage(EntityDamageEvent e) { @EventHandler public void onEnderPearlDamage(EntityDamageByEntityEvent e) { - if (e.getDamager() instanceof EnderPearl && e.getEntity() instanceof Player p) { - SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots()); + if (e.getDamager() instanceof EnderPearl && e.getEntity() instanceof Player) { + Player p = (Player) e.getEntity(); SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots()); if (boots instanceof EnderBoots && boots.canUse(p, true)) { e.setCancelled(true); @@ -58,8 +59,8 @@ public void onEnderPearlDamage(EntityDamageByEntityEvent e) { } private void onFallDamage(@Nonnull EntityDamageEvent e) { - if (e.getEntity() instanceof Player p) { - SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots()); + if (e.getEntity() instanceof Player) { + Player p = (Player) e.getEntity(); SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots()); if (boots != null) { // Check if the boots were researched @@ -67,11 +68,11 @@ private void onFallDamage(@Nonnull EntityDamageEvent e) { return; } - if (boots instanceof StomperBoots stomperBoots) { - e.setCancelled(true); + if (boots instanceof StomperBoots) { + StomperBoots stomperBoots = (StomperBoots) boots; e.setCancelled(true); stomperBoots.stomp(e); - } else if (boots instanceof LongFallBoots longFallBoots) { - e.setCancelled(true); + } else if (boots instanceof LongFallBoots) { + LongFallBoots longFallBoots = (LongFallBoots) boots; e.setCancelled(true); longFallBoots.getSoundEffect().playAt(p.getLocation(), SoundCategory.PLAYERS); } } @@ -83,7 +84,7 @@ public void onTrample(PlayerInteractEvent e) { if (e.getAction() == Action.PHYSICAL) { Block b = e.getClickedBlock(); - if (b != null && b.getType() == Material.FARMLAND) { + if (b != null && b.getType() == XMaterial.FARMLAND.parseMaterial()) { Player p = e.getPlayer(); SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots()); @@ -94,3 +95,4 @@ public void onTrample(PlayerInteractEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunBowListener.java similarity index 83% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunBowListener.java index 286bd2c2e0..b40fcd8ca0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunBowListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.HashMap; import java.util.Map; @@ -17,10 +17,10 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SlimefunBow; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BowShootHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.SlimefunBow; /** * This {@link Listener} is responsible for tracking {@link Arrow Arrows} fired from a @@ -55,8 +55,8 @@ public void onBowUse(EntityShootBowEvent e) { if (e.getEntity() instanceof Player && e.getProjectile() instanceof Arrow) { SlimefunItem bow = SlimefunItem.getByItem(e.getBow()); - if (bow instanceof SlimefunBow slimefunBow) { - projectiles.put(e.getProjectile().getUniqueId(), slimefunBow); + if (bow instanceof SlimefunBow) { + SlimefunBow slimefunBow = (SlimefunBow) bow; projectiles.put(e.getProjectile().getUniqueId(), slimefunBow); } } } @@ -82,3 +82,4 @@ public void onArrowSuccessfulHit(EntityDamageByEntityEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunGuideListener.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunGuideListener.java index 53897013a2..6d99e25296 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunGuideListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -12,13 +12,13 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.events.SlimefunGuideOpenEvent; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.events.SlimefunGuideOpenEvent; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.core.guide.options.SlimefunGuideSettings; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; public class SlimefunGuideListener implements Listener { @@ -95,3 +95,4 @@ private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideMode } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemConsumeListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemConsumeListener.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemConsumeListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemConsumeListener.java index 2a62ead3fe..ffcdb8322b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemConsumeListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemConsumeListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; @@ -8,9 +8,9 @@ import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} is responsible for handling the {@link ItemConsumptionHandler} @@ -40,3 +40,4 @@ public void onConsume(PlayerItemConsumeEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemHitListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemHitListener.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemHitListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemHitListener.java index 621040f9ea..960d471d0f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemHitListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemHitListener.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import javax.annotation.Nonnull; @@ -9,9 +13,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.WeaponUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.WeaponUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} is responsible for calling the {@link WeaponUseHandler}. @@ -34,9 +38,9 @@ public void onDamage(EntityDamageByEntityEvent e) { } Player p = (Player) e.getDamager(); - ItemStack item = p.getInventory().getItemInMainHand(); + ItemStack item = HandCompat.getMainHand(p.getInventory()); - if (!item.getType().isAir()) { + if (!MaterialCompat.isAir(item.getType())) { SlimefunItem sfItem = SlimefunItem.getByItem(item); if (sfItem != null && sfItem.canUse(p, true)) { @@ -46,3 +50,4 @@ public void onDamage(EntityDamageByEntityEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemInteractListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemInteractListener.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemInteractListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemInteractListener.java index ce3f951743..0cd95b1607 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemInteractListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SlimefunItemInteractListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.Optional; @@ -17,13 +19,13 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BlockUseHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -68,7 +70,7 @@ public void onRightClick(PlayerInteractEvent e) { PlayerRightClickEvent event = new PlayerRightClickEvent(e); Bukkit.getPluginManager().callEvent(event); - boolean itemUsed = e.getHand() == EquipmentSlot.OFF_HAND; + boolean itemUsed = HandCompat.getHand(e) == HandCompat.OFF_HAND; // Only handle the Item if it hasn't been denied if (event.useItem() != Result.DENY) { @@ -170,3 +172,4 @@ private void openInventory(Player p, SlimefunItem item, Block clickedBlock, Play } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SoulboundListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SoulboundListener.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SoulboundListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SoulboundListener.java index b57a4802a7..8b7ae382f7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SoulboundListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/SoulboundListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.HashMap; import java.util.Map; @@ -13,9 +13,9 @@ import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.core.attributes.Soulbound; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This {@link Listener} is responsible for handling any {@link Soulbound} items. @@ -75,3 +75,4 @@ private void returnSoulboundItems(@Nonnull Player p) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TalismanListener.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TalismanListener.java index 893fb0ab75..5bb03e17e2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TalismanListener.java @@ -1,4 +1,8 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.InventoryCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.ArrayList; import java.util.Collection; @@ -10,7 +14,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -44,13 +48,13 @@ import org.bukkit.util.Vector; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; -import io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.MagicianTalisman; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.Talisman; +import io.github.thebusybiscuit.slimefun5.implementation.settings.TalismanEnchantment; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEnchantment; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * This {@link Listener} is responsible for handling any {@link Event} @@ -101,8 +105,8 @@ public void onDamageGet(EntityDamageEvent e) { Talisman.trigger(e, SlimefunItems.TALISMAN_WARRIOR); break; case PROJECTILE: - if (e instanceof EntityDamageByEntityEvent entityDamageByEntityEvent) { - onProjectileDamage(entityDamageByEntityEvent); + if (e instanceof EntityDamageByEntityEvent) { + EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) e; onProjectileDamage(entityDamageByEntityEvent); } break; default: @@ -113,8 +117,8 @@ public void onDamageGet(EntityDamageEvent e) { private void onProjectileDamage(@Nonnull EntityDamageByEntityEvent e) { // "Fixes" #1022 - We just ignore Tridents now. - if (e.getDamager() instanceof Projectile projectile && !(e.getDamager() instanceof Trident)) { - if (Talisman.trigger(e, SlimefunItems.TALISMAN_WHIRLWIND)) { + if (e.getDamager() instanceof Projectile && !(e.getDamager() instanceof Trident)) { + Projectile projectile = (Projectile) e.getDamager(); if (Talisman.trigger(e, SlimefunItems.TALISMAN_WHIRLWIND)) { Player p = (Player) e.getEntity(); returnProjectile(p, projectile); } @@ -138,8 +142,8 @@ private void returnProjectile(@Nonnull Player p, @Nonnull Projectile projectile) returnedProjectile.setShooter(projectile.getShooter()); returnedProjectile.setVelocity(direction); - if (projectile instanceof AbstractArrow firedArrow) { - AbstractArrow returnedArrow = (AbstractArrow) returnedProjectile; + if (projectile instanceof AbstractArrow) { + AbstractArrow firedArrow = (AbstractArrow) projectile; AbstractArrow returnedArrow = (AbstractArrow) returnedProjectile; returnedArrow.setDamage(firedArrow.getDamage()); returnedArrow.setPickupStatus(firedArrow.getPickupStatus()); @@ -187,12 +191,12 @@ private Collection getExtraDrops(LivingEntity entity, Collection items = new ArrayList<>(drops); // Prevent duplication of items stored inside a Horse's chest - if (entity instanceof ChestedHorse chestedHorse) { - if (chestedHorse.isCarryingChest()) { + if (entity instanceof ChestedHorse) { + ChestedHorse chestedHorse = (ChestedHorse) entity; if (chestedHorse.isCarryingChest()) { // The chest is not included in getStorageContents() items.remove(new ItemStack(Material.CHEST)); - for (ItemStack item : chestedHorse.getInventory().getStorageContents()) { + for (ItemStack item : InventoryCompat.getStorageContents(chestedHorse.getInventory())) { items.remove(item); } } @@ -220,8 +224,8 @@ private Collection getExtraDrops(LivingEntity entity, Collection 0) { @@ -401,3 +405,4 @@ private int getAmountWithFortune(@Nonnull Material type, int fortuneLevel) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TeleporterListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TeleporterListener.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TeleporterListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TeleporterListener.java index 7260828b1d..11ac3b8cfe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TeleporterListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TeleporterListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.UUID; @@ -13,13 +13,13 @@ import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.AbstractTeleporterPlate; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.TeleporterPylon; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.elevator.ElevatorPlate; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.AbstractTeleporterPlate; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.Teleporter; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.TeleporterPylon; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -64,8 +64,8 @@ public void onPressurePlateEnter(PlayerInteractEvent e) { // Pressure plate was an elevator ElevatorPlate elevator = SlimefunItems.ELEVATOR_PLATE.getItem(ElevatorPlate.class); elevator.openInterface(p, b); - } else if (item instanceof AbstractTeleporterPlate teleporterPlate && teleporterPlate.hasAccess(p, b)) { - // Pressure plate was a teleporter + } else if (item instanceof AbstractTeleporterPlate && ((AbstractTeleporterPlate) item).hasAccess(p, b)) { + AbstractTeleporterPlate teleporterPlate = (AbstractTeleporterPlate) item; // Pressure plate was a teleporter SlimefunItem teleporter = BlockStorage.check(b.getRelative(BlockFace.DOWN)); if (teleporter instanceof Teleporter && checkForPylons(b.getRelative(BlockFace.DOWN))) { @@ -95,4 +95,4 @@ private boolean checkForPylons(@Nonnull Block teleporter) { return true; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/VillagerTradingListener.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/VillagerTradingListener.java index eaeefa06c9..3a6b2cd85b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/VillagerTradingListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -12,10 +12,10 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.SyntheticEmerald; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.SyntheticEmerald; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used to trade with @@ -57,3 +57,4 @@ private boolean isUnallowed(@Nullable SlimefunItem item) { return item != null && !(item instanceof VanillaItem) && !(item instanceof SyntheticEmerald) && !item.isDisabled(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WorldListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/WorldListener.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WorldListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/WorldListener.java index 0bdedf9991..3c9b37aa45 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WorldListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/WorldListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.logging.Level; @@ -9,7 +9,7 @@ import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldUnloadEvent; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -37,3 +37,4 @@ public void onWorldUnload(WorldUnloadEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/AnvilListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/AnvilListener.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/AnvilListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/AnvilListener.java index 16e28fdbee..4afc742e4e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/AnvilListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/AnvilListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; import javax.annotation.Nonnull; @@ -10,8 +10,8 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used in an @@ -28,8 +28,8 @@ public AnvilListener(@Nonnull Slimefun plugin) { @EventHandler(ignoreCancelled = true) public void onAnvil(InventoryClickEvent e) { - if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.ANVIL && e.getWhoClicked() instanceof Player player) { - ItemStack item1 = e.getInventory().getContents()[0]; + if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.ANVIL && e.getWhoClicked() instanceof Player) { + Player player = (Player) e.getWhoClicked(); ItemStack item1 = e.getInventory().getContents()[0]; ItemStack item2 = e.getInventory().getContents()[1]; if (hasUnallowedItems(item1, item2)) { @@ -40,3 +40,4 @@ public void onAnvil(InventoryClickEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/BrewingStandListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/BrewingStandListener.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/BrewingStandListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/BrewingStandListener.java index 47ab4f1eb4..d2464aa13b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/BrewingStandListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/BrewingStandListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; import javax.annotation.Nonnull; @@ -13,8 +13,8 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used in a @@ -61,3 +61,4 @@ public void hopperOnBrew(InventoryMoveItemEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CartographyTableListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CartographyTableListener.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CartographyTableListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CartographyTableListener.java index 1eed58c935..bc4a3509c0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CartographyTableListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CartographyTableListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; import javax.annotation.Nonnull; @@ -10,8 +10,8 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used in a @@ -28,8 +28,8 @@ public CartographyTableListener(@Nonnull Slimefun plugin) { @EventHandler(ignoreCancelled = true) public void onCartographyTable(InventoryClickEvent e) { - if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player player) { - ItemStack item1 = e.getInventory().getContents()[0]; + if (e.getRawSlot() == 2 && "CARTOGRAPHY".equals(e.getInventory().getType().name()) && e.getWhoClicked() instanceof Player) { + Player player = (Player) e.getWhoClicked(); ItemStack item1 = e.getInventory().getContents()[0]; ItemStack item2 = e.getInventory().getContents()[1]; if (hasUnallowedItems(item1, item2)) { @@ -40,3 +40,4 @@ public void onCartographyTable(InventoryClickEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CauldronListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CauldronListener.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CauldronListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CauldronListener.java index 9dc642a67e..1c16484143 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CauldronListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CauldronListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; import javax.annotation.Nonnull; @@ -11,9 +11,9 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used in a @@ -50,3 +50,4 @@ public void onCauldronUse(PlayerInteractEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CraftingTableListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CraftingTableListener.java similarity index 89% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CraftingTableListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CraftingTableListener.java index 928a3f58bc..61e99b9d55 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CraftingTableListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/CraftingTableListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; import javax.annotation.Nonnull; @@ -10,8 +10,8 @@ import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used in a @@ -54,3 +54,4 @@ public void onPrepareCraft(PrepareItemCraftEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/GrindstoneListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/GrindstoneListener.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/GrindstoneListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/GrindstoneListener.java index f8d3e18653..df18bd9c9b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/GrindstoneListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/GrindstoneListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; import javax.annotation.Nonnull; @@ -10,8 +10,8 @@ import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used in a @@ -28,7 +28,7 @@ public GrindstoneListener(@Nonnull Slimefun plugin) { @EventHandler(ignoreCancelled = true) public void onGrindstone(InventoryClickEvent e) { - if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.GRINDSTONE) { + if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && "GRINDSTONE".equals(e.getInventory().getType().name())) { ItemStack item1 = e.getInventory().getContents()[0]; ItemStack item2 = e.getInventory().getContents()[1]; @@ -40,3 +40,4 @@ public void onGrindstone(InventoryClickEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SlimefunCraftingListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/SlimefunCraftingListener.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SlimefunCraftingListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/SlimefunCraftingListener.java index ae51e614b5..d4819dae8a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SlimefunCraftingListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/SlimefunCraftingListener.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; import javax.annotation.Nullable; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; interface SlimefunCraftingListener extends Listener { @@ -35,3 +35,4 @@ default boolean isUnallowed(@Nullable SlimefunItem item) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/SmithingTableListener.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/SmithingTableListener.java index dd1567f778..c3c02bc03c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SmithingTableListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/SmithingTableListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; import javax.annotation.Nonnull; @@ -8,9 +8,10 @@ import org.bukkit.event.inventory.PrepareSmithingEvent; import org.bukkit.event.inventory.SmithItemEvent; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} prevents any {@link SlimefunItem} from being used in a @@ -36,7 +37,7 @@ public void onSmith(SmithItemEvent e) { @EventHandler(ignoreCancelled = true) public void onPrepareSmith(PrepareSmithingEvent e) { - if (e.getInventory().getResult() != null) { + if (ReflectionCompat.invoke(e.getInventory(), "getResult") != null) { SlimefunItem sfItem = SlimefunItem.getByItem(e.getInventory().getContents()[materialSlot()]); if (sfItem != null && !sfItem.isUseableInWorkbench()) { e.setResult(null); @@ -52,3 +53,4 @@ private int materialSlot() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/package-info.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/package-info.java index 0d777f3773..d4b365f0f4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/crafting/package-info.java @@ -1,5 +1,5 @@ /** * This package holds every {@link org.bukkit.event.Listener} which is responsible for preventing that a - * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} is used in an unallowed crafting operation + * {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} is used in an unallowed crafting operation */ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/BeeListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/BeeListener.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/BeeListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/BeeListener.java index 89c762c496..858807c17c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/BeeListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/BeeListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.entity; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.entity; import java.util.Optional; @@ -12,9 +12,9 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * The {@link Listener} for Hazmat Suit's {@link Bee} sting protection. @@ -55,3 +55,4 @@ public void onDamage(EntityDamageByEntityEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/EntityInteractionListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/EntityInteractionListener.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/EntityInteractionListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/EntityInteractionListener.java index db90d17b8c..8586df7db0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/EntityInteractionListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/EntityInteractionListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.entity; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.entity; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import javax.annotation.Nonnull; @@ -10,10 +12,10 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemState; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemState; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityInteractHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * The {@link Listener} responsible for a {@link Player} interacting with an {@link Entity}. @@ -38,17 +40,17 @@ public void onInteractEntity(PlayerInteractEntityEvent e) { ItemStack itemStack; - if (e.getHand() == EquipmentSlot.OFF_HAND) { - itemStack = e.getPlayer().getInventory().getItemInOffHand(); + if (HandCompat.getHand(e) == HandCompat.OFF_HAND) { + itemStack = HandCompat.getOffHand(e.getPlayer().getInventory()); } else { - itemStack = e.getPlayer().getInventory().getItemInMainHand(); + itemStack = HandCompat.getMainHand(e.getPlayer().getInventory()); } SlimefunItem sfItem = SlimefunItem.getByItem(itemStack); if (sfItem != null) { if (sfItem.canUse(e.getPlayer(), true)) { - sfItem.callItemHandler(EntityInteractHandler.class, handler -> handler.onInteract(e, itemStack, e.getHand() == EquipmentSlot.OFF_HAND)); + sfItem.callItemHandler(EntityInteractHandler.class, handler -> handler.onInteract(e, itemStack, HandCompat.getHand(e) == HandCompat.OFF_HAND)); } else if (sfItem.getState() != ItemState.VANILLA_FALLBACK) { /* * If an Item is disabled, we don't want it to fallback to the vanilla behaviour @@ -59,4 +61,4 @@ public void onInteractEntity(PlayerInteractEntityEvent e) { } } } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/FireworksListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/FireworksListener.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/FireworksListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/FireworksListener.java index 66f7291b02..2018147d8d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/FireworksListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/FireworksListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.entity; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.entity; import javax.annotation.Nonnull; @@ -10,8 +10,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.meta.FireworkMeta; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} makes sure that any {@link Firework} caused by a {@link Player} @@ -28,8 +28,8 @@ public FireworksListener(@Nonnull Slimefun plugin) { @EventHandler public void onResearchFireworkDamage(EntityDamageByEntityEvent e) { - if (e.getDamager() instanceof Firework firework) { - FireworkMeta meta = firework.getFireworkMeta(); + if (e.getDamager() instanceof Firework) { + Firework firework = (Firework) e.getDamager(); FireworkMeta meta = firework.getFireworkMeta(); /* We could use Peristent Data for this in the future, but ItemMeta display names @@ -44,3 +44,4 @@ public void onResearchFireworkDamage(EntityDamageByEntityEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/IronGolemListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/IronGolemListener.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/IronGolemListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/IronGolemListener.java index 1357362746..d69d44979f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/IronGolemListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/IronGolemListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.entity; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.entity; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import javax.annotation.Nonnull; @@ -12,9 +14,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; /** * This {@link Listener} makes sure that an {@link IronGolem} cannot be healed with @@ -35,10 +37,10 @@ public void onIronGolemHeal(PlayerInteractEntityEvent e) { PlayerInventory inv = e.getPlayer().getInventory(); ItemStack item = null; - if (e.getHand() == EquipmentSlot.HAND) { - item = inv.getItemInMainHand(); - } else if (e.getHand() == EquipmentSlot.OFF_HAND) { - item = inv.getItemInOffHand(); + if (HandCompat.getHand(e) == EquipmentSlot.HAND) { + item = HandCompat.getMainHand(inv); + } else if (HandCompat.getHand(e) == HandCompat.OFF_HAND) { + item = HandCompat.getOffHand(inv); } // Check if the Golem was clicked using an Iron Ingot @@ -53,10 +55,10 @@ public void onIronGolemHeal(PlayerInteractEntityEvent e) { * This is just there to update the Inventory... * Somehow cancelling it isn't enough. */ - if (e.getHand() == EquipmentSlot.HAND) { - inv.setItemInMainHand(item); - } else if (e.getHand() == EquipmentSlot.OFF_HAND) { - inv.setItemInOffHand(item); + if (HandCompat.getHand(e) == EquipmentSlot.HAND) { + HandCompat.setMainHand(inv, item); + } else if (HandCompat.getHand(e) == HandCompat.OFF_HAND) { + HandCompat.setOffHand(inv, item); } } } @@ -64,3 +66,4 @@ public void onIronGolemHeal(PlayerInteractEntityEvent e) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/MobDropListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/MobDropListener.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/MobDropListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/MobDropListener.java index 7d69ffc900..4e6949504c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/MobDropListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/MobDropListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.entity; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.entity; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; @@ -12,12 +14,12 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RandomMobDrop; +import io.github.thebusybiscuit.slimefun5.core.handlers.EntityKillHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.BasicCircuitBoard; /** * This {@link Listener} is responsible for handling any custom mob drops. @@ -39,7 +41,7 @@ public MobDropListener(@Nonnull Slimefun plugin) { public void onEntityKill(EntityDeathEvent e) { if (e.getEntity().getKiller() != null) { Player p = e.getEntity().getKiller(); - ItemStack item = p.getInventory().getItemInMainHand(); + ItemStack item = HandCompat.getMainHand(p.getInventory()); Set customDrops = Slimefun.getRegistry().getMobDrops().get(e.getEntityType()); @@ -67,16 +69,16 @@ private boolean canDrop(@Nonnull Player p, @Nonnull ItemStack item) { if (sfItem == null) { return true; } else if (sfItem.canUse(p, true)) { - if (sfItem instanceof RandomMobDrop randomMobDrop) { - int random = ThreadLocalRandom.current().nextInt(100); + if (sfItem instanceof RandomMobDrop) { + RandomMobDrop randomMobDrop = (RandomMobDrop) sfItem; int random = ThreadLocalRandom.current().nextInt(100); if (randomMobDrop.getMobDropChance() <= random) { return false; } } - if (sfItem instanceof BasicCircuitBoard basicCircuitBoard) { - return basicCircuitBoard.isDroppedFromGolems(); + if (sfItem instanceof BasicCircuitBoard) { + BasicCircuitBoard basicCircuitBoard = (BasicCircuitBoard) sfItem; return basicCircuitBoard.isDroppedFromGolems(); } return true; @@ -85,3 +87,4 @@ private boolean canDrop(@Nonnull Player p, @Nonnull ItemStack item) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/PiglinListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/PiglinListener.java similarity index 77% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/PiglinListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/PiglinListener.java index bb153b299e..1066df79a3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/PiglinListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/PiglinListener.java @@ -1,4 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.entity; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.entity; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.HandCompat; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; @@ -17,9 +20,9 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.PiglinBarterDrop; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This {@link Listener} prevents a {@link Piglin} from bartering with a @@ -39,7 +42,7 @@ public PiglinListener(@Nonnull Slimefun plugin) { @EventHandler public void onPickup(EntityPickupItemEvent e) { - if (e.getEntityType() == EntityType.PIGLIN) { + if (e.getEntityType() == EntityCompat.entityType("PIGLIN")) { ItemStack item = e.getItem().getItemStack(); // Don't let Piglins pick up gold from Slimefun @@ -51,17 +54,17 @@ public void onPickup(EntityPickupItemEvent e) { @EventHandler public void onInteract(PlayerInteractEntityEvent e) { - if (!e.getRightClicked().isValid() || e.getRightClicked().getType() != EntityType.PIGLIN) { + if (!e.getRightClicked().isValid() || e.getRightClicked().getType() != EntityCompat.entityType("PIGLIN")) { return; } Player p = e.getPlayer(); ItemStack item; - if (e.getHand() == EquipmentSlot.OFF_HAND) { - item = p.getInventory().getItemInOffHand(); + if (HandCompat.getHand(e) == HandCompat.OFF_HAND) { + item = HandCompat.getOffHand(p.getInventory()); } else { - item = p.getInventory().getItemInMainHand(); + item = HandCompat.getMainHand(p.getInventory()); } // We only care about Gold since it's the actual "Bartering" we wanna prevent @@ -90,8 +93,8 @@ public void onPiglinDropItem(EntityDropItemEvent e) { SlimefunItem sfi = SlimefunItem.getByItem(is); // Check the getBarteringLootChance and compare against a random number 0-100, // if the random number is greater then replace the item. - if (sfi instanceof PiglinBarterDrop piglinBarterDrop) { - int chance = piglinBarterDrop.getBarteringLootChance(); + if (sfi instanceof PiglinBarterDrop) { + PiglinBarterDrop piglinBarterDrop = (PiglinBarterDrop) sfi; int chance = piglinBarterDrop.getBarteringLootChance(); if (chance < 1 || chance >= 100) { sfi.warn("The Piglin Bartering chance must be between 1-99% on item: " + sfi.getId()); @@ -104,3 +107,4 @@ public void onPiglinDropItem(EntityDropItemEvent e) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/WitherListener.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/WitherListener.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/WitherListener.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/WitherListener.java index 4d6b314521..8209e92d22 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/WitherListener.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/WitherListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.entity; +package io.github.thebusybiscuit.slimefun5.implementation.listeners.entity; import javax.annotation.Nonnull; @@ -8,10 +8,10 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.WitherProof; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -36,11 +36,12 @@ public void onWitherDestroy(EntityChangeBlockEvent e) { SlimefunItem item = BlockStorage.check(e.getBlock()); // Hardened Glass is excluded from here - if (item instanceof WitherProof witherProofBlock && !item.getId().equals(SlimefunItems.HARDENED_GLASS.getItemId())) { - e.setCancelled(true); + if (item instanceof WitherProof && !item.getId().equals(SlimefunItems.HARDENED_GLASS.getItemId())) { + WitherProof witherProofBlock = (WitherProof) item; e.setCancelled(true); witherProofBlock.onAttack(e.getBlock(), (Wither) e.getEntity()); } } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/package-info.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/package-info.java index 8ace561cee..a3548c97eb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/entity/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/entity/package-info.java @@ -2,4 +2,4 @@ * This package contains any {@link org.bukkit.event.Listener} from Slimefun which is related to an * {@link org.bukkit.entity.Entity}. */ -package io.github.thebusybiscuit.slimefun4.implementation.listeners.entity; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.listeners.entity; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/package-info.java similarity index 61% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/package-info.java index bb235157a0..7862072ace 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/package-info.java @@ -1,4 +1,4 @@ /** * This package contains all implementations of {@link org.bukkit.event.Listener} that Slimefun uses. */ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.listeners; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/CraftingOperation.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/CraftingOperation.java index 410664e314..f661849041 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/CraftingOperation.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/CraftingOperation.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation.operations; +package io.github.thebusybiscuit.slimefun5.implementation.operations; import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineOperation; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; @@ -62,3 +62,4 @@ public int getTotalTicks() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/FuelOperation.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/FuelOperation.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/FuelOperation.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/FuelOperation.java index a86fd1991e..a4e7c226da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/FuelOperation.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/FuelOperation.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.operations; +package io.github.thebusybiscuit.slimefun5.implementation.operations; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -6,7 +6,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineOperation; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; @@ -64,3 +64,4 @@ public int getTotalTicks() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/GEOMiningOperation.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/GEOMiningOperation.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/GEOMiningOperation.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/GEOMiningOperation.java index 372f9f502c..61b596917c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/GEOMiningOperation.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/GEOMiningOperation.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.operations; +package io.github.thebusybiscuit.slimefun5.implementation.operations; import java.util.OptionalInt; import javax.annotation.Nonnull; import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.geo.ResourceManager; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineOperation; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOMiner; /** * This {@link MachineOperation} represents a {@link GEOMiner} @@ -40,3 +40,4 @@ public void onCancel(@Nonnull BlockPosition position) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/MiningOperation.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/MiningOperation.java index e7f94c98bf..4d10c58b02 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/MiningOperation.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/MiningOperation.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation.operations; +package io.github.thebusybiscuit.slimefun5.implementation.operations; import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; +import io.github.thebusybiscuit.slimefun5.core.machines.MachineOperation; /** * This {@link MachineOperation} represents an operation @@ -56,3 +56,4 @@ public int getTotalTicks() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/package-info.java new file mode 100644 index 0000000000..773eea782e --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/operations/package-info.java @@ -0,0 +1,4 @@ +/** + * This package contains implementations of {@link io.github.thebusybiscuit.slimefun5.core.machines.MachineOperation}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.operations; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/package-info.java similarity index 65% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/package-info.java index 24b8a2ca26..07fc1426bf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/package-info.java @@ -1,6 +1,6 @@ /** * This package holds all classes that are related to the actual implementation of this plugin. - * This includes implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} but also any + * This includes implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem} but also any * {@link org.bukkit.event.Listener}. */ -package io.github.thebusybiscuit.slimefun4.implementation; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/AbstractResource.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/AbstractResource.java similarity index 88% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/AbstractResource.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/AbstractResource.java index cfe995787f..1f9d366132 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/AbstractResource.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/AbstractResource.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.resources; +package io.github.thebusybiscuit.slimefun5.implementation.resources; import java.util.logging.Level; @@ -6,15 +6,15 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.inventory.ItemStack; import com.google.gson.JsonElement; -import io.github.thebusybiscuit.slimefun4.api.exceptions.BiomeMapException; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap; +import io.github.thebusybiscuit.slimefun5.api.exceptions.BiomeMapException; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.biomes.BiomeMap; /** * This is an abstract parent class for any {@link GEOResource} @@ -106,3 +106,4 @@ public boolean isObtainableFromGEOMiner() { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/GEOResourcesSetup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/GEOResourcesSetup.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/GEOResourcesSetup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/GEOResourcesSetup.java index a731b9df2d..64b4215223 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/GEOResourcesSetup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/GEOResourcesSetup.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.resources; +package io.github.thebusybiscuit.slimefun5.implementation.resources; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; /** * This static setup class is used to register all default instances of @@ -21,3 +21,4 @@ public static void setup() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/NetherIceResource.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/NetherIceResource.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/NetherIceResource.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/NetherIceResource.java index 360761091f..e1f581071a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/NetherIceResource.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/NetherIceResource.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation.resources; +package io.github.thebusybiscuit.slimefun5.implementation.resources; import org.bukkit.World.Environment; import org.bukkit.block.Biome; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.biomes.BiomeMap; /** * A {@link GEOResource} which consists of nether ice. @@ -36,3 +36,4 @@ public int getDefaultSupply(Environment environment, Biome biome) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/OilResource.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/OilResource.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/OilResource.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/OilResource.java index 0407e65ec8..f8a9e756ad 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/OilResource.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/OilResource.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.resources; +package io.github.thebusybiscuit.slimefun5.implementation.resources; import org.bukkit.World.Environment; import org.bukkit.block.Biome; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump; -import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOMiner; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.OilPump; +import io.github.thebusybiscuit.slimefun5.utils.biomes.BiomeMap; /** * A {@link GEOResource} which consists of buckets of Oil. @@ -49,3 +49,4 @@ public int getDefaultSupply(Environment environment, Biome biome) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/SaltResource.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/SaltResource.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/SaltResource.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/SaltResource.java index 32a6294885..b9ceacbd1a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/SaltResource.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/SaltResource.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.resources; +package io.github.thebusybiscuit.slimefun5.implementation.resources; import org.bukkit.World.Environment; import org.bukkit.block.Biome; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.biomes.BiomeMap; /** * A {@link GEOResource} which consists of Salt. @@ -46,3 +46,4 @@ public int getDefaultSupply(Environment environment, Biome biome) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/UraniumResource.java similarity index 77% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/UraniumResource.java index 9791258c20..5956a6c39d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/UraniumResource.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.resources; +package io.github.thebusybiscuit.slimefun5.implementation.resources; import org.bukkit.World.Environment; import org.bukkit.block.Biome; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.biomes.BiomeMap; /** * A {@link GEOResource} which consists of small chunks of Uranium. @@ -47,3 +47,4 @@ public int getDefaultSupply(Environment environment, Biome biome) { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/package-info.java new file mode 100644 index 0000000000..4133616f1d --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/resources/package-info.java @@ -0,0 +1,4 @@ +/** + * This package contains all implementations of {@link io.github.thebusybiscuit.slimefun5.api.geo.GEOResource}. + */ +package io.github.thebusybiscuit.slimefun5.implementation.resources; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/ClimbableSurface.java similarity index 79% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/ClimbableSurface.java index 1e850c9624..ce68cf559a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/ClimbableSurface.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/ClimbableSurface.java @@ -1,13 +1,13 @@ -package io.github.thebusybiscuit.slimefun4.implementation.settings; +package io.github.thebusybiscuit.slimefun5.implementation.settings; import javax.annotation.Nonnull; import org.bukkit.Material; -import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.settings.DoubleRangeSetting; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; +import io.github.thebusybiscuit.slimefun5.api.events.ClimbingPickLaunchEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.settings.DoubleRangeSetting; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.ClimbingPick; /** * This is an {@link ItemSetting} that manages the efficiency of climbing @@ -50,3 +50,4 @@ public Material getType() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/GoldPanDrop.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/GoldPanDrop.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/GoldPanDrop.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/GoldPanDrop.java index f114c580e5..04de17f7ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/GoldPanDrop.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/GoldPanDrop.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.implementation.settings; +package io.github.thebusybiscuit.slimefun5.implementation.settings; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GoldPan; public class GoldPanDrop extends ItemSetting { @@ -37,4 +37,4 @@ public void update(Integer newValue) { goldPan.updateRandomizer(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/TalismanEnchantment.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/TalismanEnchantment.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/TalismanEnchantment.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/TalismanEnchantment.java index 3dd005f9c6..503fee2de5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/TalismanEnchantment.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/TalismanEnchantment.java @@ -1,13 +1,14 @@ -package io.github.thebusybiscuit.slimefun4.implementation.settings; +package io.github.thebusybiscuit.slimefun5.implementation.settings; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.enchantments.Enchantment; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.KeyedCompat; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.MagicianTalisman; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.TalismanListener; /** * This class is an extension of {@link ItemSetting} that holds an {@link Enchantment} and @@ -24,7 +25,7 @@ public class TalismanEnchantment extends ItemSetting { @ParametersAreNonnullByDefault public TalismanEnchantment(MagicianTalisman talisman, Enchantment enchantment, int level) { - super(talisman, "allow-enchantments." + enchantment.getKey().getNamespace() + '.' + enchantment.getKey().getKey() + ".level." + level, true); + super(talisman, "allow-enchantments." + KeyedCompat.namespace(enchantment) + '.' + KeyedCompat.key(enchantment) + ".level." + level, true); this.enchantment = enchantment; this.level = level; @@ -49,4 +50,4 @@ public int getLevel() { return level; } -} \ No newline at end of file +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/package-info.java new file mode 100644 index 0000000000..06c4dcac21 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/settings/package-info.java @@ -0,0 +1,6 @@ +/** + * This package holds implementations of {@link io.github.thebusybiscuit.slimefun5.api.items.ItemSetting} that are for + * very specific {@link io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem SlimefunItems} and generally not + * very useful out of their context. + */ +package io.github.thebusybiscuit.slimefun5.implementation.settings; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultItemGroups.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/DefaultItemGroups.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultItemGroups.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/DefaultItemGroups.java index 3d23b19dce..917a5b569c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultItemGroups.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/DefaultItemGroups.java @@ -1,20 +1,21 @@ -package io.github.thebusybiscuit.slimefun4.implementation.setup; +package io.github.thebusybiscuit.slimefun5.implementation.setup; import java.time.Month; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.groups.FlexItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.groups.LockedItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.groups.SeasonalItemGroup; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This class holds a reference to every {@link ItemGroup} @@ -61,9 +62,10 @@ class DefaultItemGroups { protected final SeasonalItemGroup christmas = new SeasonalItemGroup(new NamespacedKey(Slimefun.instance(), "christmas"), Month.DECEMBER, 1, CustomItemStack.create(SlimefunUtils.getCustomHead("215ba31cde2671b8f176de6a9ffd008035f0590d63ee240be6e8921cd2037a45"), ChatUtils.christmas("Christmas") + " &7(December only)")); protected final SeasonalItemGroup valentinesDay = new SeasonalItemGroup(new NamespacedKey(Slimefun.instance(), "valentines_day"), Month.FEBRUARY, 2, CustomItemStack.create(SlimefunUtils.getCustomHead("55d89431d14bfef2060461b4a3565614dc51115c001fae2508e8684bc0ae6a80"), "&dValentine's Day" + " &7(14th February)")); protected final SeasonalItemGroup easter = new SeasonalItemGroup(new NamespacedKey(Slimefun.instance(), "easter"), Month.APRIL, 2, CustomItemStack.create(HeadTexture.EASTER_EGG.getAsItemStack(), "&6Easter" + " &7(April)")); - protected final SeasonalItemGroup birthday = new SeasonalItemGroup(new NamespacedKey(Slimefun.instance(), "birthday"), Month.OCTOBER, 1, CustomItemStack.create(Material.FIREWORK_ROCKET, "&a&lTheBusyBiscuit's Birthday &7(26th October)")); + protected final SeasonalItemGroup birthday = new SeasonalItemGroup(new NamespacedKey(Slimefun.instance(), "birthday"), Month.OCTOBER, 1, CustomItemStack.create(XMaterial.FIREWORK_ROCKET.parseMaterial(), "&a&lTheBusyBiscuit's Birthday &7(26th October)")); protected final SeasonalItemGroup halloween = new SeasonalItemGroup(new NamespacedKey(Slimefun.instance(), "halloween"), Month.OCTOBER, 1, CustomItemStack.create(Material.JACK_O_LANTERN, "&6&lHalloween &7(31st October)")); // Flex Item Groups protected final FlexItemGroup rickFlexGroup = new RickFlexGroup(new NamespacedKey(Slimefun.instance(), "rick")); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/PostSetup.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/PostSetup.java index ce8694bd31..4dd494446a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/PostSetup.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.setup; +package io.github.thebusybiscuit.slimefun5.implementation.setup; import java.io.BufferedReader; import java.io.IOException; @@ -24,15 +24,15 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemRegistryFinalizedEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.GrindStone; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.MakeshiftSmeltery; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.OreCrusher; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; -import io.github.thebusybiscuit.slimefun4.utils.JsonUtils; +import io.github.thebusybiscuit.slimefun5.api.events.SlimefunItemRegistryFinalizedEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.GrindStone; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.MakeshiftSmeltery; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.OreCrusher; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.Smeltery; +import io.github.thebusybiscuit.slimefun5.utils.JsonUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; @@ -99,10 +99,10 @@ public static void loadItems() { if (Slimefun.getUpdater().getBranch().isOfficial()) { sender.sendMessage(""); - sender.sendMessage(ChatColor.GREEN + " - Source Code: https://github.com/Slimefun/Slimefun4"); - sender.sendMessage(ChatColor.GREEN + " - Wiki: https://github.com/Slimefun/Slimefun4/wiki"); - sender.sendMessage(ChatColor.GREEN + " - Addons: https://github.com/Slimefun/Slimefun4/wiki/Addons"); - sender.sendMessage(ChatColor.GREEN + " - Bug Reports: https://github.com/Slimefun/Slimefun4/issues"); + sender.sendMessage(ChatColor.GREEN + " - Source Code: https://github.com/Slimefun5/Slimefun5"); + sender.sendMessage(ChatColor.GREEN + " - Wiki: https://github.com/Slimefun5/Slimefun5/wiki"); + sender.sendMessage(ChatColor.GREEN + " - Addons: https://github.com/Slimefun5/Slimefun5/wiki/Addons"); + sender.sendMessage(ChatColor.GREEN + " - Bug Reports: https://github.com/Slimefun5/Slimefun5/issues"); sender.sendMessage(ChatColor.GREEN + " - Discord: https://discord.gg/slimefun"); } else { sender.sendMessage(ChatColor.GREEN + " - UNOFFICIALLY MODIFIED BUILD - NO OFFICIAL SUPPORT GIVEN"); @@ -196,8 +196,8 @@ private static void loadSmelteryRecipes() { } for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) { - if (item instanceof AContainer machine) { - if (machine.getMachineIdentifier().equals("ELECTRIC_SMELTERY")) { + if (item instanceof AContainer) { + AContainer machine = (AContainer) item; if (machine.getMachineIdentifier().equals("ELECTRIC_SMELTERY")) { List recipes = machine.getMachineRecipes(); Collections.sort(recipes, Comparator.comparingInt(recipe -> recipe == null ? 0 : -recipe.getInput().length)); } @@ -234,9 +234,10 @@ private static boolean isDust(@Nonnull ItemStack item) { private static void registerMachineRecipe(String machine, int seconds, ItemStack[] input, ItemStack[] output) { for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) { - if (item instanceof AContainer container && container.getMachineIdentifier().equals(machine)) { - container.registerRecipe(seconds, input, output); + if (item instanceof AContainer && ((AContainer) item).getMachineIdentifier().equals(machine)) { + AContainer container = (AContainer) item; container.registerRecipe(seconds, input, output); } } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/ResearchSetup.java similarity index 98% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/ResearchSetup.java index 0ad68ea14e..0079f29445 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/ResearchSetup.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.setup; +package io.github.thebusybiscuit.slimefun5.implementation.setup; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; import java.util.Arrays; @@ -329,3 +329,4 @@ private static void register(String key, int id, String name, int defaultCost, S research.register(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/RickFlexGroup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/RickFlexGroup.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/RickFlexGroup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/RickFlexGroup.java index 914a7b517f..668231b5ee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/RickFlexGroup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/RickFlexGroup.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.setup; +package io.github.thebusybiscuit.slimefun5.implementation.setup; import java.time.LocalDate; import java.time.Month; @@ -6,14 +6,14 @@ import javax.annotation.Nonnull; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun5.api.items.groups.FlexItemGroup; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.utils.ChatUtils; /** * A super ordinary class. @@ -46,3 +46,4 @@ public void open(Player p, PlayerProfile profile, SlimefunGuideMode layout) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/SlimefunItemSetup.java similarity index 80% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/SlimefunItemSetup.java index 2448331bec..08936b6896 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/SlimefunItemSetup.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.setup; +package io.github.thebusybiscuit.slimefun5.implementation.setup; import java.util.ArrayList; import java.util.List; @@ -8,216 +8,218 @@ import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; -import io.github.thebusybiscuit.slimefun4.core.handlers.RainbowTickHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.EnchantedItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.HiddenItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.RadioactiveItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInterface; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FishermanAndroid; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ProgrammableAndroid; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.WoodcutterAndroid; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.EnderBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.FarmerShoes; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.LongFallBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.Parachute; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.RainbowArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.StomperBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.ArmorAutoCrafter; -import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.EnhancedAutoCrafter; -import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.VanillaAutoCrafter; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.EnderBackpack; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.RestoredBackpack; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SoulboundBackpack; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BrokenSpawner; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.Composter; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.Crucible; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.EnhancedFurnace; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HardenedGlass; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.IgnitionChamber; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.WitherProofBlock; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.AdvancedCargoOutputNode; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoConnectorNode; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoInputNode; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoManager; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoOutputNode; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyRegulator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.MultiTool; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Multimeter; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.SolarHelmet; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.BioGenerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.CoalGenerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.CombustionGenerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.LavaGenerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.MagnesiumGenerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.SolarGenerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoAnvil; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoBrewer; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutoDrier; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.CarbonPress; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ChargingBench; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricDustWasher; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricFurnace; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricGoldPan; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricIngotFactory; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricIngotPulverizer; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricOreGrinder; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricPress; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricSmeltery; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectrifiedCrucible; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.FluidPump; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.FoodComposter; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.FoodFabricator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.Freezer; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.HeatedPressureChamber; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.Refinery; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators.AnimalGrowthAccelerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators.CropGrowthAccelerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators.TreeGrowthAccelerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.BookBinder; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.AutoBreeder; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.ExpCollector; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.IronGolemAssembler; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.ProduceCollector; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.WitherAssembler; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor; -import io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.BirthdayCake; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.HeavyCream; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.MagicSugar; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.MeatJerky; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.MonsterJerky; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.PortableGEOScanner; -import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSControlPanel; -import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSMarkerTool; -import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.BeeWings; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfernalBonemeal; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfusedHopper; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfusedMagnet; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeFlask; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeTome; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicEyeOfEnder; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicalZombiePills; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.TelepositionScroll; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.ElementalRune; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.EnchantmentRune; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.SoulboundRune; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.VillagerRune; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.StormStaff; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.WaterStaff; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.WindStaff; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; -import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Bandage; -import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Medicine; -import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Splint; -import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Vitamins; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.AlloyIngot; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.CoolantCell; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.GoldIngot; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFertilizer; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFood; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.SteelThruster; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.StrangeNetherGoo; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.SyntheticEmerald; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.ArmorForge; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.AutomatedPanningMachine; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Compressor; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.EnhancedCraftingTable; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.GrindStone; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Juicer; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.MagicWorkbench; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.MakeshiftSmeltery; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.OreCrusher; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.OreWasher; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.PressureChamber; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.TableSaw; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner.AdvancedIndustrialMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner.IndustrialMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.seasonal.ChristmasPresent; -import io.github.thebusybiscuit.slimefun4.implementation.items.seasonal.EasterEgg; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.PersonalActivationPlate; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.PortableTeleporter; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.SharedActivationPlate; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.TeleporterPylon; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosivePickaxe; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveShovel; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.LumberAxe; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.NetherGoldPan; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfContainment; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfTheSeeker; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfVeinMining; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PortableCrafter; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PortableDustbin; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.SmeltersPickaxe; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.TapeMeasure; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.ExplosiveBow; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.IcyBow; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SwordOfBeheading; -import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.VampireBlade; -import io.github.thebusybiscuit.slimefun4.utils.ColoredMaterial; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactivity; +import io.github.thebusybiscuit.slimefun5.core.handlers.RainbowTickHandler; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.EnchantedItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.HiddenItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.RadioactiveItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientAltar; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.AndroidInterface; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.ButcherAndroid; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.FarmerAndroid; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.FishermanAndroid; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.MinerAndroid; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.ProgrammableAndroid; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.WoodcutterAndroid; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.ElytraCap; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.EnderBoots; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.FarmerShoes; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.HazmatArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.LongFallBoots; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.Parachute; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.RainbowArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.StomperBoots; +import io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters.ArmorAutoCrafter; +import io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters.EnhancedAutoCrafter; +import io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters.VanillaAutoCrafter; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.Cooler; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.EnderBackpack; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.RestoredBackpack; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SlimefunBackpack; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SoulboundBackpack; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.BlockPlacer; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.BrokenSpawner; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.Composter; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.Crucible; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.EnhancedFurnace; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.HardenedGlass; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.HologramProjector; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.IgnitionChamber; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.OutputChest; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.RainbowBlock; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.RepairedSpawner; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.UnplaceableBlock; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.WitherProofBlock; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.AdvancedCargoOutputNode; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.CargoConnectorNode; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.CargoInputNode; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.CargoManager; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.CargoOutputNode; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.ReactorAccessPort; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.TrashCan; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.Capacitor; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.EnergyConnector; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.EnergyRegulator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.JetBoots; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.Jetpack; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.MultiTool; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.Multimeter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.SolarHelmet; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators.BioGenerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators.CoalGenerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators.CombustionGenerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators.LavaGenerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators.MagnesiumGenerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.generators.SolarGenerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.AutoAnvil; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.AutoBrewer; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.AutoDrier; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.CarbonPress; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ChargingBench; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricDustWasher; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricFurnace; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricGoldPan; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricIngotFactory; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricIngotPulverizer; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricOreGrinder; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricPress; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricSmeltery; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectrifiedCrucible; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.FluidPump; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.FoodComposter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.FoodFabricator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.Freezer; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.HeatedPressureChamber; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.Refinery; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators.AnimalGrowthAccelerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators.CropGrowthAccelerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators.TreeGrowthAccelerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting.AutoDisenchanter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting.AutoEnchanter; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.enchanting.BookBinder; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities.AutoBreeder; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities.ExpCollector; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities.IronGolemAssembler; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities.ProduceCollector; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.entities.WitherAssembler; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.NetherStarReactor; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.reactors.NuclearReactor; +import io.github.thebusybiscuit.slimefun5.implementation.items.elevator.ElevatorPlate; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.BirthdayCake; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.DietCookie; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.FortuneCookie; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.HeavyCream; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.Juice; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.MagicSugar; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.MeatJerky; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.MonsterJerky; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOMiner; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.GEOScanner; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.OilPump; +import io.github.thebusybiscuit.slimefun5.implementation.items.geo.PortableGEOScanner; +import io.github.thebusybiscuit.slimefun5.implementation.items.gps.GPSControlPanel; +import io.github.thebusybiscuit.slimefun5.implementation.items.gps.GPSMarkerTool; +import io.github.thebusybiscuit.slimefun5.implementation.items.gps.GPSTransmitter; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.BeeWings; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.InfernalBonemeal; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.InfusedHopper; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.InfusedMagnet; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.KnowledgeFlask; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.KnowledgeTome; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.MagicEyeOfEnder; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.MagicalZombiePills; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.SoulboundItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.TelepositionScroll; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes.ElementalRune; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes.EnchantmentRune; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes.SoulboundRune; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.runes.VillagerRune; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves.StormStaff; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves.WaterStaff; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves.WindStaff; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.MagicianTalisman; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.Talisman; +import io.github.thebusybiscuit.slimefun5.implementation.items.medical.Bandage; +import io.github.thebusybiscuit.slimefun5.implementation.items.medical.Medicine; +import io.github.thebusybiscuit.slimefun5.implementation.items.medical.Splint; +import io.github.thebusybiscuit.slimefun5.implementation.items.medical.Vitamins; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.AlloyIngot; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.BasicCircuitBoard; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.CoolantCell; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.GoldIngot; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.OrganicFertilizer; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.OrganicFood; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.SteelThruster; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.StrangeNetherGoo; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.SyntheticEmerald; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.ArmorForge; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.AutomatedPanningMachine; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.Compressor; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.EnhancedCraftingTable; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.GrindStone; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.Juicer; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.MagicWorkbench; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.MakeshiftSmeltery; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.OreCrusher; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.OreWasher; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.PressureChamber; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.Smeltery; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.TableSaw; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner.AdvancedIndustrialMiner; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner.IndustrialMiner; +import io.github.thebusybiscuit.slimefun5.implementation.items.seasonal.ChristmasPresent; +import io.github.thebusybiscuit.slimefun5.implementation.items.seasonal.EasterEgg; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.PersonalActivationPlate; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.PortableTeleporter; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.SharedActivationPlate; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.Teleporter; +import io.github.thebusybiscuit.slimefun5.implementation.items.teleporter.TeleporterPylon; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.ClimbingPick; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.ExplosivePickaxe; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.ExplosiveShovel; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GoldPan; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GrapplingHook; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.LumberAxe; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.NetherGoldPan; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.PickaxeOfContainment; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.PickaxeOfTheSeeker; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.PickaxeOfVeinMining; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.PortableCrafter; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.PortableDustbin; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.SmeltersPickaxe; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.TapeMeasure; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.ExplosiveBow; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.IcyBow; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.SeismicAxe; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.SwordOfBeheading; +import io.github.thebusybiscuit.slimefun5.implementation.items.weapons.VampireBlade; +import io.github.thebusybiscuit.slimefun5.utils.ColoredMaterial; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PotionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; /** * This class holds the recipes of all items. @@ -240,15 +242,15 @@ public static void setup(@Nonnull Slimefun plugin) { // @formatter:off (We will need to refactor this one day) new SlimefunItem(itemGroups.weapons, SlimefunItems.GRANDMAS_WALKING_STICK, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, new ItemStack(Material.OAK_LOG), null, null, new ItemStack(Material.OAK_LOG), null, null, new ItemStack(Material.OAK_LOG), null}) + new ItemStack[] {null, MaterialCompat.stack(XMaterial.OAK_LOG), null, null, MaterialCompat.stack(XMaterial.OAK_LOG), null, null, MaterialCompat.stack(XMaterial.OAK_LOG), null}) .register(plugin); new SlimefunItem(itemGroups.weapons, SlimefunItems.GRANDPAS_WALKING_STICK, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.LEATHER), new ItemStack(Material.OAK_LOG), new ItemStack(Material.LEATHER), null, new ItemStack(Material.OAK_LOG), null, null, new ItemStack(Material.OAK_LOG), null}) + new ItemStack[] {new ItemStack(Material.LEATHER), MaterialCompat.stack(XMaterial.OAK_LOG), new ItemStack(Material.LEATHER), null, MaterialCompat.stack(XMaterial.OAK_LOG), null, null, MaterialCompat.stack(XMaterial.OAK_LOG), null}) .register(plugin); new PortableCrafter(itemGroups.usefulItems, SlimefunItems.PORTABLE_CRAFTER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.BOOK), new ItemStack(Material.CRAFTING_TABLE), null, null, null, null, null, null, null}) + new ItemStack[] {new ItemStack(Material.BOOK), MaterialCompat.stack(XMaterial.CRAFTING_TABLE), null, null, null, null, null, null, null}) .register(plugin); new FortuneCookie(itemGroups.food, SlimefunItems.FORTUNE_COOKIE, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -274,7 +276,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new MeatJerky(itemGroups.food, SlimefunItems.PORK_JERKY, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.SALT.item(), new ItemStack(Material.COOKED_PORKCHOP), null, null, null, null, null, null, null}) + new ItemStack[] {SlimefunItems.SALT.item(), MaterialCompat.stack(XMaterial.COOKED_PORKCHOP), null, null, null, null, null, null, null}) .register(plugin); new MeatJerky(itemGroups.food, SlimefunItems.CHICKEN_JERKY, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -290,11 +292,11 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new MeatJerky(itemGroups.food, SlimefunItems.FISH_JERKY, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.SALT.item(), new ItemStack(Material.COOKED_COD), null, null, null, null, null, null, null}) + new ItemStack[] {SlimefunItems.SALT.item(), MaterialCompat.stack(XMaterial.COOKED_COD), null, null, null, null, null, null, null}) .register(plugin); new SlimefunItem(itemGroups.food, SlimefunItems.KELP_COOKIE, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, new ItemStack(Material.DRIED_KELP), null, new ItemStack(Material.DRIED_KELP), new ItemStack(Material.SUGAR), new ItemStack(Material.DRIED_KELP), null, new ItemStack(Material.DRIED_KELP), null}, + new ItemStack[] {null, MaterialCompat.stack(XMaterial.DRIED_KELP), null, MaterialCompat.stack(XMaterial.DRIED_KELP), new ItemStack(Material.SUGAR), MaterialCompat.stack(XMaterial.DRIED_KELP), null, MaterialCompat.stack(XMaterial.DRIED_KELP), null}, new SlimefunItemStack(SlimefunItems.KELP_COOKIE, 2).item()) .register(plugin); @@ -307,7 +309,7 @@ public static void setup(@Nonnull Slimefun plugin) { new Compressor(itemGroups.basicMachines, SlimefunItems.COMPRESSOR).register(plugin); new SlimefunItem(itemGroups.magicalResources, SlimefunItems.MAGIC_LUMP_1, RecipeType.GRIND_STONE, - new ItemStack[] {new ItemStack(Material.NETHER_WART), null, null, null, null, null, null, null, null}, + new ItemStack[] {MaterialCompat.stack(XMaterial.NETHER_WART), null, null, null, null, null, null, null, null}, new SlimefunItemStack(SlimefunItems.MAGIC_LUMP_1, 2).item()) .register(plugin); @@ -320,7 +322,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunItem(itemGroups.magicalResources, SlimefunItems.ENDER_LUMP_1, RecipeType.GRIND_STONE, - new ItemStack[] {new ItemStack(Material.ENDER_EYE), null, null, null, null, null, null, null, null}, + new ItemStack[] {MaterialCompat.stack(XMaterial.ENDER_EYE), null, null, null, null, null, null, null, null}, new SlimefunItemStack(SlimefunItems.ENDER_LUMP_1, 2).item()) .register(plugin); @@ -337,15 +339,15 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunItem(itemGroups.magicalArmor, SlimefunItems.ENDER_HELMET, RecipeType.ARMOR_FORGE, - new ItemStack[] {SlimefunItems.ENDER_LUMP_1.item(), new ItemStack(Material.ENDER_EYE), SlimefunItems.ENDER_LUMP_1.item(), new ItemStack(Material.OBSIDIAN), null, new ItemStack(Material.OBSIDIAN), null, null, null}) + new ItemStack[] {SlimefunItems.ENDER_LUMP_1.item(), MaterialCompat.stack(XMaterial.ENDER_EYE), SlimefunItems.ENDER_LUMP_1.item(), new ItemStack(Material.OBSIDIAN), null, new ItemStack(Material.OBSIDIAN), null, null, null}) .register(plugin); new SlimefunItem(itemGroups.magicalArmor, SlimefunItems.ENDER_CHESTPLATE, RecipeType.ARMOR_FORGE, - new ItemStack[] {SlimefunItems.ENDER_LUMP_1.item(), null, SlimefunItems.ENDER_LUMP_1.item(), new ItemStack(Material.OBSIDIAN), new ItemStack(Material.ENDER_EYE), new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN)}) + new ItemStack[] {SlimefunItems.ENDER_LUMP_1.item(), null, SlimefunItems.ENDER_LUMP_1.item(), new ItemStack(Material.OBSIDIAN), MaterialCompat.stack(XMaterial.ENDER_EYE), new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN)}) .register(plugin); new SlimefunItem(itemGroups.magicalArmor, SlimefunItems.ENDER_LEGGINGS, RecipeType.ARMOR_FORGE, - new ItemStack[] {SlimefunItems.ENDER_LUMP_1.item(), new ItemStack(Material.ENDER_EYE), SlimefunItems.ENDER_LUMP_1.item(), new ItemStack(Material.OBSIDIAN), null, new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN), null, new ItemStack(Material.OBSIDIAN)}) + new ItemStack[] {SlimefunItems.ENDER_LUMP_1.item(), MaterialCompat.stack(XMaterial.ENDER_EYE), SlimefunItems.ENDER_LUMP_1.item(), new ItemStack(Material.OBSIDIAN), null, new ItemStack(Material.OBSIDIAN), new ItemStack(Material.OBSIDIAN), null, new ItemStack(Material.OBSIDIAN)}) .register(plugin); new EnderBoots(itemGroups.magicalArmor, SlimefunItems.ENDER_BOOTS, RecipeType.ARMOR_FORGE, @@ -353,7 +355,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new MagicEyeOfEnder(itemGroups.magicalGadgets, SlimefunItems.MAGIC_EYE_OF_ENDER, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {SlimefunItems.ENDER_LUMP_2.item(), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_2.item(), new ItemStack(Material.ENDER_PEARL), new ItemStack(Material.ENDER_EYE), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_2.item(), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_2.item()}) + new ItemStack[] {SlimefunItems.ENDER_LUMP_2.item(), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_2.item(), new ItemStack(Material.ENDER_PEARL), MaterialCompat.stack(XMaterial.ENDER_EYE), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_2.item(), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_2.item()}) .register(plugin); new MagicSugar(itemGroups.food, SlimefunItems.MAGIC_SUGAR, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -392,7 +394,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new UnplaceableBlock(itemGroups.magicalResources, SlimefunItems.MAGICAL_GLASS, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {SlimefunItems.MAGIC_LUMP_2.item(), SlimefunItems.GOLD_DUST.item(), SlimefunItems.MAGIC_LUMP_2.item(), SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.item(), new ItemStack(Material.GLASS_PANE), SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.item(), SlimefunItems.MAGIC_LUMP_2.item(), SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.item(), SlimefunItems.MAGIC_LUMP_2.item()}) + new ItemStack[] {SlimefunItems.MAGIC_LUMP_2.item(), SlimefunItems.GOLD_DUST.item(), SlimefunItems.MAGIC_LUMP_2.item(), SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.item(), MaterialCompat.stack(XMaterial.GLASS_PANE), SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.item(), SlimefunItems.MAGIC_LUMP_2.item(), SlimefunItems.FILLED_FLASK_OF_KNOWLEDGE.item(), SlimefunItems.MAGIC_LUMP_2.item()}) .register(plugin); new BasicCircuitBoard(itemGroups.technicalComponents, SlimefunItems.BASIC_CIRCUIT_BOARD, RecipeType.MOB_DROP, @@ -419,7 +421,7 @@ public static void setup(@Nonnull Slimefun plugin) { new Smeltery(itemGroups.basicMachines, SlimefunItems.SMELTERY).register(plugin); new IgnitionChamber(itemGroups.basicMachines, SlimefunItems.IGNITION_CHAMBER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.IRON_INGOT), new ItemStack(Material.FLINT_AND_STEEL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), SlimefunItems.BASIC_CIRCUIT_BOARD.item(), new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.OBSERVER), null}) + new ItemStack[] {new ItemStack(Material.IRON_INGOT), new ItemStack(Material.FLINT_AND_STEEL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), SlimefunItems.BASIC_CIRCUIT_BOARD.item(), new ItemStack(Material.IRON_INGOT), null, MaterialCompat.stack(XMaterial.OBSERVER), null}) .register(plugin); new PressureChamber(itemGroups.basicMachines, SlimefunItems.PRESSURE_CHAMBER).register(plugin); @@ -522,7 +524,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunItem(itemGroups.resources, SlimefunItems.SYNTHETIC_SAPPHIRE, RecipeType.SMELTERY, - new ItemStack[] {SlimefunItems.ALUMINUM_DUST.item(), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS_PANE), SlimefunItems.ALUMINUM_INGOT.item(), new ItemStack(Material.LAPIS_LAZULI), null, null, null, null}) + new ItemStack[] {SlimefunItems.ALUMINUM_DUST.item(), new ItemStack(Material.GLASS), MaterialCompat.stack(XMaterial.GLASS_PANE), SlimefunItems.ALUMINUM_INGOT.item(), MaterialCompat.stack(XMaterial.LAPIS_LAZULI), null, null, null, null}) .setUseableInWorkbench(true) .register(plugin); @@ -532,7 +534,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunItem(itemGroups.resources, SlimefunItems.RAW_CARBONADO, RecipeType.SMELTERY, - new ItemStack[] {SlimefunItems.SYNTHETIC_DIAMOND.item(), SlimefunItems.CARBON_CHUNK.item(), new ItemStack(Material.GLASS_PANE), null, null, null, null, null, null}) + new ItemStack[] {SlimefunItems.SYNTHETIC_DIAMOND.item(), SlimefunItems.CARBON_CHUNK.item(), MaterialCompat.stack(XMaterial.GLASS_PANE), null, null, null, null, null, null}) .register(plugin); new AlloyIngot(itemGroups.resources, SlimefunItems.NICKEL_INGOT, @@ -642,7 +644,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SteelThruster(itemGroups.technicalComponents, SlimefunItems.STEEL_THRUSTER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, new ItemStack(Material.REDSTONE), null, SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.STEEL_PLATE.item(), new ItemStack(Material.FIRE_CHARGE), SlimefunItems.STEEL_PLATE.item()}) + new ItemStack[] {null, new ItemStack(Material.REDSTONE), null, SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.STEEL_PLATE.item(), MaterialCompat.stack(XMaterial.FIRE_CHARGE), SlimefunItems.STEEL_PLATE.item()}) .register(plugin); new SlimefunItem(itemGroups.technicalComponents, SlimefunItems.POWER_CRYSTAL, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -722,7 +724,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new WaterStaff(itemGroups.magicalGadgets, SlimefunItems.STAFF_WATER, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, new ItemStack(Material.LILY_PAD), SlimefunItems.MAGIC_LUMP_2.item(), null, SlimefunItems.STAFF_ELEMENTAL.item(), new ItemStack(Material.LILY_PAD), SlimefunItems.STAFF_ELEMENTAL.item(), null, null}) + new ItemStack[] {null, MaterialCompat.stack(XMaterial.LILY_PAD), SlimefunItems.MAGIC_LUMP_2.item(), null, SlimefunItems.STAFF_ELEMENTAL.item(), MaterialCompat.stack(XMaterial.LILY_PAD), SlimefunItems.STAFF_ELEMENTAL.item(), null, null}) .register(plugin); new EnchantedItem(itemGroups.magicalGadgets, SlimefunItems.STAFF_FIRE, RecipeType.MAGIC_WORKBENCH, @@ -841,9 +843,9 @@ public static void setup(@Nonnull Slimefun plugin) { ItemStack weaknessPotion = new ItemStack(Material.POTION); PotionMeta meta = (PotionMeta) weaknessPotion.getItemMeta(); if (Slimefun.getMinecraftVersion().isBefore(20, 2)) { - meta.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false)); + PotionCompat.setBasePotionData(meta, PotionType.WEAKNESS, false, false); } else { - meta.setBasePotionType(PotionType.WEAKNESS); + PotionCompat.setBasePotionType(meta, PotionType.WEAKNESS); } weaknessPotion.setItemMeta(meta); @@ -902,7 +904,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new MagicianTalisman(SlimefunItems.TALISMAN_MAGICIAN, - new ItemStack[] {SlimefunItems.ENDER_LUMP_3.item(), null, SlimefunItems.ENDER_LUMP_3.item(), new ItemStack(Material.ENCHANTING_TABLE), SlimefunItems.COMMON_TALISMAN.item(), new ItemStack(Material.ENCHANTING_TABLE), SlimefunItems.ENDER_LUMP_3.item(), null, SlimefunItems.ENDER_LUMP_3.item()}) + new ItemStack[] {SlimefunItems.ENDER_LUMP_3.item(), null, SlimefunItems.ENDER_LUMP_3.item(), MaterialCompat.stack(XMaterial.ENCHANTING_TABLE), SlimefunItems.COMMON_TALISMAN.item(), MaterialCompat.stack(XMaterial.ENCHANTING_TABLE), SlimefunItems.ENDER_LUMP_3.item(), null, SlimefunItems.ENDER_LUMP_3.item()}) .register(plugin); new Talisman(SlimefunItems.TALISMAN_TRAVELLER, @@ -921,7 +923,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new Talisman(SlimefunItems.TALISMAN_CAVEMAN, - new ItemStack[] { SlimefunItems.MAGIC_LUMP_3.item(), null, SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.GOLDEN_PICKAXE), SlimefunItems.TALISMAN_MINER.item(), SlimefunItems.EARTH_RUNE.item(), SlimefunItems.MAGIC_LUMP_3.item(), null, SlimefunItems.MAGIC_LUMP_3.item()}, + new ItemStack[] { SlimefunItems.MAGIC_LUMP_3.item(), null, SlimefunItems.MAGIC_LUMP_3.item(), MaterialCompat.stack(XMaterial.GOLDEN_PICKAXE), SlimefunItems.TALISMAN_MINER.item(), SlimefunItems.EARTH_RUNE.item(), SlimefunItems.MAGIC_LUMP_3.item(), null, SlimefunItems.MAGIC_LUMP_3.item()}, false, false, "caveman", 50, new PotionEffect(VersionedPotionEffectType.HASTE, 800, 2)) .register(plugin); @@ -935,7 +937,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SyntheticEmerald(itemGroups.resources, SlimefunItems.SYNTHETIC_EMERALD, RecipeType.SMELTERY, - new ItemStack[] {SlimefunItems.SYNTHETIC_SAPPHIRE.item(), SlimefunItems.ALUMINUM_DUST.item(), SlimefunItems.ALUMINUM_INGOT.item(), new ItemStack(Material.GLASS_PANE), null, null, null, null, null}) + new ItemStack[] {SlimefunItems.SYNTHETIC_SAPPHIRE.item(), SlimefunItems.ALUMINUM_DUST.item(), SlimefunItems.ALUMINUM_INGOT.item(), MaterialCompat.stack(XMaterial.GLASS_PANE), null, null, null, null, null}) .register(plugin); registerArmorSet(itemGroups.armor, SlimefunItems.CHAIN, new ItemStack[] { @@ -982,21 +984,21 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new HazmatArmorPiece(itemGroups.armor, SlimefunItems.SCUBA_HELMET, RecipeType.ARMOR_FORGE, - new ItemStack[] {new ItemStack(Material.ORANGE_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), new ItemStack(Material.ORANGE_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), new ItemStack(Material.GLASS_PANE), SlimefunItems.REINFORCED_CLOTH.item(), null, null, null}, + new ItemStack[] {MaterialCompat.stack(XMaterial.ORANGE_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), MaterialCompat.stack(XMaterial.ORANGE_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), MaterialCompat.stack(XMaterial.GLASS_PANE), SlimefunItems.REINFORCED_CLOTH.item(), null, null, null}, new PotionEffect[] {new PotionEffect(PotionEffectType.WATER_BREATHING, 300, 1)}) .register(plugin); new HazmatArmorPiece(itemGroups.armor, SlimefunItems.HAZMAT_CHESTPLATE, RecipeType.ARMOR_FORGE, - new ItemStack[] {new ItemStack(Material.ORANGE_WOOL), null, new ItemStack(Material.ORANGE_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), SlimefunItems.REINFORCED_CLOTH.item(), SlimefunItems.REINFORCED_CLOTH.item(), new ItemStack(Material.BLACK_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), new ItemStack(Material.BLACK_WOOL)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.ORANGE_WOOL), null, MaterialCompat.stack(XMaterial.ORANGE_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), SlimefunItems.REINFORCED_CLOTH.item(), SlimefunItems.REINFORCED_CLOTH.item(), MaterialCompat.stack(XMaterial.BLACK_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), MaterialCompat.stack(XMaterial.BLACK_WOOL)}, new PotionEffect[] {new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 300, 1)}) .register(plugin); new HazmatArmorPiece(itemGroups.armor, SlimefunItems.HAZMAT_LEGGINGS, RecipeType.ARMOR_FORGE, - new ItemStack[] {new ItemStack(Material.BLACK_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), new ItemStack(Material.BLACK_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), null, SlimefunItems.REINFORCED_CLOTH.item(), SlimefunItems.REINFORCED_CLOTH.item(), null, SlimefunItems.REINFORCED_CLOTH.item()}, new PotionEffect[0]) + new ItemStack[] {MaterialCompat.stack(XMaterial.BLACK_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), MaterialCompat.stack(XMaterial.BLACK_WOOL), SlimefunItems.REINFORCED_CLOTH.item(), null, SlimefunItems.REINFORCED_CLOTH.item(), SlimefunItems.REINFORCED_CLOTH.item(), null, SlimefunItems.REINFORCED_CLOTH.item()}, new PotionEffect[0]) .register(plugin); new HazmatArmorPiece(itemGroups.armor, SlimefunItems.HAZMAT_BOOTS, RecipeType.ARMOR_FORGE, - new ItemStack[] {SlimefunItems.REINFORCED_CLOTH.item(), null, SlimefunItems.REINFORCED_CLOTH.item(), SlimefunItems.REINFORCED_CLOTH.item(), null, SlimefunItems.REINFORCED_CLOTH.item(), new ItemStack(Material.BLACK_WOOL), null, new ItemStack(Material.BLACK_WOOL)}, new PotionEffect[0]) + new ItemStack[] {SlimefunItems.REINFORCED_CLOTH.item(), null, SlimefunItems.REINFORCED_CLOTH.item(), SlimefunItems.REINFORCED_CLOTH.item(), null, SlimefunItems.REINFORCED_CLOTH.item(), MaterialCompat.stack(XMaterial.BLACK_WOOL), null, MaterialCompat.stack(XMaterial.BLACK_WOOL)}, new PotionEffect[0]) .register(plugin); new SlimefunItem(itemGroups.misc, SlimefunItems.CRUSHED_ORE, RecipeType.ORE_CRUSHER, @@ -1032,7 +1034,7 @@ public static void setup(@Nonnull Slimefun plugin) { }, "GOLD_12K", false, new PotionEffect[0][0], plugin); new SlimefunItem(itemGroups.misc, SlimefunItems.CLOTH, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.WHITE_WOOL), null, null, null, null, null, null, null, null}, + new ItemStack[] {MaterialCompat.stack(XMaterial.WHITE_WOOL), null, null, null, null, null, null, null, null}, new SlimefunItemStack(SlimefunItems.CLOTH, 8).item()) .register(plugin); @@ -1065,7 +1067,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunArmorPiece(itemGroups.technicalGadgets, SlimefunItems.NIGHT_VISION_GOGGLES, RecipeType.ARMOR_FORGE, - new ItemStack[] {new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.LIME_STAINED_GLASS_PANE), new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.LIME_STAINED_GLASS_PANE), new ItemStack(Material.COAL_BLOCK), null, new ItemStack(Material.COAL_BLOCK)}, + new ItemStack[] {new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.COAL_BLOCK), new ItemStack(Material.COAL_BLOCK), MaterialCompat.stack(XMaterial.LIME_STAINED_GLASS_PANE), new ItemStack(Material.COAL_BLOCK), MaterialCompat.stack(XMaterial.LIME_STAINED_GLASS_PANE), new ItemStack(Material.COAL_BLOCK), null, new ItemStack(Material.COAL_BLOCK)}, new PotionEffect[] {new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 20)}) .register(plugin); @@ -1095,7 +1097,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new VampireBlade(itemGroups.weapons, SlimefunItems.BLADE_OF_VAMPIRES, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, new ItemStack(Material.WITHER_SKELETON_SKULL), null, null, new ItemStack(Material.WITHER_SKELETON_SKULL), null, null, new ItemStack(Material.BLAZE_ROD), null}) + new ItemStack[] {null, MaterialCompat.stack(XMaterial.WITHER_SKELETON_SKULL), null, null, MaterialCompat.stack(XMaterial.WITHER_SKELETON_SKULL), null, null, new ItemStack(Material.BLAZE_ROD), null}) .register(plugin); new SlimefunItem(itemGroups.misc, SlimefunItems.GOLD_24K_BLOCK, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -1103,7 +1105,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new Composter(itemGroups.basicMachines, SlimefunItems.COMPOSTER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.OAK_SLAB), null, new ItemStack(Material.OAK_SLAB), new ItemStack(Material.OAK_SLAB), null, new ItemStack(Material.OAK_SLAB), new ItemStack(Material.OAK_SLAB), new ItemStack(Material.CAULDRON), new ItemStack(Material.OAK_SLAB)}) + new ItemStack[] {MaterialCompat.stack(XMaterial.OAK_SLAB), null, MaterialCompat.stack(XMaterial.OAK_SLAB), MaterialCompat.stack(XMaterial.OAK_SLAB), null, MaterialCompat.stack(XMaterial.OAK_SLAB), MaterialCompat.stack(XMaterial.OAK_SLAB), new ItemStack(Material.CAULDRON), MaterialCompat.stack(XMaterial.OAK_SLAB)}) .register(plugin); new FarmerShoes(itemGroups.magicalArmor, SlimefunItems.FARMER_SHOES, RecipeType.ARMOR_FORGE, @@ -1124,7 +1126,7 @@ public static void setup(@Nonnull Slimefun plugin) { new AdvancedIndustrialMiner(itemGroups.basicMachines, SlimefunItems.ADVANCED_INDUSTRIAL_MINER).register(plugin); new StomperBoots(itemGroups.magicalArmor, SlimefunItems.BOOTS_OF_THE_STOMPER, RecipeType.ARMOR_FORGE, - new ItemStack[] {null, null, null, new ItemStack(Material.YELLOW_WOOL), null, new ItemStack(Material.YELLOW_WOOL), new ItemStack(Material.PISTON), null, new ItemStack(Material.PISTON)}) + new ItemStack[] {null, null, null, MaterialCompat.stack(XMaterial.YELLOW_WOOL), null, MaterialCompat.stack(XMaterial.YELLOW_WOOL), MaterialCompat.stack(XMaterial.PISTON), null, MaterialCompat.stack(XMaterial.PISTON)}) .register(plugin); new PickaxeOfTheSeeker(itemGroups.tools, SlimefunItems.PICKAXE_OF_THE_SEEKER, RecipeType.MAGIC_WORKBENCH, @@ -1148,7 +1150,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new Crucible(itemGroups.basicMachines, SlimefunItems.CRUCIBLE, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.TERRACOTTA), null, new ItemStack(Material.TERRACOTTA), new ItemStack(Material.TERRACOTTA), null, new ItemStack(Material.TERRACOTTA), new ItemStack(Material.TERRACOTTA), new ItemStack(Material.FLINT_AND_STEEL), new ItemStack(Material.TERRACOTTA)}) + new ItemStack[] {MaterialCompat.stack(XMaterial.TERRACOTTA), null, MaterialCompat.stack(XMaterial.TERRACOTTA), MaterialCompat.stack(XMaterial.TERRACOTTA), null, MaterialCompat.stack(XMaterial.TERRACOTTA), MaterialCompat.stack(XMaterial.TERRACOTTA), new ItemStack(Material.FLINT_AND_STEEL), MaterialCompat.stack(XMaterial.TERRACOTTA)}) .register(plugin); new SlimefunBackpack(45, itemGroups.usefulItems, SlimefunItems.GILDED_BACKPACK, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -1174,7 +1176,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new UnplaceableBlock(itemGroups.magicalResources, SlimefunItems.NECROTIC_SKULL, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {SlimefunItems.MAGIC_LUMP_3.item(), null, SlimefunItems.MAGIC_LUMP_3.item(), null, new ItemStack(Material.WITHER_SKELETON_SKULL), null, SlimefunItems.MAGIC_LUMP_3.item(), null, SlimefunItems.MAGIC_LUMP_3.item()}) + new ItemStack[] {SlimefunItems.MAGIC_LUMP_3.item(), null, SlimefunItems.MAGIC_LUMP_3.item(), null, MaterialCompat.stack(XMaterial.WITHER_SKELETON_SKULL), null, SlimefunItems.MAGIC_LUMP_3.item(), null, SlimefunItems.MAGIC_LUMP_3.item()}) .register(plugin); new SlimefunItem(itemGroups.magicalResources, SlimefunItems.ESSENCE_OF_AFTERLIFE, RecipeType.ANCIENT_ALTAR, @@ -1182,7 +1184,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunItem(itemGroups.magicalResources, SlimefunItems.SYNTHETIC_SHULKER_SHELL, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.ENDER_RUNE.item(), SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.REINFORCED_PLATE.item(), new ItemStack(Material.TURTLE_HELMET), SlimefunItems.REINFORCED_PLATE.item(), SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.ENDER_RUNE.item(), SlimefunItems.ENDER_LUMP_3.item()}) + new ItemStack[] {SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.ENDER_RUNE.item(), SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.REINFORCED_PLATE.item(), MaterialCompat.stack(XMaterial.TURTLE_HELMET), SlimefunItems.REINFORCED_PLATE.item(), SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.ENDER_RUNE.item(), SlimefunItems.ENDER_LUMP_3.item()}) .setUseableInWorkbench(true) .register(plugin); @@ -1247,7 +1249,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SoulboundItem(itemGroups.weapons, SlimefunItems.SOULBOUND_TRIDENT, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), null, null, new ItemStack(Material.TRIDENT), null, null, SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), null}) + new ItemStack[] {null, SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), null, null, MaterialCompat.stack(XMaterial.TRIDENT), null, null, SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), null}) .register(plugin); new SoulboundItem(itemGroups.weapons, SlimefunItems.SOULBOUND_BOW, RecipeType.MAGIC_WORKBENCH, @@ -1263,7 +1265,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SoulboundItem(itemGroups.tools, SlimefunItems.SOULBOUND_SHOVEL, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), null, null, new ItemStack(Material.DIAMOND_SHOVEL), null, null, SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), null}) + new ItemStack[] {null, SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), null, null, MaterialCompat.stack(XMaterial.DIAMOND_SHOVEL), null, null, SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), null}) .register(plugin); new SoulboundItem(itemGroups.tools, SlimefunItems.SOULBOUND_HOE, RecipeType.MAGIC_WORKBENCH, @@ -1297,7 +1299,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new Juice(itemGroups.food, SlimefunItems.MELON_JUICE, RecipeType.JUICER, - new ItemStack[] {new ItemStack(Material.MELON_SLICE), null, null, null, null, null, null, null, null}) + new ItemStack[] {MaterialCompat.stack(XMaterial.MELON_SLICE), null, null, null, null, null, null, null, null}) .register(plugin); new Juice(itemGroups.food, SlimefunItems.PUMPKIN_JUICE, RecipeType.JUICER, @@ -1305,19 +1307,19 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new Juice(itemGroups.food, SlimefunItems.SWEET_BERRY_JUICE, RecipeType.JUICER, - new ItemStack[] {new ItemStack(Material.SWEET_BERRIES), null, null, null, null, null, null, null, null}) + new ItemStack[] {MaterialCompat.stack(XMaterial.SWEET_BERRIES), null, null, null, null, null, null, null, null}) .register(plugin); new Juice(itemGroups.food, SlimefunItems.GOLDEN_APPLE_JUICE, RecipeType.JUICER, new ItemStack[] {new ItemStack(Material.GOLDEN_APPLE), null, null, null, null, null, null, null, null}) .register(plugin); - new VanillaItem(itemGroups.food, new ItemStack(Material.ENCHANTED_GOLDEN_APPLE), "ENCHANTED_GOLDEN_APPLE", RecipeType.ENHANCED_CRAFTING_TABLE, + new VanillaItem(itemGroups.food, MaterialCompat.stack(XMaterial.ENCHANTED_GOLDEN_APPLE), "ENCHANTED_GOLDEN_APPLE", RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.GOLD_24K_BLOCK.item(), SlimefunItems.GOLD_24K_BLOCK.item(), SlimefunItems.GOLD_24K_BLOCK.item(), SlimefunItems.GOLD_24K_BLOCK.item(), new ItemStack(Material.APPLE), SlimefunItems.GOLD_24K_BLOCK.item(), SlimefunItems.GOLD_24K_BLOCK.item(), SlimefunItems.GOLD_24K_BLOCK.item(), SlimefunItems.GOLD_24K_BLOCK.item()}) .register(plugin); new BrokenSpawner(itemGroups.magicalResources, SlimefunItems.BROKEN_SPAWNER, new RecipeType(new NamespacedKey(plugin, "pickaxe_of_containment"), SlimefunItems.PICKAXE_OF_CONTAINMENT), - new ItemStack[] {null, null, null, null, new ItemStack(Material.SPAWNER), null, null, null, null}) + new ItemStack[] {null, null, null, null, MaterialCompat.stack(XMaterial.SPAWNER), null, null, null, null}) .register(plugin); new RepairedSpawner(itemGroups.magicalGadgets, SlimefunItems.REPAIRED_SPAWNER, RecipeType.ANCIENT_ALTAR, @@ -1394,7 +1396,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new BlockPlacer(itemGroups.basicMachines, SlimefunItems.BLOCK_PLACER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.GOLD_4K.item(), new ItemStack(Material.PISTON), SlimefunItems.GOLD_4K.item(), new ItemStack(Material.IRON_INGOT), SlimefunItems.ELECTRIC_MOTOR.item(), new ItemStack(Material.IRON_INGOT), SlimefunItems.GOLD_4K.item(), new ItemStack(Material.PISTON), SlimefunItems.GOLD_4K.item()}) + new ItemStack[] {SlimefunItems.GOLD_4K.item(), MaterialCompat.stack(XMaterial.PISTON), SlimefunItems.GOLD_4K.item(), new ItemStack(Material.IRON_INGOT), SlimefunItems.ELECTRIC_MOTOR.item(), new ItemStack(Material.IRON_INGOT), SlimefunItems.GOLD_4K.item(), MaterialCompat.stack(XMaterial.PISTON), SlimefunItems.GOLD_4K.item()}) .register(plugin); new TelepositionScroll(itemGroups.magicalGadgets, SlimefunItems.SCROLL_OF_DIMENSIONAL_TELEPOSITION, RecipeType.MAGIC_WORKBENCH, @@ -1402,7 +1404,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new ExplosiveBow(itemGroups.weapons, SlimefunItems.EXPLOSIVE_BOW, - new ItemStack[] {null, new ItemStack(Material.STICK), new ItemStack(Material.GUNPOWDER), SlimefunItems.STAFF_FIRE.item(), null, SlimefunItems.SULFATE.item(), null, new ItemStack(Material.STICK), new ItemStack(Material.GUNPOWDER)}) + new ItemStack[] {null, new ItemStack(Material.STICK), MaterialCompat.stack(XMaterial.GUNPOWDER), SlimefunItems.STAFF_FIRE.item(), null, SlimefunItems.SULFATE.item(), null, new ItemStack(Material.STICK), MaterialCompat.stack(XMaterial.GUNPOWDER)}) .register(plugin); new IcyBow(itemGroups.weapons, SlimefunItems.ICY_BOW, @@ -1410,11 +1412,11 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new KnowledgeTome(itemGroups.magicalGadgets, SlimefunItems.TOME_OF_KNOWLEDGE_SHARING, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, new ItemStack(Material.FEATHER), null, new ItemStack(Material.INK_SAC), SlimefunItems.MAGICAL_BOOK_COVER.item(), new ItemStack(Material.GLASS_BOTTLE), null, new ItemStack(Material.WRITABLE_BOOK), null}) + new ItemStack[] {null, new ItemStack(Material.FEATHER), null, MaterialCompat.stack(XMaterial.INK_SAC), SlimefunItems.MAGICAL_BOOK_COVER.item(), new ItemStack(Material.GLASS_BOTTLE), null, MaterialCompat.stack(XMaterial.WRITABLE_BOOK), null}) .register(plugin); new KnowledgeFlask(itemGroups.magicalGadgets, SlimefunItems.FLASK_OF_KNOWLEDGE, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, null, null, SlimefunItems.MAGIC_LUMP_2.item(), new ItemStack(Material.GLASS_PANE), SlimefunItems.MAGIC_LUMP_2.item(), null, SlimefunItems.MAGIC_LUMP_2.item(), null}, + new ItemStack[] {null, null, null, SlimefunItems.MAGIC_LUMP_2.item(), MaterialCompat.stack(XMaterial.GLASS_PANE), SlimefunItems.MAGIC_LUMP_2.item(), null, SlimefunItems.MAGIC_LUMP_2.item(), null}, new SlimefunItemStack(SlimefunItems.FLASK_OF_KNOWLEDGE, 8).item()) .register(plugin); @@ -1432,7 +1434,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new Juice(itemGroups.christmas, SlimefunItems.CHRISTMAS_CHOCOLATE_MILK, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.CHRISTMAS_MILK.item(), new ItemStack(Material.COCOA_BEANS), null, null, null, null, null, null, null}, + new ItemStack[] {SlimefunItems.CHRISTMAS_MILK.item(), MaterialCompat.stack(XMaterial.COCOA_BEANS), null, null, null, null, null, null, null}, new SlimefunItemStack(SlimefunItems.CHRISTMAS_CHOCOLATE_MILK, 2).item()) .register(plugin); @@ -1447,7 +1449,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunItem(itemGroups.christmas, SlimefunItems.CHRISTMAS_COOKIE, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.COOKIE), new ItemStack(Material.SUGAR), new ItemStack(Material.LIME_DYE), null, null, null, null, null, null}, + new ItemStack[] {new ItemStack(Material.COOKIE), new ItemStack(Material.SUGAR), MaterialCompat.stack(XMaterial.LIME_DYE), null, null, null, null, null, null}, new SlimefunItemStack(SlimefunItems.CHRISTMAS_COOKIE, 16).item()) .register(plugin); @@ -1481,12 +1483,12 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunItem(itemGroups.christmas, SlimefunItems.CHRISTMAS_CHOCOLATE_APPLE, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, new ItemStack(Material.COCOA_BEANS), null, null, new ItemStack(Material.APPLE), null, null, new ItemStack(Material.STICK), null}, + new ItemStack[] {null, MaterialCompat.stack(XMaterial.COCOA_BEANS), null, null, new ItemStack(Material.APPLE), null, null, new ItemStack(Material.STICK), null}, new SlimefunItemStack(SlimefunItems.CHRISTMAS_CHOCOLATE_APPLE, 2).item()) .register(plugin); new ChristmasPresent(itemGroups.christmas, SlimefunItems.CHRISTMAS_PRESENT, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, new ItemStack(Material.NAME_TAG), null, new ItemStack(Material.RED_WOOL), new ItemStack(Material.GREEN_WOOL), new ItemStack(Material.RED_WOOL), new ItemStack(Material.RED_WOOL), new ItemStack(Material.GREEN_WOOL), new ItemStack(Material.RED_WOOL)}, + new ItemStack[] {null, new ItemStack(Material.NAME_TAG), null, MaterialCompat.stack(XMaterial.RED_WOOL), MaterialCompat.stack(XMaterial.GREEN_WOOL), MaterialCompat.stack(XMaterial.RED_WOOL), MaterialCompat.stack(XMaterial.RED_WOOL), MaterialCompat.stack(XMaterial.GREEN_WOOL), MaterialCompat.stack(XMaterial.RED_WOOL)}, new SlimefunItemStack(SlimefunItems.CHRISTMAS_HOT_CHOCOLATE, 1).item(), new SlimefunItemStack(SlimefunItems.CHRISTMAS_CHOCOLATE_APPLE, 4).item(), new SlimefunItemStack(SlimefunItems.CHRISTMAS_CARAMEL_APPLE, 4).item(), @@ -1512,7 +1514,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new EasterEgg(itemGroups.easter, SlimefunItems.EASTER_EGG, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, null, null, new ItemStack(Material.LIME_DYE), new ItemStack(Material.EGG), new ItemStack(Material.PURPLE_DYE), null, null, null}, + new ItemStack[] {null, null, null, MaterialCompat.stack(XMaterial.LIME_DYE), new ItemStack(Material.EGG), MaterialCompat.stack(XMaterial.PURPLE_DYE), null, null, null}, new SlimefunItemStack(SlimefunItems.EASTER_EGG, 2).item(), // Gifts: new SlimefunItemStack(SlimefunItems.EASTER_CARROT_PIE, 4).item(), @@ -1553,7 +1555,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new AncientAltar(itemGroups.magicalGadgets, SlimefunItems.ANCIENT_ALTAR, RecipeType.MAGIC_WORKBENCH, - new ItemStack[] {null, new ItemStack(Material.ENCHANTING_TABLE), null, SlimefunItems.MAGIC_LUMP_3.item(), SlimefunItems.GOLD_8K.item(), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.OBSIDIAN), SlimefunItems.GOLD_8K.item(), new ItemStack(Material.OBSIDIAN)}) + new ItemStack[] {null, MaterialCompat.stack(XMaterial.ENCHANTING_TABLE), null, SlimefunItems.MAGIC_LUMP_3.item(), SlimefunItems.GOLD_8K.item(), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.OBSIDIAN), SlimefunItems.GOLD_8K.item(), new ItemStack(Material.OBSIDIAN)}) .register(plugin); new EnergyRegulator(itemGroups.electricity, SlimefunItems.ENERGY_REGULATOR, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -1566,7 +1568,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new SlimefunItem(itemGroups.misc, SlimefunItems.DUCT_TAPE, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.ALUMINUM_DUST.item(), SlimefunItems.ALUMINUM_DUST.item(), SlimefunItems.ALUMINUM_DUST.item(), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER)}, + new ItemStack[] {SlimefunItems.ALUMINUM_DUST.item(), SlimefunItems.ALUMINUM_DUST.item(), SlimefunItems.ALUMINUM_DUST.item(), new ItemStack(Material.SLIME_BALL), MaterialCompat.stack(XMaterial.WHITE_WOOL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER)}, new SlimefunItemStack(SlimefunItems.DUCT_TAPE, 2).item()) .register(plugin); @@ -1611,7 +1613,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new ChargingBench(itemGroups.electricity, SlimefunItems.CHARGING_BENCH, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET.item(), null, SlimefunItems.BATTERY.item(), new ItemStack(Material.CRAFTING_TABLE), SlimefunItems.BATTERY.item(), null, SlimefunItems.SMALL_CAPACITOR.item(), null}) + new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET.item(), null, SlimefunItems.BATTERY.item(), MaterialCompat.stack(XMaterial.CRAFTING_TABLE), SlimefunItems.BATTERY.item(), null, SlimefunItems.SMALL_CAPACITOR.item(), null}) .setCapacity(128) .setEnergyConsumption(10) .setProcessingSpeed(1) @@ -1771,7 +1773,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new CoalGenerator(itemGroups.electricity, SlimefunItems.COAL_GENERATOR_2, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.MAGMA_BLOCK), SlimefunItems.HEATING_COIL.item(), new ItemStack(Material.MAGMA_BLOCK), SlimefunItems.HARDENED_METAL_INGOT.item(), SlimefunItems.COAL_GENERATOR.item(), SlimefunItems.HARDENED_METAL_INGOT.item(), null, SlimefunItems.ELECTRIC_MOTOR.item(), null}) + new ItemStack[] {MaterialCompat.stack(XMaterial.MAGMA_BLOCK), SlimefunItems.HEATING_COIL.item(), MaterialCompat.stack(XMaterial.MAGMA_BLOCK), SlimefunItems.HARDENED_METAL_INGOT.item(), SlimefunItems.COAL_GENERATOR.item(), SlimefunItems.HARDENED_METAL_INGOT.item(), null, SlimefunItems.ELECTRIC_MOTOR.item(), null}) .setCapacity(256) .setEnergyProduction(15) .register(plugin); @@ -1783,7 +1785,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new AutoDrier(itemGroups.electricity, SlimefunItems.AUTO_DRIER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[]{null, null, null, SlimefunItems.HEATING_COIL.item(), new ItemStack(Material.SMOKER), SlimefunItems.HEATING_COIL.item(), null, new ItemStack(Material.CAMPFIRE), null}) + new ItemStack[]{null, null, null, SlimefunItems.HEATING_COIL.item(), MaterialCompat.stack(XMaterial.SMOKER), SlimefunItems.HEATING_COIL.item(), null, MaterialCompat.stack(XMaterial.CAMPFIRE), null}) .setCapacity(128) .setEnergyConsumption(5) .setProcessingSpeed(1) @@ -1797,14 +1799,14 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new ElectricPress(itemGroups.electricity, SlimefunItems.ELECTRIC_PRESS, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.PISTON), SlimefunItems.ELECTRIC_MOTOR.item(), new ItemStack(Material.PISTON), null, SlimefunItems.MEDIUM_CAPACITOR.item(), null, SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item()}) + new ItemStack[] {MaterialCompat.stack(XMaterial.PISTON), SlimefunItems.ELECTRIC_MOTOR.item(), MaterialCompat.stack(XMaterial.PISTON), null, SlimefunItems.MEDIUM_CAPACITOR.item(), null, SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item()}) .setCapacity(256) .setEnergyConsumption(8) .setProcessingSpeed(1) .register(plugin); new ElectricPress(itemGroups.electricity, SlimefunItems.ELECTRIC_PRESS_2, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.STICKY_PISTON), SlimefunItems.ELECTRIC_PRESS.item(), new ItemStack(Material.STICKY_PISTON), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.BIG_CAPACITOR.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item()}) + new ItemStack[] {MaterialCompat.stack(XMaterial.STICKY_PISTON), SlimefunItems.ELECTRIC_PRESS.item(), MaterialCompat.stack(XMaterial.STICKY_PISTON), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.BIG_CAPACITOR.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item(), SlimefunItems.DAMASCUS_STEEL_INGOT.item()}) .setCapacity(1024) .setEnergyConsumption(20) .setProcessingSpeed(3) @@ -1821,7 +1823,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new AutoEnchanter(itemGroups.electricity, SlimefunItems.AUTO_ENCHANTER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, new ItemStack(Material.ENCHANTING_TABLE), null, SlimefunItems.CARBONADO.item(), SlimefunItems.ELECTRIC_MOTOR.item(), SlimefunItems.CARBONADO.item(), SlimefunItems.WITHER_PROOF_OBSIDIAN.item(), SlimefunItems.WITHER_PROOF_OBSIDIAN.item(), SlimefunItems.WITHER_PROOF_OBSIDIAN.item()}) + new ItemStack[] {null, MaterialCompat.stack(XMaterial.ENCHANTING_TABLE), null, SlimefunItems.CARBONADO.item(), SlimefunItems.ELECTRIC_MOTOR.item(), SlimefunItems.CARBONADO.item(), SlimefunItems.WITHER_PROOF_OBSIDIAN.item(), SlimefunItems.WITHER_PROOF_OBSIDIAN.item(), SlimefunItems.WITHER_PROOF_OBSIDIAN.item()}) .setCapacity(128) .setEnergyConsumption(9) .setProcessingSpeed(1) @@ -1863,7 +1865,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new BookBinder(itemGroups.electricity, SlimefunItems.BOOK_BINDER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, new ItemStack(Material.ENCHANTING_TABLE), null, new ItemStack(Material.BOOKSHELF), SlimefunItems.HARDENED_METAL_INGOT.item(), new ItemStack(Material.BOOKSHELF), SlimefunItems.SYNTHETIC_SAPPHIRE.item(), SlimefunItems.SMALL_CAPACITOR.item(), SlimefunItems.SYNTHETIC_SAPPHIRE.item()}) + new ItemStack[] {null, MaterialCompat.stack(XMaterial.ENCHANTING_TABLE), null, new ItemStack(Material.BOOKSHELF), SlimefunItems.HARDENED_METAL_INGOT.item(), new ItemStack(Material.BOOKSHELF), SlimefunItems.SYNTHETIC_SAPPHIRE.item(), SlimefunItems.SMALL_CAPACITOR.item(), SlimefunItems.SYNTHETIC_SAPPHIRE.item()}) .setCapacity(256) .setEnergyConsumption(16) .setProcessingSpeed(1) @@ -1879,7 +1881,7 @@ public static void setup(@Nonnull Slimefun plugin) { .register(plugin); new UnplaceableBlock(itemGroups.technicalComponents, SlimefunItems.ANDROID_MEMORY_CORE, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.BRASS_INGOT.item(), new ItemStack(Material.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT.item(), SlimefunItems.POWER_CRYSTAL.item(), SlimefunItems.TIN_DUST.item(), SlimefunItems.POWER_CRYSTAL.item(), SlimefunItems.BRASS_INGOT.item(), new ItemStack(Material.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT.item()}) + new ItemStack[] {SlimefunItems.BRASS_INGOT.item(), MaterialCompat.stack(XMaterial.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT.item(), SlimefunItems.POWER_CRYSTAL.item(), SlimefunItems.TIN_DUST.item(), SlimefunItems.POWER_CRYSTAL.item(), SlimefunItems.BRASS_INGOT.item(), MaterialCompat.stack(XMaterial.ORANGE_STAINED_GLASS), SlimefunItems.BRASS_INGOT.item()}) .register(plugin); new GPSTransmitter(itemGroups.gps, 1, SlimefunItems.GPS_TRANSMITTER, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -1947,7 +1949,7 @@ public int getEnergyConsumption() { .register(plugin); new GPSMarkerTool(itemGroups.gps, SlimefunItems.GPS_MARKER_TOOL, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET.item(), null, new ItemStack(Material.LAPIS_LAZULI), SlimefunItems.BASIC_CIRCUIT_BOARD.item(), new ItemStack(Material.LAPIS_LAZULI), new ItemStack(Material.REDSTONE), SlimefunItems.REDSTONE_ALLOY.item(), new ItemStack(Material.REDSTONE)}) + new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET.item(), null, MaterialCompat.stack(XMaterial.LAPIS_LAZULI), SlimefunItems.BASIC_CIRCUIT_BOARD.item(), MaterialCompat.stack(XMaterial.LAPIS_LAZULI), new ItemStack(Material.REDSTONE), SlimefunItems.REDSTONE_ALLOY.item(), new ItemStack(Material.REDSTONE)}) .register(plugin); new SlimefunItem(itemGroups.gps, SlimefunItems.GPS_EMERGENCY_TRANSMITTER, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -1955,11 +1957,11 @@ public int getEnergyConsumption() { .register(plugin); new AndroidInterface(itemGroups.androids, SlimefunItems.ANDROID_INTERFACE_ITEMS, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.BASIC_CIRCUIT_BOARD.item(), new ItemStack(Material.BLUE_STAINED_GLASS), SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item()}) + new ItemStack[] {SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.BASIC_CIRCUIT_BOARD.item(), MaterialCompat.stack(XMaterial.BLUE_STAINED_GLASS), SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item()}) .register(plugin); new AndroidInterface(itemGroups.androids, SlimefunItems.ANDROID_INTERFACE_FUEL, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item(), new ItemStack(Material.RED_STAINED_GLASS), SlimefunItems.BASIC_CIRCUIT_BOARD.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item()}) + new ItemStack[] {SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item(), MaterialCompat.stack(XMaterial.RED_STAINED_GLASS), SlimefunItems.BASIC_CIRCUIT_BOARD.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item(), SlimefunItems.STEEL_INGOT.item(), SlimefunItems.PLASTIC_SHEET.item()}) .register(plugin); new ProgrammableAndroid(itemGroups.androids, 1, SlimefunItems.PROGRAMMABLE_ANDROID, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -2029,27 +2031,27 @@ public int getEnergyConsumption() { .register(plugin); new ElementalRune(itemGroups.magicalResources, SlimefunItems.FIRE_RUNE, - new ItemStack[] {new ItemStack(Material.FIRE_CHARGE), SlimefunItems.MAGIC_LUMP_2.item(), new ItemStack(Material.FIRE_CHARGE), new ItemStack(Material.BLAZE_POWDER), SlimefunItems.EARTH_RUNE.item(), new ItemStack(Material.FLINT_AND_STEEL), new ItemStack(Material.FIRE_CHARGE), SlimefunItems.MAGIC_LUMP_2.item(), new ItemStack(Material.FIRE_CHARGE)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.FIRE_CHARGE), SlimefunItems.MAGIC_LUMP_2.item(), MaterialCompat.stack(XMaterial.FIRE_CHARGE), new ItemStack(Material.BLAZE_POWDER), SlimefunItems.EARTH_RUNE.item(), new ItemStack(Material.FLINT_AND_STEEL), MaterialCompat.stack(XMaterial.FIRE_CHARGE), SlimefunItems.MAGIC_LUMP_2.item(), MaterialCompat.stack(XMaterial.FIRE_CHARGE)}, new SlimefunItemStack(SlimefunItems.FIRE_RUNE, 4).item()) .register(plugin); new ElementalRune(itemGroups.magicalResources, SlimefunItems.WATER_RUNE, - new ItemStack[] {new ItemStack(Material.SALMON), SlimefunItems.MAGIC_LUMP_2.item(), new ItemStack(Material.WATER_BUCKET), new ItemStack(Material.SAND), SlimefunItems.BLANK_RUNE.item(), new ItemStack(Material.SAND), new ItemStack(Material.WATER_BUCKET), SlimefunItems.MAGIC_LUMP_2.item(), new ItemStack(Material.COD)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.SALMON), SlimefunItems.MAGIC_LUMP_2.item(), new ItemStack(Material.WATER_BUCKET), new ItemStack(Material.SAND), SlimefunItems.BLANK_RUNE.item(), new ItemStack(Material.SAND), new ItemStack(Material.WATER_BUCKET), SlimefunItems.MAGIC_LUMP_2.item(), MaterialCompat.stack(XMaterial.COD)}, new SlimefunItemStack(SlimefunItems.WATER_RUNE, 4).item()) .register(plugin); new ElementalRune(itemGroups.magicalResources, SlimefunItems.ENDER_RUNE, - new ItemStack[] {new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_3.item(), new ItemStack(Material.ENDER_PEARL), new ItemStack(Material.ENDER_EYE), SlimefunItems.BLANK_RUNE.item(), new ItemStack(Material.ENDER_EYE), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_3.item(), new ItemStack(Material.ENDER_PEARL)}, + new ItemStack[] {new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_3.item(), new ItemStack(Material.ENDER_PEARL), MaterialCompat.stack(XMaterial.ENDER_EYE), SlimefunItems.BLANK_RUNE.item(), MaterialCompat.stack(XMaterial.ENDER_EYE), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_3.item(), new ItemStack(Material.ENDER_PEARL)}, new SlimefunItemStack(SlimefunItems.ENDER_RUNE, 6).item()) .register(plugin); new ElementalRune(itemGroups.magicalResources, SlimefunItems.LIGHTNING_RUNE, - new ItemStack[] {new ItemStack(Material.IRON_INGOT), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.IRON_INGOT), SlimefunItems.AIR_RUNE.item(), new ItemStack(Material.PHANTOM_MEMBRANE), SlimefunItems.WATER_RUNE.item(), new ItemStack(Material.IRON_INGOT), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.IRON_INGOT)}, + new ItemStack[] {new ItemStack(Material.IRON_INGOT), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.IRON_INGOT), SlimefunItems.AIR_RUNE.item(), MaterialCompat.stack(XMaterial.PHANTOM_MEMBRANE), SlimefunItems.WATER_RUNE.item(), new ItemStack(Material.IRON_INGOT), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.IRON_INGOT)}, new SlimefunItemStack(SlimefunItems.LIGHTNING_RUNE, 4).item()) .register(plugin); new ElementalRune(itemGroups.magicalResources, SlimefunItems.RAINBOW_RUNE, - new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.CYAN_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.ENDER_RUNE.item(), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.YELLOW_DYE), SlimefunItems.ENDER_LUMP_3.item(), new ItemStack(Material.MAGENTA_DYE)}) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), SlimefunItems.MAGIC_LUMP_3.item(), MaterialCompat.stack(XMaterial.CYAN_DYE), MaterialCompat.stack(XMaterial.WHITE_WOOL), SlimefunItems.ENDER_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.YELLOW_DYE), SlimefunItems.ENDER_LUMP_3.item(), MaterialCompat.stack(XMaterial.MAGENTA_DYE)}) .register(plugin); new SoulboundRune(itemGroups.magicalResources, SlimefunItems.SOULBOUND_RUNE, RecipeType.ANCIENT_ALTAR, @@ -2061,158 +2063,158 @@ public int getEnergyConsumption() { .register(plugin); new InfernalBonemeal(itemGroups.magicalGadgets, SlimefunItems.INFERNAL_BONEMEAL, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.NETHER_WART), SlimefunItems.EARTH_RUNE.item(), new ItemStack(Material.NETHER_WART), SlimefunItems.MAGIC_LUMP_2.item(), new ItemStack(Material.BONE_MEAL), SlimefunItems.MAGIC_LUMP_2.item(), new ItemStack(Material.NETHER_WART), new ItemStack(Material.BLAZE_POWDER), new ItemStack(Material.NETHER_WART)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.NETHER_WART), SlimefunItems.EARTH_RUNE.item(), MaterialCompat.stack(XMaterial.NETHER_WART), SlimefunItems.MAGIC_LUMP_2.item(), MaterialCompat.stack(XMaterial.BONE_MEAL), SlimefunItems.MAGIC_LUMP_2.item(), MaterialCompat.stack(XMaterial.NETHER_WART), new ItemStack(Material.BLAZE_POWDER), MaterialCompat.stack(XMaterial.NETHER_WART)}, new SlimefunItemStack(SlimefunItems.INFERNAL_BONEMEAL, 8).item()) .register(plugin); new SlimefunItem(itemGroups.magicalGadgets, SlimefunItems.ELYTRA_SCALE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.AIR_RUNE.item(), SlimefunItems.ENDER_LUMP_3.item(), new ItemStack(Material.PHANTOM_MEMBRANE), new ItemStack(Material.FEATHER), new ItemStack(Material.PHANTOM_MEMBRANE), SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.AIR_RUNE.item(), SlimefunItems.ENDER_LUMP_3.item()}) + new ItemStack[] {SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.AIR_RUNE.item(), SlimefunItems.ENDER_LUMP_3.item(), MaterialCompat.stack(XMaterial.PHANTOM_MEMBRANE), new ItemStack(Material.FEATHER), MaterialCompat.stack(XMaterial.PHANTOM_MEMBRANE), SlimefunItems.ENDER_LUMP_3.item(), SlimefunItems.AIR_RUNE.item(), SlimefunItems.ENDER_LUMP_3.item()}) .register(plugin); - new VanillaItem(itemGroups.magicalGadgets, new ItemStack(Material.ELYTRA), "ELYTRA", RecipeType.ANCIENT_ALTAR, + new VanillaItem(itemGroups.magicalGadgets, MaterialCompat.stack(XMaterial.ELYTRA), "ELYTRA", RecipeType.ANCIENT_ALTAR, new ItemStack[] {SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.AIR_RUNE.item(), SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.AIR_RUNE.item(), new ItemStack(Material.LEATHER_CHESTPLATE), SlimefunItems.AIR_RUNE.item(), SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.AIR_RUNE.item(), SlimefunItems.ELYTRA_SCALE.item()}) .register(plugin); new SlimefunItem(itemGroups.magicalGadgets, SlimefunItems.INFUSED_ELYTRA, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), new ItemStack(Material.ELYTRA), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item()}) + new ItemStack[] {SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), MaterialCompat.stack(XMaterial.ELYTRA), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item()}) .register(plugin); new SoulboundItem(itemGroups.magicalGadgets, SlimefunItems.SOULBOUND_ELYTRA, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ELYTRA_SCALE.item(), new ItemStack(Material.ELYTRA), SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item()}) + new ItemStack[] {SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ELYTRA_SCALE.item(), MaterialCompat.stack(XMaterial.ELYTRA), SlimefunItems.ELYTRA_SCALE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item(), SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), SlimefunItems.FLASK_OF_KNOWLEDGE.item()}) .register(plugin); - new VanillaItem(itemGroups.magicalGadgets, new ItemStack(Material.TRIDENT), "TRIDENT", RecipeType.ANCIENT_ALTAR, - new ItemStack[] { new ItemStack(Material.NAUTILUS_SHELL), SlimefunItems.REINFORCED_ALLOY_INGOT.item(), new ItemStack(Material.NAUTILUS_SHELL), SlimefunItems.STAFF_WATER.item(), new ItemStack(Material.DIAMOND_SWORD), SlimefunItems.STAFF_WATER.item(), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.NETHER_STAR), SlimefunItems.MAGIC_LUMP_3.item()}) + new VanillaItem(itemGroups.magicalGadgets, MaterialCompat.stack(XMaterial.TRIDENT), "TRIDENT", RecipeType.ANCIENT_ALTAR, + new ItemStack[] { MaterialCompat.stack(XMaterial.NAUTILUS_SHELL), SlimefunItems.REINFORCED_ALLOY_INGOT.item(), MaterialCompat.stack(XMaterial.NAUTILUS_SHELL), SlimefunItems.STAFF_WATER.item(), new ItemStack(Material.DIAMOND_SWORD), SlimefunItems.STAFF_WATER.item(), SlimefunItems.MAGIC_LUMP_3.item(), new ItemStack(Material.NETHER_STAR), SlimefunItems.MAGIC_LUMP_3.item()}) .register(plugin); - new VanillaItem(itemGroups.magicalGadgets, new ItemStack(Material.TOTEM_OF_UNDYING), "TOTEM_OF_UNDYING", RecipeType.ANCIENT_ALTAR, + new VanillaItem(itemGroups.magicalGadgets, MaterialCompat.stack(XMaterial.TOTEM_OF_UNDYING), "TOTEM_OF_UNDYING", RecipeType.ANCIENT_ALTAR, new ItemStack[] {SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), new ItemStack(Material.EMERALD_BLOCK), SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), SlimefunItems.MAGIC_LUMP_3.item(), SlimefunItems.COMMON_TALISMAN.item(), SlimefunItems.MAGIC_LUMP_3.item(), SlimefunItems.ESSENCE_OF_AFTERLIFE.item(), new ItemStack(Material.EMERALD_BLOCK), SlimefunItems.ESSENCE_OF_AFTERLIFE.item()}) .register(plugin); new RainbowBlock(itemGroups.magicalGadgets, SlimefunItems.RAINBOW_WOOL, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.WHITE_WOOL)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.WHITE_WOOL)}, new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL, 8).item(), new RainbowTickHandler(ColoredMaterial.WOOL)) .register(plugin); new RainbowBlock(itemGroups.magicalGadgets, SlimefunItems.RAINBOW_GLASS, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.WHITE_STAINED_GLASS)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS)}, new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS, 8).item(), new RainbowTickHandler(ColoredMaterial.STAINED_GLASS)) .register(plugin); new RainbowBlock(itemGroups.magicalGadgets, SlimefunItems.RAINBOW_GLASS_PANE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE)}, new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE, 8).item(), new RainbowTickHandler(ColoredMaterial.STAINED_GLASS_PANE)) .register(plugin); new RainbowBlock(itemGroups.magicalGadgets, SlimefunItems.RAINBOW_CLAY, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.WHITE_TERRACOTTA)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA)}, new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY, 8).item(), new RainbowTickHandler(ColoredMaterial.TERRACOTTA)) .register(plugin); new RainbowBlock(itemGroups.magicalGadgets, SlimefunItems.RAINBOW_CONCRETE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.WHITE_CONCRETE)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE)}, new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE, 8).item(), new RainbowTickHandler(ColoredMaterial.CONCRETE)) .register(plugin); new RainbowBlock(itemGroups.magicalGadgets, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA)}, new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA, 8).item(), new RainbowTickHandler(ColoredMaterial.GLAZED_TERRACOTTA)) .register(plugin); // Christmas new RainbowBlock(itemGroups.christmas, SlimefunItems.RAINBOW_WOOL_XMAS, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_XMAS, 2).item(), new RainbowTickHandler(Material.RED_WOOL, Material.GREEN_WOOL)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.GREEN_DYE), MaterialCompat.stack(XMaterial.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_XMAS, 2).item(), new RainbowTickHandler(XMaterial.RED_WOOL.parseMaterial(), XMaterial.GREEN_WOOL.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.christmas, SlimefunItems.RAINBOW_GLASS_XMAS, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_XMAS, 2).item(), new RainbowTickHandler(Material.RED_STAINED_GLASS, Material.GREEN_STAINED_GLASS)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.GREEN_DYE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_XMAS, 2).item(), new RainbowTickHandler(XMaterial.RED_STAINED_GLASS.parseMaterial(), XMaterial.GREEN_STAINED_GLASS.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.christmas, SlimefunItems.RAINBOW_GLASS_PANE_XMAS, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_XMAS, 2).item(), new RainbowTickHandler(Material.RED_STAINED_GLASS_PANE, Material.GREEN_STAINED_GLASS_PANE)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.GREEN_DYE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_XMAS, 2).item(), new RainbowTickHandler(XMaterial.RED_STAINED_GLASS_PANE.parseMaterial(), XMaterial.GREEN_STAINED_GLASS_PANE.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.christmas, SlimefunItems.RAINBOW_CLAY_XMAS, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_XMAS, 2).item(), new RainbowTickHandler(Material.RED_TERRACOTTA, Material.GREEN_TERRACOTTA)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.GREEN_DYE), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_XMAS, 2).item(), new RainbowTickHandler(XMaterial.RED_TERRACOTTA.parseMaterial(), XMaterial.GREEN_TERRACOTTA.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.christmas, SlimefunItems.RAINBOW_CONCRETE_XMAS, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_XMAS, 2).item(), new RainbowTickHandler(Material.RED_CONCRETE, Material.GREEN_CONCRETE)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.GREEN_DYE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_XMAS, 2).item(), new RainbowTickHandler(XMaterial.RED_CONCRETE.parseMaterial(), XMaterial.GREEN_CONCRETE.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.christmas, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_XMAS, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_XMAS, 2).item(), new RainbowTickHandler(Material.RED_GLAZED_TERRACOTTA, Material.GREEN_GLAZED_TERRACOTTA)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.GREEN_DYE), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE.item(), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_XMAS, 2).item(), new RainbowTickHandler(XMaterial.RED_GLAZED_TERRACOTTA.parseMaterial(), XMaterial.GREEN_GLAZED_TERRACOTTA.parseMaterial())) .register(plugin); // Valentines Day new RainbowBlock(itemGroups.valentinesDay, SlimefunItems.RAINBOW_WOOL_VALENTINE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_VALENTINE, 2).item(), new RainbowTickHandler(Material.MAGENTA_WOOL, Material.PINK_WOOL)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_VALENTINE, 2).item(), new RainbowTickHandler(XMaterial.MAGENTA_WOOL.parseMaterial(), XMaterial.PINK_WOOL.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.valentinesDay, SlimefunItems.RAINBOW_GLASS_VALENTINE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_VALENTINE, 2).item(), new RainbowTickHandler(Material.MAGENTA_STAINED_GLASS, Material.PINK_STAINED_GLASS)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_VALENTINE, 2).item(), new RainbowTickHandler(XMaterial.MAGENTA_STAINED_GLASS.parseMaterial(), XMaterial.PINK_STAINED_GLASS.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.valentinesDay, SlimefunItems.RAINBOW_GLASS_PANE_VALENTINE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_VALENTINE, 2).item(), new RainbowTickHandler(Material.MAGENTA_STAINED_GLASS_PANE, Material.PINK_STAINED_GLASS_PANE)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_VALENTINE, 2).item(), new RainbowTickHandler(XMaterial.MAGENTA_STAINED_GLASS_PANE.parseMaterial(), XMaterial.PINK_STAINED_GLASS_PANE.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.valentinesDay, SlimefunItems.RAINBOW_CLAY_VALENTINE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_VALENTINE, 2).item(), new RainbowTickHandler(Material.MAGENTA_TERRACOTTA, Material.PINK_TERRACOTTA)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_VALENTINE, 2).item(), new RainbowTickHandler(XMaterial.MAGENTA_TERRACOTTA.parseMaterial(), XMaterial.PINK_TERRACOTTA.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.valentinesDay, SlimefunItems.RAINBOW_CONCRETE_VALENTINE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_VALENTINE, 2).item(), new RainbowTickHandler(Material.MAGENTA_CONCRETE, Material.PINK_CONCRETE)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_VALENTINE, 2).item(), new RainbowTickHandler(XMaterial.MAGENTA_CONCRETE.parseMaterial(), XMaterial.PINK_CONCRETE.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.valentinesDay, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_VALENTINE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_VALENTINE, 2).item(), new RainbowTickHandler(Material.MAGENTA_GLAZED_TERRACOTTA, Material.PINK_GLAZED_TERRACOTTA)) + new ItemStack[] {MaterialCompat.stack(XMaterial.RED_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.PINK_DYE), MaterialCompat.stack(XMaterial.POPPY), MaterialCompat.stack(XMaterial.RED_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_VALENTINE, 2).item(), new RainbowTickHandler(XMaterial.MAGENTA_GLAZED_TERRACOTTA.parseMaterial(), XMaterial.PINK_GLAZED_TERRACOTTA.parseMaterial())) .register(plugin); // Halloween new RainbowBlock(itemGroups.halloween, SlimefunItems.RAINBOW_WOOL_HALLOWEEN, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_HALLOWEEN, 2).item(), new RainbowTickHandler(Material.ORANGE_WOOL, Material.BLACK_WOOL)) + new ItemStack[] {MaterialCompat.stack(XMaterial.ORANGE_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.BLACK_DYE), MaterialCompat.stack(XMaterial.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_WOOL), MaterialCompat.stack(XMaterial.BLACK_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.ORANGE_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_HALLOWEEN, 2).item(), new RainbowTickHandler(XMaterial.ORANGE_WOOL.parseMaterial(), XMaterial.BLACK_WOOL.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.halloween, SlimefunItems.RAINBOW_GLASS_HALLOWEEN, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_HALLOWEEN, 2).item(), new RainbowTickHandler(Material.ORANGE_STAINED_GLASS, Material.BLACK_STAINED_GLASS)) + new ItemStack[] {MaterialCompat.stack(XMaterial.ORANGE_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.BLACK_DYE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS), MaterialCompat.stack(XMaterial.BLACK_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.ORANGE_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_HALLOWEEN, 2).item(), new RainbowTickHandler(XMaterial.ORANGE_STAINED_GLASS.parseMaterial(), XMaterial.BLACK_STAINED_GLASS.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.halloween, SlimefunItems.RAINBOW_GLASS_PANE_HALLOWEEN, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_HALLOWEEN, 2).item(), new RainbowTickHandler(Material.ORANGE_STAINED_GLASS_PANE, Material.BLACK_STAINED_GLASS_PANE)) + new ItemStack[] {MaterialCompat.stack(XMaterial.ORANGE_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.BLACK_DYE), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_STAINED_GLASS_PANE), MaterialCompat.stack(XMaterial.BLACK_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.ORANGE_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_HALLOWEEN, 2).item(), new RainbowTickHandler(XMaterial.ORANGE_STAINED_GLASS_PANE.parseMaterial(), XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.halloween, SlimefunItems.RAINBOW_CLAY_HALLOWEEN, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_HALLOWEEN, 2).item(), new RainbowTickHandler(Material.ORANGE_TERRACOTTA, Material.BLACK_TERRACOTTA)) + new ItemStack[] {MaterialCompat.stack(XMaterial.ORANGE_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.BLACK_DYE), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_TERRACOTTA), MaterialCompat.stack(XMaterial.BLACK_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.ORANGE_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_HALLOWEEN, 2).item(), new RainbowTickHandler(XMaterial.ORANGE_TERRACOTTA.parseMaterial(), XMaterial.BLACK_TERRACOTTA.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.halloween, SlimefunItems.RAINBOW_CONCRETE_HALLOWEEN, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_HALLOWEEN, 2).item(), new RainbowTickHandler(Material.ORANGE_CONCRETE, Material.BLACK_CONCRETE)) + new ItemStack[] {MaterialCompat.stack(XMaterial.ORANGE_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.BLACK_DYE), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_CONCRETE), MaterialCompat.stack(XMaterial.BLACK_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.ORANGE_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_HALLOWEEN, 2).item(), new RainbowTickHandler(XMaterial.ORANGE_CONCRETE.parseMaterial(), XMaterial.BLACK_CONCRETE.parseMaterial())) .register(plugin); new RainbowBlock(itemGroups.halloween, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)}, - new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN, 2).item(), new RainbowTickHandler(Material.ORANGE_GLAZED_TERRACOTTA, Material.BLACK_GLAZED_TERRACOTTA)) + new ItemStack[] {MaterialCompat.stack(XMaterial.ORANGE_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.BLACK_DYE), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE.item(), MaterialCompat.stack(XMaterial.WHITE_GLAZED_TERRACOTTA), MaterialCompat.stack(XMaterial.BLACK_DYE), new ItemStack(Material.PUMPKIN), MaterialCompat.stack(XMaterial.ORANGE_DYE)}, + new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN, 2).item(), new RainbowTickHandler(XMaterial.ORANGE_GLAZED_TERRACOTTA.parseMaterial(), XMaterial.BLACK_GLAZED_TERRACOTTA.parseMaterial())) .register(plugin); new WitherProofBlock(itemGroups.technicalComponents, SlimefunItems.WITHER_PROOF_GLASS, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -2255,7 +2257,7 @@ public int getEnergyConsumption() { .register(plugin); new Refinery(itemGroups.electricity, SlimefunItems.REFINERY, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.HARDENED_GLASS.item(), SlimefunItems.REDSTONE_ALLOY.item(), SlimefunItems.HARDENED_GLASS.item(), SlimefunItems.HARDENED_GLASS.item(), SlimefunItems.REDSTONE_ALLOY.item(), SlimefunItems.HARDENED_GLASS.item(), new ItemStack(Material.PISTON), SlimefunItems.ELECTRIC_MOTOR.item(), new ItemStack(Material.PISTON)}) + new ItemStack[] {SlimefunItems.HARDENED_GLASS.item(), SlimefunItems.REDSTONE_ALLOY.item(), SlimefunItems.HARDENED_GLASS.item(), SlimefunItems.HARDENED_GLASS.item(), SlimefunItems.REDSTONE_ALLOY.item(), SlimefunItems.HARDENED_GLASS.item(), MaterialCompat.stack(XMaterial.PISTON), SlimefunItems.ELECTRIC_MOTOR.item(), MaterialCompat.stack(XMaterial.PISTON)}) .setCapacity(256) .setEnergyConsumption(16) .setProcessingSpeed(1) @@ -2293,7 +2295,7 @@ public int getEnergyConsumption() { .register(plugin); new SharedActivationPlate(itemGroups.gps, SlimefunItems.GPS_ACTIVATION_DEVICE_SHARED, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, new ItemStack(Material.STONE_PRESSURE_PLATE), null, new ItemStack(Material.REDSTONE), SlimefunItems.GPS_TRANSMITTER.item(), new ItemStack(Material.REDSTONE), SlimefunItems.BILLON_INGOT.item(), SlimefunItems.BILLON_INGOT.item(), SlimefunItems.BILLON_INGOT.item()}) + new ItemStack[] {null, MaterialCompat.stack(XMaterial.STONE_PRESSURE_PLATE), null, new ItemStack(Material.REDSTONE), SlimefunItems.GPS_TRANSMITTER.item(), new ItemStack(Material.REDSTONE), SlimefunItems.BILLON_INGOT.item(), SlimefunItems.BILLON_INGOT.item(), SlimefunItems.BILLON_INGOT.item()}) .register(plugin); new PersonalActivationPlate(itemGroups.gps, SlimefunItems.GPS_ACTIVATION_DEVICE_PERSONAL, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -2322,7 +2324,7 @@ public int getEnergyConsumption() { .register(plugin); new ElevatorPlate(itemGroups.gps, SlimefunItems.ELEVATOR_PLATE, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, new ItemStack(Material.STONE_PRESSURE_PLATE), null, new ItemStack(Material.PISTON), SlimefunItems.ELECTRIC_MOTOR.item(), new ItemStack(Material.PISTON), SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.ALUMINUM_BRONZE_INGOT.item()}, + new ItemStack[] {null, MaterialCompat.stack(XMaterial.STONE_PRESSURE_PLATE), null, MaterialCompat.stack(XMaterial.PISTON), SlimefunItems.ELECTRIC_MOTOR.item(), MaterialCompat.stack(XMaterial.PISTON), SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.ALUMINUM_BRONZE_INGOT.item(), SlimefunItems.ALUMINUM_BRONZE_INGOT.item()}, new SlimefunItemStack(SlimefunItems.ELEVATOR_PLATE, 2).item()) .register(plugin); @@ -2349,28 +2351,28 @@ public int getEnergyConsumption() { new OrganicFood(itemGroups.misc, SlimefunItems.POTATO_ORGANIC_FOOD, Material.POTATO) .register(plugin); - new OrganicFood(itemGroups.misc, SlimefunItems.SEEDS_ORGANIC_FOOD, Material.WHEAT_SEEDS) + new OrganicFood(itemGroups.misc, SlimefunItems.SEEDS_ORGANIC_FOOD, XMaterial.WHEAT_SEEDS.parseMaterial()) .register(plugin); - new OrganicFood(itemGroups.misc, SlimefunItems.BEETROOT_ORGANIC_FOOD, Material.BEETROOT) + new OrganicFood(itemGroups.misc, SlimefunItems.BEETROOT_ORGANIC_FOOD, XMaterial.BEETROOT.parseMaterial()) .register(plugin); - new OrganicFood(itemGroups.misc, SlimefunItems.MELON_ORGANIC_FOOD, Material.MELON_SLICE) + new OrganicFood(itemGroups.misc, SlimefunItems.MELON_ORGANIC_FOOD, XMaterial.MELON_SLICE.parseMaterial()) .register(plugin); new OrganicFood(itemGroups.misc, SlimefunItems.APPLE_ORGANIC_FOOD, Material.APPLE) .register(plugin); - new OrganicFood(itemGroups.misc, SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD, Material.SWEET_BERRIES) + new OrganicFood(itemGroups.misc, SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD, XMaterial.SWEET_BERRIES.parseMaterial()) .register(plugin); - new OrganicFood(itemGroups.misc, SlimefunItems.KELP_ORGANIC_FOOD, Material.DRIED_KELP) + new OrganicFood(itemGroups.misc, SlimefunItems.KELP_ORGANIC_FOOD, XMaterial.DRIED_KELP.parseMaterial()) .register(plugin); - new OrganicFood(itemGroups.misc, SlimefunItems.COCOA_ORGANIC_FOOD, Material.COCOA_BEANS) + new OrganicFood(itemGroups.misc, SlimefunItems.COCOA_ORGANIC_FOOD, XMaterial.COCOA_BEANS.parseMaterial()) .register(plugin); - new OrganicFood(itemGroups.misc, SlimefunItems.SEAGRASS_ORGANIC_FOOD, Material.SEAGRASS) + new OrganicFood(itemGroups.misc, SlimefunItems.SEAGRASS_ORGANIC_FOOD, XMaterial.SEAGRASS.parseMaterial()) .register(plugin); new AutoBreeder(itemGroups.electricity, SlimefunItems.AUTO_BREEDER, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -2500,7 +2502,7 @@ public int getSpeed() { .register(plugin); new CoolantCell(itemGroups.technicalComponents, SlimefunItems.REACTOR_COOLANT_CELL, RecipeType.FREEZER, - new ItemStack[] {new ItemStack(Material.BLUE_ICE), null, null, null, null, null, null, null, null}) + new ItemStack[] {MaterialCompat.stack(XMaterial.BLUE_ICE), null, null, null, null, null, null, null, null}) .register(plugin); new CoolantCell(itemGroups.technicalComponents, SlimefunItems.NETHER_ICE_COOLANT_CELL, RecipeType.HEATED_PRESSURE_CHAMBER, @@ -2612,7 +2614,7 @@ public int getCapacity() { .register(plugin); new ElectricSmeltery(itemGroups.electricity, SlimefunItems.ELECTRIC_SMELTERY, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.NETHER_BRICKS), SlimefunItems.ELECTRIC_MOTOR.item(), new ItemStack(Material.NETHER_BRICKS), SlimefunItems.HEATING_COIL.item(), SlimefunItems.ELECTRIC_INGOT_FACTORY.item(), SlimefunItems.HEATING_COIL.item(), SlimefunItems.GILDED_IRON.item(), SlimefunItems.ELECTRIC_MOTOR.item(), SlimefunItems.GILDED_IRON.item()}) + new ItemStack[] {MaterialCompat.stack(XMaterial.NETHER_BRICKS), SlimefunItems.ELECTRIC_MOTOR.item(), MaterialCompat.stack(XMaterial.NETHER_BRICKS), SlimefunItems.HEATING_COIL.item(), SlimefunItems.ELECTRIC_INGOT_FACTORY.item(), SlimefunItems.HEATING_COIL.item(), SlimefunItems.GILDED_IRON.item(), SlimefunItems.ELECTRIC_MOTOR.item(), SlimefunItems.GILDED_IRON.item()}) .setCapacity(512) .setEnergyConsumption(10) .setProcessingSpeed(1) @@ -2634,31 +2636,31 @@ public int getCapacity() { .register(plugin); new TapeMeasure(itemGroups.usefulItems, SlimefunItems.TAPE_MEASURE, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.SILICON.item(), new ItemStack(Material.YELLOW_DYE), SlimefunItems.SILICON.item(), new ItemStack(Material.YELLOW_DYE), new ItemStack(Material.STRING), new ItemStack(Material.YELLOW_DYE), SlimefunItems.GILDED_IRON.item(), new ItemStack(Material.YELLOW_DYE), SlimefunItems.SILICON.item()}) + new ItemStack[] {SlimefunItems.SILICON.item(), MaterialCompat.stack(XMaterial.YELLOW_DYE), SlimefunItems.SILICON.item(), MaterialCompat.stack(XMaterial.YELLOW_DYE), new ItemStack(Material.STRING), MaterialCompat.stack(XMaterial.YELLOW_DYE), SlimefunItems.GILDED_IRON.item(), MaterialCompat.stack(XMaterial.YELLOW_DYE), SlimefunItems.SILICON.item()}) .register(plugin); MinecraftVersion minecraftVersion = Slimefun.getMinecraftVersion(); new SlimefunItem(itemGroups.magicalArmor, SlimefunItems.BEE_HELMET, RecipeType.ARMOR_FORGE, - new ItemStack[] {SlimefunItems.GOLD_8K.item(), new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K.item(), new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), null, null, null}) + new ItemStack[] {SlimefunItems.GOLD_8K.item(), MaterialCompat.stack(XMaterial.HONEY_BLOCK), SlimefunItems.GOLD_8K.item(), MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK), null, MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK), null, null, null}) .register(plugin); new BeeWings(itemGroups.magicalArmor, SlimefunItems.BEE_WINGS, RecipeType.ARMOR_FORGE, - new ItemStack[] {SlimefunItems.GOLD_8K.item(), null, SlimefunItems.GOLD_8K.item(), new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.ELYTRA), new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K.item(), new ItemStack(Material.HONEY_BLOCK)}) + new ItemStack[] {SlimefunItems.GOLD_8K.item(), null, SlimefunItems.GOLD_8K.item(), MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK), MaterialCompat.stack(XMaterial.ELYTRA), MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK), MaterialCompat.stack(XMaterial.HONEY_BLOCK), SlimefunItems.GOLD_8K.item(), MaterialCompat.stack(XMaterial.HONEY_BLOCK)}) .register(plugin); new SlimefunItem(itemGroups.magicalArmor, SlimefunItems.BEE_LEGGINGS, RecipeType.ARMOR_FORGE, - new ItemStack[] {SlimefunItems.GOLD_8K.item(), new ItemStack(Material.HONEY_BLOCK), SlimefunItems.GOLD_8K.item(), new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK), new ItemStack(Material.HONEYCOMB_BLOCK), null, new ItemStack(Material.HONEYCOMB_BLOCK)}) + new ItemStack[] {SlimefunItems.GOLD_8K.item(), MaterialCompat.stack(XMaterial.HONEY_BLOCK), SlimefunItems.GOLD_8K.item(), MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK), null, MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK), MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK), null, MaterialCompat.stack(XMaterial.HONEYCOMB_BLOCK)}) .register(plugin); new LongFallBoots(itemGroups.magicalArmor, SlimefunItems.BEE_BOOTS, RecipeType.ARMOR_FORGE, - new ItemStack[] {null, null, null, SlimefunItems.GOLD_8K.item(), null, SlimefunItems.GOLD_8K.item(), new ItemStack(Material.HONEY_BLOCK), null, new ItemStack(Material.HONEY_BLOCK)}, + new ItemStack[] {null, null, null, SlimefunItems.GOLD_8K.item(), null, SlimefunItems.GOLD_8K.item(), MaterialCompat.stack(XMaterial.HONEY_BLOCK), null, MaterialCompat.stack(XMaterial.HONEY_BLOCK)}, new PotionEffect[] {new PotionEffect(VersionedPotionEffectType.JUMP_BOOST, 300, 2)}, SoundEffect.BEE_BOOTS_FALL_SOUND) .register(plugin); new VillagerRune(itemGroups.magicalResources, SlimefunItems.VILLAGER_RUNE, RecipeType.ANCIENT_ALTAR, - new ItemStack[] {SlimefunItems.MAGIC_LUMP_3.item(), SlimefunItems.MAGICAL_GLASS.item(), new ItemStack(Material.CRYING_OBSIDIAN), SlimefunItems.STRANGE_NETHER_GOO.item(), SlimefunItems.FIRE_RUNE.item(), SlimefunItems.STRANGE_NETHER_GOO.item(), new ItemStack(Material.CRYING_OBSIDIAN), SlimefunItems.MAGICAL_GLASS.item(), SlimefunItems.MAGIC_LUMP_3.item()}, + new ItemStack[] {SlimefunItems.MAGIC_LUMP_3.item(), SlimefunItems.MAGICAL_GLASS.item(), MaterialCompat.stack(XMaterial.CRYING_OBSIDIAN), SlimefunItems.STRANGE_NETHER_GOO.item(), SlimefunItems.FIRE_RUNE.item(), SlimefunItems.STRANGE_NETHER_GOO.item(), MaterialCompat.stack(XMaterial.CRYING_OBSIDIAN), SlimefunItems.MAGICAL_GLASS.item(), SlimefunItems.MAGIC_LUMP_3.item()}, new SlimefunItemStack(SlimefunItems.VILLAGER_RUNE, 3).item()) .register(plugin); @@ -2668,7 +2670,7 @@ public int getCapacity() { if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_17)) { new Juice(itemGroups.food, SlimefunItems.GLOW_BERRY_JUICE, RecipeType.JUICER, - new ItemStack[] {new ItemStack(Material.GLOW_BERRIES), null, null, null, null, null, null, null, null}) + new ItemStack[] {MaterialCompat.stack(XMaterial.GLOW_BERRIES), null, null, null, null, null, null, null, null}) .register(plugin); } @@ -2682,24 +2684,24 @@ public int getCapacity() { .register(plugin); new UnplaceableBlock(itemGroups.cargo, SlimefunItems.CRAFTING_MOTOR, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {new ItemStack(Material.CRAFTING_TABLE), SlimefunItems.BLISTERING_INGOT_3.item(), new ItemStack(Material.CRAFTING_TABLE), SlimefunItems.REDSTONE_ALLOY.item(), SlimefunItems.CARGO_MOTOR.item(), SlimefunItems.REDSTONE_ALLOY.item(), new ItemStack(Material.CRAFTING_TABLE), SlimefunItems.BLISTERING_INGOT_3.item(), new ItemStack(Material.CRAFTING_TABLE)}, + new ItemStack[] {MaterialCompat.stack(XMaterial.CRAFTING_TABLE), SlimefunItems.BLISTERING_INGOT_3.item(), MaterialCompat.stack(XMaterial.CRAFTING_TABLE), SlimefunItems.REDSTONE_ALLOY.item(), SlimefunItems.CARGO_MOTOR.item(), SlimefunItems.REDSTONE_ALLOY.item(), MaterialCompat.stack(XMaterial.CRAFTING_TABLE), SlimefunItems.BLISTERING_INGOT_3.item(), MaterialCompat.stack(XMaterial.CRAFTING_TABLE)}, new SlimefunItemStack(SlimefunItems.CRAFTING_MOTOR, 2).item()) .register(plugin); new VanillaAutoCrafter(itemGroups.cargo, SlimefunItems.VANILLA_AUTO_CRAFTER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, SlimefunItems.CARGO_MOTOR.item(), null, new ItemStack(Material.CRAFTING_TABLE), SlimefunItems.CRAFTING_MOTOR.item(), new ItemStack(Material.CRAFTING_TABLE), null, SlimefunItems.ELECTRIC_MOTOR.item(), null}) + new ItemStack[] {null, SlimefunItems.CARGO_MOTOR.item(), null, MaterialCompat.stack(XMaterial.CRAFTING_TABLE), SlimefunItems.CRAFTING_MOTOR.item(), MaterialCompat.stack(XMaterial.CRAFTING_TABLE), null, SlimefunItems.ELECTRIC_MOTOR.item(), null}) .setCapacity(256) .setEnergyConsumption(16) .register(plugin); new EnhancedAutoCrafter(itemGroups.cargo, SlimefunItems.ENHANCED_AUTO_CRAFTER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, SlimefunItems.CRAFTING_MOTOR.item(), null, new ItemStack(Material.CRAFTING_TABLE), new ItemStack(Material.DISPENSER), new ItemStack(Material.CRAFTING_TABLE), null, SlimefunItems.CARGO_MOTOR.item(), null}) + new ItemStack[] {null, SlimefunItems.CRAFTING_MOTOR.item(), null, MaterialCompat.stack(XMaterial.CRAFTING_TABLE), new ItemStack(Material.DISPENSER), MaterialCompat.stack(XMaterial.CRAFTING_TABLE), null, SlimefunItems.CARGO_MOTOR.item(), null}) .setCapacity(256) .setEnergyConsumption(16) .register(plugin); new ArmorAutoCrafter(itemGroups.cargo, SlimefunItems.ARMOR_AUTO_CRAFTER, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {null, SlimefunItems.CRAFTING_MOTOR.item(), null, new ItemStack(Material.DISPENSER), new ItemStack(Material.ANVIL), new ItemStack(Material.DISPENSER), new ItemStack(Material.CRAFTING_TABLE), SlimefunItems.ELECTRIC_MOTOR.item(), new ItemStack(Material.CRAFTING_TABLE)}) + new ItemStack[] {null, SlimefunItems.CRAFTING_MOTOR.item(), null, new ItemStack(Material.DISPENSER), new ItemStack(Material.ANVIL), new ItemStack(Material.DISPENSER), MaterialCompat.stack(XMaterial.CRAFTING_TABLE), SlimefunItems.ELECTRIC_MOTOR.item(), MaterialCompat.stack(XMaterial.CRAFTING_TABLE)}) .setCapacity(256) .setEnergyConsumption(32) .register(plugin); @@ -2741,3 +2743,4 @@ private static void registerArmorSet(ItemGroup itemGroup, ItemStack baseComponen } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/package-info.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/package-info.java index ad5bd0fb4c..09b6cfda03 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/setup/package-info.java @@ -1,4 +1,4 @@ /** * In this package we initialize our items, researches and stuff. */ -package io.github.thebusybiscuit.slimefun4.implementation.setup; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.setup; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/AncientAltarTask.java similarity index 78% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/AncientAltarTask.java index be256b0031..61eadad7e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/AncientAltarTask.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks; +package io.github.thebusybiscuit.slimefun5.implementation.tasks; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ParticleCompat; import java.util.Collection; import java.util.HashMap; @@ -14,20 +16,20 @@ import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.block.Block; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.AncientAltarCraftEvent; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedParticle; +import io.github.thebusybiscuit.slimefun5.api.events.AncientAltarCraftEvent; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientAltar; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.AncientAltarListener; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedParticle; /** * The {@link AncientAltarTask} is responsible for the animation that happens when a ritual @@ -117,12 +119,12 @@ private boolean checkLockedItems() { } private void idle() { - dropLocation.getWorld().spawnParticle(VersionedParticle.WITCH, dropLocation, 16, 1.2F, 0F, 1.2F); - dropLocation.getWorld().spawnParticle(VersionedParticle.FIREWORK, dropLocation, 8, 0.2F, 0F, 0.2F); + ParticleCompat.spawn(dropLocation.getWorld(), VersionedParticle.WITCH, dropLocation, 16, 1.2F, 0F, 1.2F); + ParticleCompat.spawn(dropLocation.getWorld(), VersionedParticle.FIREWORK, dropLocation, 8, 0.2F, 0F, 0.2F); for (Location loc : particleLocations) { - dropLocation.getWorld().spawnParticle(VersionedParticle.ENCHANT, loc, 16, 0.3F, 0.2F, 0.3F); - dropLocation.getWorld().spawnParticle(VersionedParticle.ENCHANTED_HIT, loc, 8, 0.3F, 0.2F, 0.3F); + ParticleCompat.spawn(dropLocation.getWorld(), VersionedParticle.ENCHANT, loc, 16, 0.3F, 0.2F, 0.3F); + ParticleCompat.spawn(dropLocation.getWorld(), VersionedParticle.ENCHANTED_HIT, loc, 8, 0.3F, 0.2F, 0.3F); } } @@ -137,8 +139,8 @@ private void checkPedestal(@Nonnull Block pedestal) { items.add(pedestalItem.getOriginalItemStack(entity)); SoundEffect.ANCIENT_ALTAR_ITEM_CHECK_SOUND.playAt(pedestal); - dropLocation.getWorld().spawnParticle(VersionedParticle.ENCHANT, pedestal.getLocation().add(0.5, 1.5, 0.5), 16, 0.3F, 0.2F, 0.3F); - dropLocation.getWorld().spawnParticle(VersionedParticle.ENCHANTED_HIT, pedestal.getLocation().add(0.5, 1.5, 0.5), 8, 0.3F, 0.2F, 0.3F); + ParticleCompat.spawn(dropLocation.getWorld(), VersionedParticle.ENCHANT, pedestal.getLocation().add(0.5, 1.5, 0.5), 16, 0.3F, 0.2F, 0.3F); + ParticleCompat.spawn(dropLocation.getWorld(), VersionedParticle.ENCHANTED_HIT, pedestal.getLocation().add(0.5, 1.5, 0.5), 8, 0.3F, 0.2F, 0.3F); positionLock.remove(entity); entity.remove(); @@ -184,3 +186,4 @@ private void finish() { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/ArmorTask.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/ArmorTask.java index d0ab1ec05b..7257f8de6f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/ArmorTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks; +package io.github.thebusybiscuit.slimefun5.implementation.tasks; import java.util.Collections; import java.util.HashSet; @@ -17,17 +17,17 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.SolarHelmet; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.api.items.HashedArmorpiece; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactive; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.SolarHelmet; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; /** * The {@link ArmorTask} is responsible for handling {@link PotionEffect PotionEffects} for @@ -130,8 +130,8 @@ private void checkForSolarHelmet(@Nonnull Player p) { ItemStack helmet = p.getInventory().getHelmet(); SlimefunItem item = SlimefunItem.getByItem(helmet); - if (item instanceof SolarHelmet solarHelmet && item.canUse(p, true)) { - solarHelmet.rechargeItems(p); + if (item instanceof SolarHelmet && item.canUse(p, true)) { + SolarHelmet solarHelmet = (SolarHelmet) item; solarHelmet.rechargeItems(p); } } @@ -191,3 +191,4 @@ private boolean checkAndApplyRadiation(@Nonnull Player p, @Nullable ItemStack it return false; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AsyncRecipeChoiceTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/AsyncRecipeChoiceTask.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AsyncRecipeChoiceTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/AsyncRecipeChoiceTask.java index 9ac00aa3ca..4479a34c5d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AsyncRecipeChoiceTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/AsyncRecipeChoiceTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks; +package io.github.thebusybiscuit.slimefun5.implementation.tasks; import java.util.HashMap; import java.util.Map; @@ -10,15 +10,15 @@ import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.Tag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.inventory.RecipeChoice.MaterialChoice; import io.github.bakedlibs.dough.collections.LoopIterator; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.guide.SurvivalSlimefunGuide; /** * A {@link AsyncRecipeChoiceTask} is an asynchronously repeating task that cycles @@ -126,3 +126,4 @@ public void run() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/CapacitorTextureUpdateTask.java similarity index 80% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/CapacitorTextureUpdateTask.java index 4f79580831..cc79b05bbb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/CapacitorTextureUpdateTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/CapacitorTextureUpdateTask.java @@ -1,17 +1,17 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks; +package io.github.thebusybiscuit.slimefun5.implementation.tasks; import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.Server; import org.bukkit.block.Block; -import io.github.bakedlibs.dough.skins.PlayerHead; -import io.github.bakedlibs.dough.skins.PlayerSkin; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPlayerHead; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.Capacitor; +import io.github.thebusybiscuit.slimefun5.utils.HeadTexture; import io.papermc.lib.PaperLib; /** @@ -57,7 +57,7 @@ public void run() { Material type = b.getType(); // Ensure that this Block is still a Player Head - if (type == Material.PLAYER_HEAD || type == Material.PLAYER_WALL_HEAD) { + if (type == XMaterial.PLAYER_HEAD.parseMaterial() || type == XMaterial.PLAYER_WALL_HEAD.parseMaterial()) { if (filledPercentage <= 0.25) { // 0-25% capacity setTexture(b, HeadTexture.CAPACITOR_25); @@ -75,10 +75,10 @@ public void run() { } private void setTexture(@Nonnull Block b, @Nonnull HeadTexture texture) { - PlayerSkin skin = PlayerSkin.fromHashCode(texture.getUniqueId(), texture.getTexture()); - PlayerHead.setSkin(b, skin, false); + VersionedPlayerHead.setSkinFromHash(b, texture.getUniqueId(), texture.getTexture(), false); PaperLib.getBlockState(b, false).getState().update(true, false); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/SlimefunStartupTask.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/SlimefunStartupTask.java index 4802161951..2c7d091945 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/SlimefunStartupTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks; +package io.github.thebusybiscuit.slimefun5.implementation.tasks; import java.util.logging.Level; @@ -7,11 +7,11 @@ import org.bukkit.Bukkit; import org.bukkit.World; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.TeleporterListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener; -import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.TeleporterListener; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.WorldListener; +import io.github.thebusybiscuit.slimefun5.implementation.setup.PostSetup; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -81,3 +81,4 @@ private boolean isEnabled(String... itemIds) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/TickerTask.java similarity index 98% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/TickerTask.java index 91525994fb..e8c3814325 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/TickerTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks; +package io.github.thebusybiscuit.slimefun5.implementation.tasks; import java.util.Collection; import java.util.Collections; @@ -23,9 +23,9 @@ import io.github.bakedlibs.dough.blocks.BlockPosition; import io.github.bakedlibs.dough.blocks.ChunkPosition; -import io.github.thebusybiscuit.slimefun4.api.ErrorReport; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.ErrorReport; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -388,3 +388,4 @@ public void disableTicker(@Nonnull Location l) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/AbstractArmorTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/AbstractArmorTask.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/AbstractArmorTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/AbstractArmorTask.java index 179e905f14..eb1d3614b6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/AbstractArmorTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/AbstractArmorTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.armor; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.armor; import java.util.logging.Level; @@ -10,8 +10,8 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This is a base class for any ArmorTask, it checks every online player @@ -77,3 +77,4 @@ protected void onTick() { @ParametersAreNonnullByDefault protected abstract void onPlayerTick(Player p, PlayerProfile profile); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/RadiationTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/RadiationTask.java similarity index 76% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/RadiationTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/RadiationTask.java index 85e4c4bfe8..a8f651c5bf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/RadiationTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/RadiationTask.java @@ -1,15 +1,18 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.armor; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.armor; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.api.events.RadiationDamageEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.RadiationSymptom; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.RadioactivityListener; -import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils; +import io.github.thebusybiscuit.slimefun5.api.events.RadiationDamageEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.core.attributes.RadiationSymptom; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactive; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.RadioactivityListener; +import io.github.thebusybiscuit.slimefun5.utils.RadiationUtils; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.ComponentBuilder; @@ -51,12 +54,12 @@ protected void onPlayerTick(Player p, PlayerProfile profile) { && p.getGameMode() != GameMode.CREATIVE && p.getGameMode() != GameMode.SPECTATOR) { for (ItemStack item : p.getInventory()) { - if (item == null || item.getType().isAir()) { + if (item == null || MaterialCompat.isAir(item.getType())) { continue; } SlimefunItem sfItem = SlimefunItem.getByItem(item); - if (sfItem instanceof Radioactive radioactiveItem) { - exposureTotal += item.getAmount() * radioactiveItem.getRadioactivity().getExposureModifier(); + if (sfItem instanceof Radioactive) { + Radioactive radioactiveItem = (Radioactive) sfItem; exposureTotal += item.getAmount() * radioactiveItem.getRadioactivity().getExposureModifier(); } } int exposureLevelBefore = RadiationUtils.getExposure(p); @@ -93,8 +96,9 @@ protected void onPlayerTick(Player p, PlayerProfile profile) { .getMessage(p, "actionbar.radiation") .replace("%level%", "" + exposureLevelAfter); BaseComponent[] components = - new ComponentBuilder().append(ChatColors.color(msg)).create(); - p.spigot().sendMessage(ChatMessageType.ACTION_BAR, components); + new ComponentBuilder("").append(ChatColors.color(msg)).create(); + // The (ChatMessageType, BaseComponent[]) sendMessage overload is post-1.8; reached reflectively. + ReflectionCompat.invoke(p.spigot(), "sendMessage", ChatMessageType.ACTION_BAR, components); } } else { RadiationUtils.removeExposure(p, 1); @@ -137,3 +141,4 @@ public static void addGracePeriod(@Nonnull Player player) { ACTIVE_GRACE_PERIODS.put(player.getUniqueId(), System.currentTimeMillis() + (GRACE_PERIOD_DURATION * 1000L)); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/RainbowArmorTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/RainbowArmorTask.java similarity index 67% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/RainbowArmorTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/RainbowArmorTask.java index 7df8b7e846..47ca7674b6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/RainbowArmorTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/RainbowArmorTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.armor; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.armor; import javax.annotation.ParametersAreNonnullByDefault; @@ -7,9 +7,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; -import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.RainbowArmorPiece; +import io.github.thebusybiscuit.slimefun5.api.items.HashedArmorpiece; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.RainbowArmorPiece; /** * The {@link RainbowArmorTask} is responsible for handling the change in color of any Rainbow Armor piece. @@ -35,8 +35,8 @@ protected void onPlayerTick(Player p, PlayerProfile profile) { HashedArmorpiece armorPiece = profile.getArmor()[i]; armorPiece.getItem().ifPresent(sfArmorPiece -> { - if (sfArmorPiece instanceof RainbowArmorPiece rainbowArmorPiece && rainbowArmorPiece.canUse(p, true)) { - updateRainbowArmor(item, rainbowArmorPiece); + if (sfArmorPiece instanceof RainbowArmorPiece && ((RainbowArmorPiece) sfArmorPiece).canUse(p, true)) { + RainbowArmorPiece rainbowArmorPiece = (RainbowArmorPiece) sfArmorPiece; updateRainbowArmor(item, rainbowArmorPiece); } }); } @@ -48,9 +48,10 @@ private void updateRainbowArmor(ItemStack itemStack, RainbowArmorPiece armorPiec Color[] colors = armorPiece.getColors(); Color newColor = colors[(int) (currentColorIndex % colors.length)]; - if (itemStack.getItemMeta() instanceof LeatherArmorMeta leatherArmorMeta) { - leatherArmorMeta.setColor(newColor); + if (itemStack.getItemMeta() instanceof LeatherArmorMeta) { + LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) itemStack.getItemMeta(); leatherArmorMeta.setColor(newColor); itemStack.setItemMeta(leatherArmorMeta); } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/SlimefunArmorTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/SlimefunArmorTask.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/SlimefunArmorTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/SlimefunArmorTask.java index ce21846923..fb4e0ec40b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/SlimefunArmorTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/SlimefunArmorTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.armor; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.armor; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,12 +6,12 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.api.items.HashedArmorpiece; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactive; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; /** * The {@link SlimefunArmorTask} is responsible for handling {@link SlimefunArmorPiece} @@ -77,3 +77,4 @@ protected void onArmorPieceTick(Player p, SlimefunArmorPiece sfArmorPiece, ItemS } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/SolarHelmetTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/SolarHelmetTask.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/SolarHelmetTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/SolarHelmetTask.java index 7b28b60fe2..453743664c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/armor/SolarHelmetTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/armor/SolarHelmetTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.armor; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.armor; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -8,11 +8,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.SolarHelmet; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.SolarHelmet; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * The {@link SolarHelmetTask} is responsible for handling {@link SolarHelmet} for generating power @@ -36,8 +36,8 @@ private void checkForSolarHelmet(@Nonnull Player p) { ItemStack helmet = p.getInventory().getHelmet(); SlimefunItem item = SlimefunItem.getByItem(helmet); - if (item instanceof SolarHelmet solarHelmet && item.canUse(p, true)) { - solarHelmet.rechargeItems(p); + if (item instanceof SolarHelmet && item.canUse(p, true)) { + SolarHelmet solarHelmet = (SolarHelmet) item; solarHelmet.rechargeItems(p); } } @@ -52,3 +52,4 @@ private boolean hasSunlight(@Nonnull Player p) { return (world.getTime() < 12300 || world.getTime() > 23850) && p.getEyeLocation().getBlock().getLightFromSky() == 15; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/package-info.java similarity index 54% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/package-info.java index 2935ec8cb9..efb44b70f0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/package-info.java @@ -1,4 +1,4 @@ /** * This package contains several tasks that Slimefun runs regularly. */ -package io.github.thebusybiscuit.slimefun4.implementation.tasks; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.implementation.tasks; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/AbstractPlayerTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/AbstractPlayerTask.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/AbstractPlayerTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/AbstractPlayerTask.java index 03744889bd..0a689847b8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/AbstractPlayerTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/AbstractPlayerTask.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.player; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.player; import javax.annotation.Nonnull; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; abstract class AbstractPlayerTask implements Runnable { @@ -59,3 +59,4 @@ protected boolean isValid() { protected abstract void executeTask(); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/BeeWingsTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/BeeWingsTask.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/BeeWingsTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/BeeWingsTask.java index 662f8c6dcb..23eae419b9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/BeeWingsTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/BeeWingsTask.java @@ -1,17 +1,19 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.player; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.player; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.EntityCompat; import javax.annotation.Nonnull; -import org.bukkit.HeightMap; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.BeeWings; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeWingsListener; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPotionEffectType; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.BeeWings; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BeeWingsListener; /** * This task is responsible for the repeating checks for our {@link BeeWings}. @@ -38,7 +40,9 @@ public BeeWingsTask(@Nonnull Player p) { protected void executeTask() { if (p.getLocation().getY() < lastLocation.getY()) { Location loc = p.getLocation(); - int distanceToHighestBlock = (loc.getBlockY() - loc.getWorld().getHighestBlockYAt(loc, HeightMap.WORLD_SURFACE)); + // HeightMap overload is 1.15+; the single-arg getHighestBlockYAt(Location) exists on 1.8 and + // resolves to the world surface, so it is equivalent here. + int distanceToHighestBlock = (loc.getBlockY() - loc.getWorld().getHighestBlockYAt(loc)); /* * getDistanceToGround will only fire when distanceToHighestBlock is negative @@ -64,7 +68,11 @@ private void slowDown() { Slimefun.getLocalization().sendMessage(p, "messages.bee-suit-slow-fall"); p.setFallDistance(0); - p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 60, 0)); + + // SLOW_FALLING is 1.13+ (null on older servers, where the slow-fall effect simply cannot apply). + if (VersionedPotionEffectType.SLOW_FALLING != null) { + p.addPotionEffect(new PotionEffect(VersionedPotionEffectType.SLOW_FALLING, 60, 0)); + } } /** @@ -91,7 +99,8 @@ private int getDistanceToGround(@Nonnull Block b, int limit) { @Override protected boolean isValid() { // The task is only valid as long as the Player is alive and gliding - if (!p.isOnline() || !p.isValid() || p.isDead() || !p.isGliding() || p.hasPotionEffect(PotionEffectType.SLOW_FALLING)) { + if (!p.isOnline() || !p.isValid() || p.isDead() || !EntityCompat.isGliding(p) + || (VersionedPotionEffectType.SLOW_FALLING != null && p.hasPotionEffect(VersionedPotionEffectType.SLOW_FALLING))) { cancel(); return false; } @@ -100,3 +109,4 @@ protected boolean isValid() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/InfusedMagnetTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/InfusedMagnetTask.java similarity index 75% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/InfusedMagnetTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/InfusedMagnetTask.java index 091f59ddec..dea305635b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/InfusedMagnetTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/InfusedMagnetTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.player; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.player; import javax.annotation.Nonnull; @@ -7,9 +7,9 @@ import org.bukkit.entity.Item; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.InfusedMagnet; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.InfusedMagnet; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; /** * This {@link AbstractPlayerTask} is run when a {@link Player} carries an {@link InfusedMagnet}. @@ -47,7 +47,8 @@ protected void executeTask() { boolean playSound = false; for (Entity entity : p.getNearbyEntities(radius, radius, radius)) { - if (entity instanceof Item item && !SlimefunUtils.hasNoPickupFlag(item) && item.getPickupDelay() <= 0 && p.getLocation().distanceSquared(item.getLocation()) > 0.3) { + if (entity instanceof Item && !SlimefunUtils.hasNoPickupFlag((Item) entity) && ((Item) entity).getPickupDelay() <= 0 && p.getLocation().distanceSquared(((Item) entity).getLocation()) > 0.3) { + Item item = (Item) entity; item.teleport(p.getLocation()); playSound = true; } @@ -64,3 +65,4 @@ protected boolean isValid() { return super.isValid() && p.getGameMode() != GameMode.SPECTATOR; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/JetBootsTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/JetBootsTask.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/JetBootsTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/JetBootsTask.java index c11c01184e..76b6291460 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/JetBootsTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/JetBootsTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.player; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.player; import java.util.concurrent.ThreadLocalRandom; @@ -6,13 +6,13 @@ import org.bukkit.Effect; import org.bukkit.Material; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.JetBoots; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; public class JetBootsTask extends AbstractPlayerTask { @@ -47,3 +47,4 @@ protected void executeTask() { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/JetpackTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/JetpackTask.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/JetpackTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/JetpackTask.java index 40c119943e..7be1854062 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/JetpackTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/JetpackTask.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.player; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.player; import javax.annotation.Nonnull; import org.bukkit.Effect; import org.bukkit.Material; -import org.bukkit.SoundCategory; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCategory; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.gadgets.Jetpack; public class JetpackTask extends AbstractPlayerTask { @@ -42,3 +42,4 @@ protected void executeTask() { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/ParachuteTask.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/ParachuteTask.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/ParachuteTask.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/ParachuteTask.java index 94382753d5..2dcd275030 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/ParachuteTask.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/player/ParachuteTask.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks.player; +package io.github.thebusybiscuit.slimefun5.implementation.tasks.player; import javax.annotation.Nonnull; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.Parachute; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.Parachute; /** * The {@link ParachuteTask} adds the entire functionality of the {@link Parachute}. @@ -36,3 +36,4 @@ protected void executeTask() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/ClearLagIntegration.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/ClearLagIntegration.java new file mode 100644 index 0000000000..0081863e1d --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/ClearLagIntegration.java @@ -0,0 +1,68 @@ +package io.github.thebusybiscuit.slimefun5.integrations; + +import java.util.Iterator; +import java.util.List; + +import javax.annotation.Nonnull; + +import org.bukkit.entity.Item; +import org.bukkit.event.Event; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.plugin.EventExecutor; + +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; + +/** + * This handles all integrations with ClearLag. + * We don't want it to clear our altar items. + * + *

+ * Java-8 universal port: ClearLag's {@code EntityRemoveEvent} only exists when ClearLag is installed, + * so we cannot reference it in an {@code @EventHandler} signature (the class would fail to load). The + * event type is resolved reflectively and a dynamic {@link EventExecutor} is registered for it; the + * event's entity list is read and pruned reflectively. + * + * @author TheBusyBiscuit + */ +class ClearLagIntegration implements Listener { + + private static final String EVENT_CLASS = "me.minebuilders.clearlag.events.EntityRemoveEvent"; + + private final Slimefun plugin; + + ClearLagIntegration(@Nonnull Slimefun plugin) { + this.plugin = plugin; + } + + public void register() { + Class eventClass; + + try { + eventClass = Class.forName(EVENT_CLASS).asSubclass(Event.class); + } catch (ClassNotFoundException e) { + throw new IllegalStateException("ClearLag EntityRemoveEvent not found", e); + } + + EventExecutor executor = (listener, event) -> onEntityRemove(event); + plugin.getServer().getPluginManager().registerEvent(eventClass, this, EventPriority.NORMAL, executor, plugin); + } + + private void onEntityRemove(@Nonnull Object event) { + Object entityList = ReflectionCompat.invoke(event, "getEntityList"); + + if (entityList instanceof List) { + Iterator iterator = ((List) entityList).iterator(); + + while (iterator.hasNext()) { + Object n = iterator.next(); + + if (n instanceof Item && SlimefunUtils.hasNoPickupFlag((Item) n)) { + iterator.remove(); + } + } + } + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/IntegrationsManager.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/IntegrationsManager.java similarity index 53% rename from src/main/java/io/github/thebusybiscuit/slimefun4/integrations/IntegrationsManager.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/IntegrationsManager.java index 5063884c56..e87964197e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/IntegrationsManager.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/IntegrationsManager.java @@ -1,40 +1,36 @@ -package io.github.thebusybiscuit.slimefun4.integrations; +package io.github.thebusybiscuit.slimefun5.integrations; -import java.util.function.Consumer; import java.util.logging.Level; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import dev.lone.itemsadder.api.CustomBlock; import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Server; import org.bukkit.block.Block; import org.bukkit.event.Event; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; - -import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; -import com.gmail.nossr50.util.skills.SkillUtils; +import org.bukkit.Server; import io.github.bakedlibs.dough.protection.ProtectionManager; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter; - -import dev.lone.itemsadder.api.ItemsAdder; +import io.github.thebusybiscuit.slimefun5.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; /** * This Service holds all interactions and hooks with third-party {@link Plugin Plugins} * that are not necessarily a dependency or a {@link SlimefunAddon}. - * - * Integration with these plugins happens inside Slimefun itself. - * + * + *

+ * TEMPORARY JAVA-8 STUB: during the multi-version (1.8+) port the soft-dependency hooks + * (PlaceholderAPI, WorldEdit, mcMMO, ClearLag, ItemsAdder, Orebfuscator) are disabled because + * their APIs require a modern JVM and cannot sit on the Java-8 compile classpath. The dough + * {@link ProtectionManager} (Java-8 compatible) is retained. The hooks will be re-introduced via + * reflection so they remain optional and JVM-version-agnostic. + * * @author TheBusyBiscuit - * - * @see Slimefun * + * @see Slimefun */ public class IntegrationsManager { @@ -53,7 +49,7 @@ public class IntegrationsManager { */ private boolean isEnabled = false; - // Soft dependencies + // Soft dependencies (disabled in the Java-8 stub; re-added later via reflection) private boolean isPlaceholderAPIInstalled = false; private boolean isWorldEditInstalled = false; private boolean isMcMMOInstalled = false; @@ -63,7 +59,7 @@ public class IntegrationsManager { /** * This initializes the {@link IntegrationsManager} - * + * * @param plugin * Our instance of {@link Slimefun} */ @@ -73,7 +69,7 @@ public IntegrationsManager(@Nonnull Slimefun plugin) { /** * This method returns whether the {@link IntegrationsManager} was enabled yet. - * + * * @return Whether this {@link IntegrationsManager} has been enabled already. */ public boolean isEnabled() { @@ -91,47 +87,10 @@ public final void start() { isEnabled = true; } - // Load any soft dependencies - onServerLoad(); - // Load any integrations which aren't dependencies (loadBefore) plugin.getServer().getScheduler().runTask(plugin, this::onServerStart); } - /** - * This method is called when the {@link Server} loaded its {@link Plugin Plugins}. - * We can safely assume that any {@link Plugin} which is a soft dependency of Slimefun - * to be enabled at this point. - */ - private void onServerLoad() { - // PlaceholderAPI hook to provide playerholders from Slimefun. - load("PlaceholderAPI", integration -> { - new PlaceholderAPIIntegration(plugin).register(); - isPlaceholderAPIInstalled = true; - }); - - // WorldEdit Hook to clear Slimefun Data upon //set 0 //cut or any other equivalent - load("WorldEdit", integration -> { - new WorldEditIntegration().register(); - isWorldEditInstalled = true; - }); - - // mcMMO Integration - load("mcMMO", integration -> { - new McMMOIntegration(plugin).register(); - isMcMMOInstalled = true; - }); - - // ClearLag integration (to prevent display items from getting deleted) - load("ClearLag", integration -> { - new ClearLagIntegration(plugin).register(); - isClearLagInstalled = true; - }); - - // ItemsAdder Integration (custom blocks) - load("ItemsAdder", integration -> isItemsAdderInstalled = true); - } - /** * This method is called when the {@link Server} has finished loading all its {@link Plugin Plugins}. */ @@ -143,19 +102,68 @@ private void onServerStart() { Slimefun.logger().log(Level.WARNING, x, () -> "Failed to load Protection plugin integrations for Slimefun v" + Slimefun.getVersion()); } - // Orebfuscator Integration - load("Orebfuscator", integration -> { - new OrebfuscatorIntegration(plugin).register(); - isOrebfuscatorInstalled = true; - }); + // Java-8 universal port: these soft-dependency hooks are re-added via reflection so they stay + // optional and JVM-version-agnostic. Each hook references no third-party type in its bytecode + // and is only registered when its plugin is actually present. + if (isPluginInstalled("ClearLag")) { + isClearLagInstalled = register("ClearLag", () -> new ClearLagIntegration(plugin).register()); + } + + if (isPluginInstalled("mcMMO")) { + isMcMMOInstalled = register("mcMMO", () -> new McMMOIntegration(plugin).register()); + } + + if (isPluginInstalled("Orebfuscator")) { + isOrebfuscatorInstalled = register("Orebfuscator", () -> new OrebfuscatorIntegration(plugin).register()); + } + + // Detection-only hooks (no listener to register): ItemsAdder is queried on demand below. + isItemsAdderInstalled = isPluginInstalled("ItemsAdder"); + + // WorldEdit and PlaceholderAPI cannot be re-added via reflection (their hooks must subclass a + // third-party class - AbstractDelegateExtent / PlaceholderExpansion - which is impossible + // without the Java-17 API on the compile classpath). They remain detected but inactive. + isWorldEditInstalled = isPluginInstalled("WorldEdit"); + isPlaceholderAPIInstalled = isPluginInstalled("PlaceholderAPI"); + } + + /** + * Detects whether a {@link Plugin} is installed (loaded) on this server. + * + * @param name + * The plugin name + * + * @return Whether the plugin is present + */ + private boolean isPluginInstalled(@Nonnull String name) { + return Bukkit.getPluginManager().getPlugin(name) != null; + } + + /** + * Runs a hook registration, logging and swallowing any failure so a broken integration never + * disrupts the others. + * + * @param name + * The integration name (for logging) + * @param registration + * The registration action + * + * @return Whether registration succeeded + */ + private boolean register(@Nonnull String name, @Nonnull Runnable registration) { + try { + registration.run(); + return true; + } catch (Exception | LinkageError x) { + logError(name, x); + return false; + } } /** * This method logs a {@link Throwable} that was caused by a {@link Plugin} * we integrate into. - * Calling this method will probably log the error and provide the version of this {@link Plugin} - * for error analysis. - * + * * @param name * The name of the {@link Plugin} * @param throwable @@ -175,36 +183,10 @@ protected void logError(String name, Throwable throwable) { } /** - * This method loads an integration with a {@link Plugin} of the specified name. - * If that {@link Plugin} is installed and enabled, the provided callback will be run. - * - * @param pluginName - * The name of this {@link Plugin} - * @param consumer - * The callback to run if that {@link Plugin} is installed and enabled - */ - private void load(@Nonnull String pluginName, @Nonnull Consumer consumer) { - Plugin integration = plugin.getServer().getPluginManager().getPlugin(pluginName); - - if (integration != null && integration.isEnabled()) { - String version = integration.getDescription().getVersion(); - Slimefun.logger().log(Level.INFO, "Hooked into Plugin: {0} v{1}", new Object[] { pluginName, version }); - - try { - // Run our callback - consumer.accept(integration); - } catch (Exception | LinkageError x) { - Slimefun.logger().log(Level.WARNING, "Maybe consider updating {0} or Slimefun?", pluginName); - Slimefun.logger().log(Level.WARNING, x, () -> "Failed to hook into " + pluginName + " v" + version); - } - } - } - - /** - * This returns out instance of the {@link ProtectionManager}. + * This returns our instance of the {@link ProtectionManager}. * This bridge is used to hook into any third-party protection {@link Plugin}. - * - * @return Our instanceof of the {@link ProtectionManager} + * + * @return Our instance of the {@link ProtectionManager} */ public @Nonnull ProtectionManager getProtectionManager() { return protectionManager; @@ -212,78 +194,88 @@ private void load(@Nonnull String pluginName, @Nonnull Consumer consumer /** * This checks if one of our third party integrations faked an {@link Event}. - * Faked {@link Event Events} should be ignored in our logic. - * + * * @param event * The {@link Event} to test - * + * * @return Whether this is a fake event */ public boolean isEventFaked(@Nonnull Event event) { - // This can be changed to "FakeEvent" in a later version - return isMcMMOInstalled && event instanceof FakeBlockBreakEvent; + // mcMMO fires "fake" events (marked by com.gmail.nossr50.events.fake.FakeEvent) for its + // abilities; resolve that marker reflectively so we don't act on them. + if (!isMcMMOInstalled) { + return false; + } + + try { + return Class.forName("com.gmail.nossr50.events.fake.FakeEvent").isInstance(event); + } catch (Throwable e) { + return false; + } } /** * This checks if one of our third party integrations has placed a custom - * {@link Block} at this {@link Location}. - * + * {@link Block} at this location. + * * @param block * The {@link Block} to check - * - * @return Whether a different custom {@link Block} exists at that {@link Location} + * + * @return Whether a different custom {@link Block} exists at that location */ - @SuppressWarnings("deprecation") public boolean isCustomBlock(@Nonnull Block block) { - if (isItemsAdderInstalled) { - try { - return CustomBlock.byAlreadyPlaced(block) != null; - } catch (Exception | LinkageError x) { - logError("ItemsAdder", x); - } + // ItemsAdder: CustomBlock.byAlreadyPlaced(block) != null, resolved reflectively. + if (!isItemsAdderInstalled) { + return false; } - return false; + try { + Object result = ReflectionCompat.invokeStatic(Class.forName("dev.lone.itemsadder.api.CustomBlock"), "byAlreadyPlaced", block); + return result != null; + } catch (Throwable e) { + return false; + } } /** * This checks if one of our third party integrations defines a given * {@link ItemStack} as custom. - * + * * @param item * The {@link ItemStack} to check - * + * * @return Whether this {@link ItemStack} is a custom item */ - @SuppressWarnings("deprecation") public boolean isCustomItem(@Nonnull ItemStack item) { - if (isItemsAdderInstalled) { - try { - return ItemsAdder.isCustomItem(item); - } catch (Exception | LinkageError x) { - logError("ItemsAdder", x); - } + // ItemsAdder: CustomStack.byItemStack(item) != null, resolved reflectively. + if (!isItemsAdderInstalled) { + return false; } - return false; + try { + Object result = ReflectionCompat.invokeStatic(Class.forName("dev.lone.itemsadder.api.CustomStack"), "byItemStack", item); + return result != null; + } catch (Throwable e) { + return false; + } } /** * This method removes any temporary enchantments from the given {@link ItemStack}. - * Some plugins apply enchantments for a short amount of time and remove it later. - * We don't want these items to be exploited using an {@link AutoDisenchanter} for example, - * so we want to be able to strip those temporary enchantments in advance. - * + * * @param item * The {@link ItemStack} */ public void removeTemporaryEnchantments(@Nonnull ItemStack item) { - if (isMcMMOInstalled) { - try { - SkillUtils.removeAbilityBuff(item); - } catch (Exception | LinkageError x) { - logError("mcMMO", x); - } + // mcMMO applies temporary ability buffs; remove them via SkillUtils reflectively. + if (!isMcMMOInstalled) { + return; + } + + try { + ReflectionCompat.invokeStatic(Class.forName("com.gmail.nossr50.util.skills.SkillUtils"), "removeAbilityBuff", item); + } catch (Throwable e) { + // mcMMO API mismatch - ignore. } } diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/McMMOIntegration.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/McMMOIntegration.java new file mode 100644 index 0000000000..594ad52bd2 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/McMMOIntegration.java @@ -0,0 +1,106 @@ +package io.github.thebusybiscuit.slimefun5.integrations; + +import javax.annotation.Nonnull; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.EventExecutor; + +import io.github.thebusybiscuit.slimefun5.api.events.AutoDisenchantEvent; +import io.github.thebusybiscuit.slimefun5.api.events.BlockPlacerPlaceEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; + +/** + * This handles all integrations with mcMMO. + * + *

+ * Java-8 universal port: the mcMMO API is Java-17 bytecode and cannot sit on the Java-8 compile + * classpath, so all mcMMO calls go through reflection. The handlers on Slimefun's own events + * ({@link BlockPlacerPlaceEvent}, {@link AutoDisenchantEvent}) are normal {@code @EventHandler}s; the + * handler for mcMMO's own {@code McMMOPlayerSalvageCheckEvent} is registered via a dynamic + * {@link EventExecutor} because that event class only exists when mcMMO is installed. + * + * @author TheBusyBiscuit + */ +class McMMOIntegration implements Listener { + + private static final String SALVAGE_EVENT = "com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent"; + private static final String MCMMO_CLASS = "com.gmail.nossr50.mcMMO"; + private static final String SKILL_UTILS_CLASS = "com.gmail.nossr50.util.skills.SkillUtils"; + + private final Slimefun plugin; + + McMMOIntegration(@Nonnull Slimefun plugin) { + this.plugin = plugin; + } + + public void register() { + plugin.getServer().getPluginManager().registerEvents(this, plugin); + + // mcMMO's salvage event only exists when mcMMO is installed - register it reflectively. + try { + Class salvageEvent = Class.forName(SALVAGE_EVENT).asSubclass(Event.class); + EventExecutor executor = (listener, event) -> onItemSalvage(event); + plugin.getServer().getPluginManager().registerEvent(salvageEvent, this, EventPriority.NORMAL, executor, plugin); + } catch (ClassNotFoundException e) { + // mcMMO without the salvage skill - nothing to hook. + Slimefun.logger().info("mcMMO salvage event not present; skipping that hook."); + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onBlockPlacerPlace(BlockPlacerPlaceEvent e) { + // This registers blocks placed by the BlockPlacer as "player-placed" + try { + Object placeStore = ReflectionCompat.invokeStatic(Class.forName(MCMMO_CLASS), "getPlaceStore"); + ReflectionCompat.invoke(placeStore, "setTrue", e.getBlock()); + } catch (Exception | LinkageError x) { + Slimefun.getIntegrations().logError("mcMMO", x); + } + } + + @EventHandler(ignoreCancelled = true) + public void onAutoDisenchant(AutoDisenchantEvent e) { + try { + ReflectionCompat.invokeStatic(Class.forName(SKILL_UTILS_CLASS), "removeAbilityBuff", e.getItem()); + } catch (Exception | LinkageError x) { + Slimefun.getIntegrations().logError("mcMMO", x); + } + } + + private void onItemSalvage(@Nonnull Object event) { + // Prevent Slimefun items from being salvaged + Object salvageItem = ReflectionCompat.invoke(event, "getSalvageItem"); + + if (salvageItem instanceof ItemStack && !isSalvageable((ItemStack) salvageItem)) { + ReflectionCompat.invoke(event, "setCancelled", true); + Object player = ReflectionCompat.invoke(event, "getPlayer"); + + if (player instanceof Player) { + Slimefun.getLocalization().sendMessage((Player) player, "anvil.mcmmo-salvaging"); + } + } + } + + /** + * This method checks if an {@link ItemStack} can be salvaged or not. + * We basically don't want players to salvage any {@link SlimefunItem} unless + * it is a {@link VanillaItem}. + * + * @param item + * The {@link ItemStack} to check + * + * @return Whether this item can be safely salvaged + */ + private boolean isSalvageable(@Nonnull ItemStack item) { + SlimefunItem sfItem = SlimefunItem.getByItem(item); + return sfItem == null || sfItem instanceof VanillaItem; + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/OrebfuscatorIntegration.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/OrebfuscatorIntegration.java new file mode 100644 index 0000000000..e29d7f012a --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/OrebfuscatorIntegration.java @@ -0,0 +1,93 @@ +package io.github.thebusybiscuit.slimefun5.integrations; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; + +import org.bukkit.Bukkit; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.plugin.ServicesManager; + +import io.github.thebusybiscuit.slimefun5.api.events.BlockPlacerPlaceEvent; +import io.github.thebusybiscuit.slimefun5.api.events.ExplosiveToolBreakBlocksEvent; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.events.ReactorExplodeEvent; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.GoldPan; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; + +/** + * This handles block breaks with Orebfuscator. + * + *

+ * Java-8 universal port: {@code net.imprex.orebfuscator.api.OrebfuscatorService} is Java-17 bytecode + * and cannot sit on the Java-8 compile classpath, so the service is held as an opaque {@link Object} + * and {@code deobfuscate(Collection)} is invoked reflectively. All of this class's event handlers are + * on Slimefun's own events, so the class itself references no Orebfuscator type in its bytecode and is + * only ever registered when Orebfuscator is actually installed. + * + * @author NgLoader + */ +class OrebfuscatorIntegration implements Listener { + + private static final String SERVICE_CLASS = "net.imprex.orebfuscator.api.OrebfuscatorService"; + + private final Slimefun plugin; + private Object service; + + OrebfuscatorIntegration(@Nonnull Slimefun plugin) { + this.plugin = plugin; + } + + /** + * Resolves the Orebfuscator service reflectively and registers the listener. + */ + public void register() { + ServicesManager servicesManager = Bukkit.getServer().getServicesManager(); + + try { + Class serviceClass = Class.forName(SERVICE_CLASS); + this.service = servicesManager.getRegistration(serviceClass.asSubclass(Object.class)).getProvider(); + } catch (ClassNotFoundException | RuntimeException e) { + // Re-throw so the IntegrationsManager logs and skips this integration. + throw new IllegalStateException("Could not resolve the Orebfuscator service", e); + } + + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + private void deobfuscate(@Nonnull Object blocks) { + ReflectionCompat.invoke(service, "deobfuscate", blocks); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onBlockPlacerPlace(BlockPlacerPlaceEvent event) { + deobfuscate(Arrays.asList(event.getBlock(), event.getBlockPlacer())); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onExplosiveToolBreakBlocks(ExplosiveToolBreakBlocksEvent event) { + Set blocks = new HashSet<>(); + blocks.addAll(event.getAdditionalBlocks()); + blocks.add(event.getPrimaryBlock()); + deobfuscate(blocks); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onReactorExplode(ReactorExplodeEvent event) { + deobfuscate(Arrays.asList(event.getLocation().getBlock())); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onGoldPanUse(PlayerRightClickEvent event) { + if (event.getSlimefunItem().isPresent() && event.getClickedBlock().isPresent() && event.getSlimefunItem().get() instanceof GoldPan) { + deobfuscate(Arrays.asList(event.getClickedBlock().get())); + } + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/PlaceholderAPIIntegration.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/PlaceholderAPIIntegration.java similarity index 80% rename from src/main/java/io/github/thebusybiscuit/slimefun4/integrations/PlaceholderAPIIntegration.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/PlaceholderAPIIntegration.java index 826fb1e4b5..ef30951231 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/PlaceholderAPIIntegration.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/PlaceholderAPIIntegration.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.integrations; +package io.github.thebusybiscuit.slimefun5.integrations; import java.util.Optional; import java.util.Set; @@ -10,9 +10,9 @@ import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.expansion.PlaceholderExpansion; @@ -82,8 +82,8 @@ public String onRequest(@Nullable OfflinePlayer p, @Nonnull String params) { if (profile.isPresent()) { Stream stream = profile.get().getResearches().stream(); return String.valueOf(stream.mapToInt(Research::getCost).sum()); - } else if (p instanceof Player player) { - return getProfilePlaceholder(player); + } else if (p instanceof Player) { + Player player = (Player) p; return getProfilePlaceholder(player); } } @@ -93,8 +93,8 @@ public String onRequest(@Nullable OfflinePlayer p, @Nonnull String params) { if (profile.isPresent()) { Set set = profile.get().getResearches(); return String.valueOf(set.size()); - } else if (p instanceof Player player) { - return getProfilePlaceholder(player); + } else if (p instanceof Player) { + Player player = (Player) p; return getProfilePlaceholder(player); } } @@ -108,8 +108,8 @@ public String onRequest(@Nullable OfflinePlayer p, @Nonnull String params) { if (profile.isPresent()) { Set set = profile.get().getResearches(); return String.valueOf(Math.round(((set.size() * 100.0F) / Slimefun.getRegistry().getResearches().size()) * 100.0F) / 100.0F); - } else if (p instanceof Player player) { - return getProfilePlaceholder(player); + } else if (p instanceof Player) { + Player player = (Player) p; return getProfilePlaceholder(player); } } @@ -118,8 +118,8 @@ public String onRequest(@Nullable OfflinePlayer p, @Nonnull String params) { if (profile.isPresent()) { return profile.get().getTitle(); - } else if (p instanceof Player player) { - return getProfilePlaceholder(player); + } else if (p instanceof Player) { + Player player = (Player) p; return getProfilePlaceholder(player); } } @@ -131,8 +131,8 @@ public String onRequest(@Nullable OfflinePlayer p, @Nonnull String params) { return Slimefun.getProfiler().getTime(); } - if (isPlaceholder(p, false, params, "language") && p instanceof Player player) { - return Slimefun.getLocalization().getLanguage(player).getName(player); + if (isPlaceholder(p, false, params, "language") && p instanceof Player) { + Player player = (Player) p; return Slimefun.getLocalization().getLanguage(player).getName(player); } return null; @@ -144,3 +144,4 @@ private String getProfilePlaceholder(@Nonnull Player p) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/WorldEditIntegration.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/WorldEditIntegration.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/integrations/WorldEditIntegration.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/WorldEditIntegration.java index 5ebb4ad1bb..2035bbb3a3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/WorldEditIntegration.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/WorldEditIntegration.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.integrations; +package io.github.thebusybiscuit.slimefun5.integrations; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -43,7 +45,7 @@ public void wrapForLogging(EditSessionEvent event) { @Override public > boolean setBlock(BlockVector3 pos, T block) throws WorldEditException { - if (block.getBlockType().getMaterial().isAir()) { + if (MaterialCompat.isAir(block.getBlockType().getMaterial())) { World world = Bukkit.getWorld(event.getWorld().getName()); if (world != null) { @@ -62,3 +64,4 @@ public > boolean setBlock(BlockVector3 pos, T bloc } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/package-info.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/integrations/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/package-info.java index 61c871610c..ce999458e5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/integrations/package-info.java @@ -1,4 +1,4 @@ /** * This package holds classes which are related to integrations between Slimefun and Third-Party plugins. */ -package io.github.thebusybiscuit.slimefun4.integrations; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.integrations; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/libraries/keys/Keyed.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/libraries/keys/Keyed.java new file mode 100644 index 0000000000..94708c4456 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/libraries/keys/Keyed.java @@ -0,0 +1,14 @@ +package io.github.thebusybiscuit.slimefun5.libraries.keys; + +/** + * Java-8 universal port: an own, relocated stand-in for {@code org.bukkit.Keyed} (MC 1.12+). + *

+ * See {@link NamespacedKey}. Many always-loaded Slimefun types {@code implements Keyed}; declaring the + * real {@code org.bukkit.Keyed} would make those classes fail to load on 1.8–1.11 servers (the + * interface is absent there and Bukkit refuses to load plugin-shipped {@code org.bukkit.*} classes). + * This own interface lives in Slimefun's package, is bundled, and loads on every version. + */ +public interface Keyed { + + NamespacedKey getKey(); +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/libraries/keys/NamespacedKey.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/libraries/keys/NamespacedKey.java new file mode 100644 index 0000000000..54a1a769c1 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/libraries/keys/NamespacedKey.java @@ -0,0 +1,92 @@ +package io.github.thebusybiscuit.slimefun5.libraries.keys; + +import org.bukkit.plugin.Plugin; + +/** + * Java-8 universal port: an own, relocated stand-in for {@code org.bukkit.NamespacedKey} (which only + * exists on MC 1.12+). + *

+ * Slimefun's identity system uses namespaced keys pervasively, in always-loaded class signatures + * (many types {@code implements Keyed}). Bukkit's {@code PluginClassLoader} refuses to load + * {@code org.bukkit.*} classes shipped inside a plugin jar, so the real {@code NamespacedKey} cannot be + * provided on 1.8–1.11. This own type lives in Slimefun's own package, is bundled into the jar, + * and is therefore loadable on every version. It is a plain {@code (namespace, key)} identity pair; + * conversion to the real {@code org.bukkit.NamespacedKey} happens only at the few server-API boundaries + * (PDC, registries, recipe lookups) via {@code BukkitKeys}, all of which are 1.12+/1.14+ only. + * + *

+ * The public surface mirrors {@code org.bukkit.NamespacedKey} so call sites read identically after the + * import swap. + */ +public final class NamespacedKey { + + public static final String MINECRAFT = "minecraft"; + public static final String BUKKIT = "bukkit"; + + private final String namespace; + private final String key; + + public NamespacedKey(Plugin owner, String key) { + this.namespace = owner == null ? "minecraft" : owner.getName().toLowerCase(); + this.key = key; + } + + public NamespacedKey(String namespace, String key) { + this.namespace = namespace; + this.key = key; + } + + public static NamespacedKey minecraft(String key) { + return new NamespacedKey("minecraft", key); + } + + /** + * Mirrors {@code org.bukkit.NamespacedKey#fromString}: parses a {@code "namespace:key"} string, + * defaulting the namespace to {@code minecraft} when no colon is present. + */ + public static NamespacedKey fromString(String string) { + if (string == null || string.isEmpty()) { + return null; + } + + int index = string.indexOf(':'); + + if (index < 0) { + return new NamespacedKey(MINECRAFT, string); + } + + return new NamespacedKey(string.substring(0, index), string.substring(index + 1)); + } + + public String getNamespace() { + return namespace; + } + + public String getKey() { + return key; + } + + @Override + public int hashCode() { + return (namespace + ":" + key).hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (!(obj instanceof NamespacedKey)) { + return false; + } + + NamespacedKey other = (NamespacedKey) obj; + return namespace.equals(other.namespace) && key.equals(other.key); + } + + @Override + public String toString() { + return namespace + ":" + key; + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/Storage.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/Storage.java similarity index 84% rename from src/main/java/io/github/thebusybiscuit/slimefun4/storage/Storage.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/Storage.java index 037db2afc3..310d37ce83 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/Storage.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/Storage.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.storage; +package io.github.thebusybiscuit.slimefun5.storage; -import io.github.thebusybiscuit.slimefun4.storage.data.PlayerData; +import io.github.thebusybiscuit.slimefun5.storage.data.PlayerData; import javax.annotation.concurrent.ThreadSafe; @@ -24,3 +24,4 @@ public interface Storage { void savePlayerData(UUID uuid, PlayerData data); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/backend/legacy/LegacyStorage.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/backend/legacy/LegacyStorage.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/storage/backend/legacy/LegacyStorage.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/backend/legacy/LegacyStorage.java index f051a3b846..eb1dd30200 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/backend/legacy/LegacyStorage.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/backend/legacy/LegacyStorage.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.storage.backend.legacy; +package io.github.thebusybiscuit.slimefun5.storage.backend.legacy; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.storage.Storage; -import io.github.thebusybiscuit.slimefun4.storage.data.PlayerData; +import io.github.thebusybiscuit.slimefun5.api.gps.Waypoint; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.storage.Storage; +import io.github.thebusybiscuit.slimefun5.storage.data.PlayerData; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -145,3 +145,4 @@ public void savePlayerData(@Nonnull UUID uuid, @Nonnull PlayerData data) { Slimefun.getAnalyticsService().recordPlayerProfileDataTime("legacy", false, end - start); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/data/PlayerData.java similarity index 90% rename from src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/data/PlayerData.java index 8615b6ee5f..323797b6b9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/storage/data/PlayerData.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/storage/data/PlayerData.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.storage.data; +package io.github.thebusybiscuit.slimefun5.storage.data; import com.google.common.annotations.Beta; -import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.api.gps.Waypoint; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; import java.util.HashMap; import java.util.HashSet; @@ -16,7 +16,7 @@ import org.apache.commons.lang.Validate; /** - * The data which backs {@link io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile} + * The data which backs {@link io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile} * * This API is still experimental, it may change without notice. */ @@ -94,3 +94,4 @@ public void removeWaypoint(@Nonnull Waypoint waypoint) { waypoints.remove(waypoint); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ArmorStandUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ArmorStandUtils.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/ArmorStandUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ArmorStandUtils.java index e2cf5ae10f..abb3ef348d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ArmorStandUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ArmorStandUtils.java @@ -1,14 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ReflectionCompat; import javax.annotation.Nonnull; import io.papermc.lib.PaperLib; import org.bukkit.Location; import org.bukkit.entity.ArmorStand; -import io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector; +import io.github.thebusybiscuit.slimefun5.core.services.holograms.HologramsService; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.HologramProjector; /** * This class holds utilities for {@link ArmorStand}, useful for classes @@ -60,15 +61,27 @@ private ArmorStandUtils() {} return armorStand; } - return location.getWorld().spawn(location, ArmorStand.class, ArmorStandUtils::setupArmorStand); + // The pre-spawn consumer overload of World#spawn is 1.11+; reached reflectively to keep its + // flicker-free behaviour on modern servers (this branch only runs on 1.20.2+). + java.util.function.Consumer setup = ArmorStandUtils::setupArmorStand; + Object spawned = ReflectionCompat.invoke(location.getWorld(), "spawn", location, ArmorStand.class, setup); + + if (spawned instanceof ArmorStand) { + return (ArmorStand) spawned; + } + + ArmorStand fallback = location.getWorld().spawn(location, ArmorStand.class); + setupArmorStand(fallback); + return fallback; } private static void setupArmorStand(ArmorStand armorStand) { armorStand.setVisible(false); - armorStand.setSilent(true); + ReflectionCompat.invoke(armorStand, "setSilent", true); armorStand.setMarker(true); armorStand.setGravity(false); armorStand.setBasePlate(false); armorStand.setRemoveWhenFarAway(false); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChargeUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChargeUtils.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChargeUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChargeUtils.java index 9c23ff0075..ba45d8ec32 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChargeUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChargeUtils.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.math.BigDecimal; import java.math.RoundingMode; @@ -10,14 +12,12 @@ import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.persistence.PersistentDataContainer; -import org.bukkit.persistence.PersistentDataType; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This is just a simple helper class to provide static methods to the {@link Rechargeable} @@ -46,7 +46,7 @@ public static void setCharge(@Nonnull ItemMeta meta, float charge, float capacit float value = decimal.floatValue(); NamespacedKey key = Slimefun.getRegistry().getItemChargeDataKey(); - meta.getPersistentDataContainer().set(key, PersistentDataType.FLOAT, value); + PdcCompat.set(meta, key, "FLOAT", value); List lore = meta.hasLore() ? meta.getLore() : new ArrayList<>(); for (int i = 0; i < lore.size(); i++) { @@ -67,8 +67,7 @@ public static float getCharge(@Nonnull ItemMeta meta) { Validate.notNull(meta, "Meta cannot be null!"); NamespacedKey key = Slimefun.getRegistry().getItemChargeDataKey(); - PersistentDataContainer container = meta.getPersistentDataContainer(); - Float value = container.get(key, PersistentDataType.FLOAT); + Float value = (Float) PdcCompat.get(meta, key, "FLOAT"); // If persistent data is available, we just return this value if (value != null) { @@ -82,7 +81,7 @@ public static float getCharge(@Nonnull ItemMeta meta) { String data = ChatColor.stripColor(PatternUtils.SLASH_SEPARATOR.split(line)[0].replace(LORE_PREFIX, "")); float loreValue = Float.parseFloat(data); - container.set(key, PersistentDataType.FLOAT, loreValue); + PdcCompat.set(meta, key, "FLOAT", loreValue); return loreValue; } } @@ -91,3 +90,4 @@ public static float getCharge(@Nonnull ItemMeta meta) { return 0; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChatUtils.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChatUtils.java index 829e5891c3..c9803d3b86 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChatUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.Locale; import java.util.function.Consumer; @@ -12,7 +12,7 @@ import io.github.bakedlibs.dough.chat.ChatInput; import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This utility class contains a few static methods that are all about {@link String} manipulation @@ -103,3 +103,4 @@ public static void awaitInput(@Nonnull Player p, @Nonnull Consumer callb } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChestMenuUtils.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChestMenuUtils.java index dc31cf2b76..9b47cf3276 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ChestMenuUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.Arrays; import java.util.List; @@ -8,18 +8,20 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import org.bukkit.ChatColor; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedItemFlag; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; @@ -28,22 +30,22 @@ public final class ChestMenuUtils { private ChestMenuUtils() {} - private static final ItemStack UI_BACKGROUND = new SlimefunItemStack("_UI_BACKGROUND", Material.GRAY_STAINED_GLASS_PANE, " ").item(); - private static final ItemStack INPUT_SLOT = new SlimefunItemStack("_UI_INPUT_SLOT", Material.CYAN_STAINED_GLASS_PANE, " ").item(); - private static final ItemStack OUTPUT_SLOT = new SlimefunItemStack("_UI_OUTPUT_SLOT", Material.ORANGE_STAINED_GLASS_PANE, " ").item(); + private static final ItemStack UI_BACKGROUND = new SlimefunItemStack("_UI_BACKGROUND", MaterialCompat.stack(XMaterial.GRAY_STAINED_GLASS_PANE), " ").item(); + private static final ItemStack INPUT_SLOT = new SlimefunItemStack("_UI_INPUT_SLOT", MaterialCompat.stack(XMaterial.CYAN_STAINED_GLASS_PANE), " ").item(); + private static final ItemStack OUTPUT_SLOT = new SlimefunItemStack("_UI_OUTPUT_SLOT", MaterialCompat.stack(XMaterial.ORANGE_STAINED_GLASS_PANE), " ").item(); private static final ItemStack NO_PERMISSION = new SlimefunItemStack("_UI_NO_PERMISSION", Material.BARRIER, "No Permission").item(); private static final ItemStack NOT_RESEARCHED = new SlimefunItemStack("_UI_NOT_RESEARCHED", Material.BARRIER, "Not researched").item(); - private static final ItemStack BACK_BUTTON = new SlimefunItemStack("_UI_BACK", Material.ENCHANTED_BOOK, "&7\u21E6 Back", meta -> meta.addItemFlags(ItemFlag.HIDE_ENCHANTS)).item(); - private static final ItemStack MENU_BUTTON = new SlimefunItemStack("_UI_MENU", Material.COMPARATOR, "&eSettings / Info", "", "&7\u21E8 Click to see more").item(); + private static final ItemStack BACK_BUTTON = new SlimefunItemStack("_UI_BACK", Material.ENCHANTED_BOOK, "&7\u21E6 Back", meta -> VersionedItemFlag.addFlags(meta, VersionedItemFlag.HIDE_ENCHANTS)).item(); + private static final ItemStack MENU_BUTTON = new SlimefunItemStack("_UI_MENU", XMaterial.COMPARATOR.parseMaterial(), "&eSettings / Info", "", "&7\u21E8 Click to see more").item(); private static final ItemStack SEARCH_BUTTON = new SlimefunItemStack("_UI_SEARCH", Material.NAME_TAG, "&bSearch").item(); - private static final ItemStack WIKI_BUTTON = new SlimefunItemStack("_UI_WIKI", Material.KNOWLEDGE_BOOK, "&3Slimefun Wiki").item(); + private static final ItemStack WIKI_BUTTON = new SlimefunItemStack("_UI_WIKI", XMaterial.KNOWLEDGE_BOOK.parseMaterial(), "&3Slimefun Wiki").item(); - private static final ItemStack PREV_BUTTON_ACTIVE = new SlimefunItemStack("_UI_PREVIOUS_ACTIVE", Material.LIME_STAINED_GLASS_PANE, "&r\u21E6 Previous Page").item(); - private static final ItemStack NEXT_BUTTON_ACTIVE = new SlimefunItemStack("_UI_NEXT_ACTIVE", Material.LIME_STAINED_GLASS_PANE, "&rNext Page \u21E8").item(); - private static final ItemStack PREV_BUTTON_INACTIVE = new SlimefunItemStack("_UI_PREVIOUS_INACTIVE", Material.BLACK_STAINED_GLASS_PANE, "&8\u21E6 Previous Page").item(); - private static final ItemStack NEXT_BUTTON_INACTIVE = new SlimefunItemStack("_UI_NEXT_INACTIVE", Material.BLACK_STAINED_GLASS_PANE, "&8Next Page \u21E8").item(); + private static final ItemStack PREV_BUTTON_ACTIVE = new SlimefunItemStack("_UI_PREVIOUS_ACTIVE", MaterialCompat.stack(XMaterial.LIME_STAINED_GLASS_PANE), "&r\u21E6 Previous Page").item(); + private static final ItemStack NEXT_BUTTON_ACTIVE = new SlimefunItemStack("_UI_NEXT_ACTIVE", MaterialCompat.stack(XMaterial.LIME_STAINED_GLASS_PANE), "&rNext Page \u21E8").item(); + private static final ItemStack PREV_BUTTON_INACTIVE = new SlimefunItemStack("_UI_PREVIOUS_INACTIVE", MaterialCompat.stack(XMaterial.BLACK_STAINED_GLASS_PANE), "&8\u21E6 Previous Page").item(); + private static final ItemStack NEXT_BUTTON_INACTIVE = new SlimefunItemStack("_UI_NEXT_INACTIVE", MaterialCompat.stack(XMaterial.BLACK_STAINED_GLASS_PANE), "&8Next Page \u21E8").item(); private static final ChestMenu.AdvancedMenuClickHandler OUTPUT_HANDLER = new ChestMenu.AdvancedMenuClickHandler() { @@ -154,10 +156,10 @@ public static void updateProgressbar(@Nonnull ChestMenu menu, int slot, int time ItemStack item = indicator.clone(); ItemMeta im = item.getItemMeta(); - im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + VersionedItemFlag.addFlags(im, VersionedItemFlag.HIDE_ATTRIBUTES); - if (im instanceof Damageable damageable) { - damageable.setDamage(getDurability(item, timeLeft, time)); + if (im instanceof Damageable) { + Damageable damageable = (Damageable) im; damageable.setDamage(getDurability(item, timeLeft, time)); } im.setDisplayName(" "); @@ -194,3 +196,4 @@ private static short getDurability(@Nonnull ItemStack item, int timeLeft, int ma } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ColoredMaterial.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ColoredMaterial.java new file mode 100644 index 0000000000..0927a53672 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/ColoredMaterial.java @@ -0,0 +1,281 @@ +package io.github.thebusybiscuit.slimefun5.utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import org.apache.commons.lang.Validate; +import org.bukkit.DyeColor; +import org.bukkit.Material; + +import com.cryptomorin.xseries.XMaterial; + +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; + +/** + * This class holds a few ordered {@link List Lists} that hold colored variants + * of {@link Material}. + *

+ * Java-8 universal port: the colored variants are declared as {@link XMaterial} and resolved to the + * running server's {@link Material} at class-load. On 1.13+ all 16 colors resolve. On legacy servers + * (pre-flattening) some color families did not exist yet (e.g. concrete = 1.12, shulker boxes = 1.11), + * and individual colors were data values on a shared {@link Material} rather than distinct materials; + * those entries resolve to {@code null} here. Callers running below 1.13 must tolerate null entries. + * + * @author TheBusyBiscuit + * + * @see SlimefunTag + * + */ +public enum ColoredMaterial { + + // @formatter:off (We want this to stay formatted like this) + + /** + * This {@link List} contains all wool colors ordered by their appearance ingame. + */ + WOOL(new XMaterial[] { + XMaterial.WHITE_WOOL, + XMaterial.ORANGE_WOOL, + XMaterial.MAGENTA_WOOL, + XMaterial.LIGHT_BLUE_WOOL, + XMaterial.YELLOW_WOOL, + XMaterial.LIME_WOOL, + XMaterial.PINK_WOOL, + XMaterial.GRAY_WOOL, + XMaterial.LIGHT_GRAY_WOOL, + XMaterial.CYAN_WOOL, + XMaterial.PURPLE_WOOL, + XMaterial.BLUE_WOOL, + XMaterial.BROWN_WOOL, + XMaterial.GREEN_WOOL, + XMaterial.RED_WOOL, + XMaterial.BLACK_WOOL + }), + + /** + * This {@link List} contains all carpet colors ordered by their appearance ingame. + */ + CARPET(new XMaterial[] { + XMaterial.WHITE_CARPET, + XMaterial.ORANGE_CARPET, + XMaterial.MAGENTA_CARPET, + XMaterial.LIGHT_BLUE_CARPET, + XMaterial.YELLOW_CARPET, + XMaterial.LIME_CARPET, + XMaterial.PINK_CARPET, + XMaterial.GRAY_CARPET, + XMaterial.LIGHT_GRAY_CARPET, + XMaterial.CYAN_CARPET, + XMaterial.PURPLE_CARPET, + XMaterial.BLUE_CARPET, + XMaterial.BROWN_CARPET, + XMaterial.GREEN_CARPET, + XMaterial.RED_CARPET, + XMaterial.BLACK_CARPET + }), + + /** + * This {@link List} contains all stained glass colors ordered by their appearance ingame. + */ + STAINED_GLASS(new XMaterial[] { + XMaterial.WHITE_STAINED_GLASS, + XMaterial.ORANGE_STAINED_GLASS, + XMaterial.MAGENTA_STAINED_GLASS, + XMaterial.LIGHT_BLUE_STAINED_GLASS, + XMaterial.YELLOW_STAINED_GLASS, + XMaterial.LIME_STAINED_GLASS, + XMaterial.PINK_STAINED_GLASS, + XMaterial.GRAY_STAINED_GLASS, + XMaterial.LIGHT_GRAY_STAINED_GLASS, + XMaterial.CYAN_STAINED_GLASS, + XMaterial.PURPLE_STAINED_GLASS, + XMaterial.BLUE_STAINED_GLASS, + XMaterial.BROWN_STAINED_GLASS, + XMaterial.GREEN_STAINED_GLASS, + XMaterial.RED_STAINED_GLASS, + XMaterial.BLACK_STAINED_GLASS + }), + + /** + * This {@link List} contains all stained glass pane colors ordered by their appearance ingame. + */ + STAINED_GLASS_PANE(new XMaterial[] { + XMaterial.WHITE_STAINED_GLASS_PANE, + XMaterial.ORANGE_STAINED_GLASS_PANE, + XMaterial.MAGENTA_STAINED_GLASS_PANE, + XMaterial.LIGHT_BLUE_STAINED_GLASS_PANE, + XMaterial.YELLOW_STAINED_GLASS_PANE, + XMaterial.LIME_STAINED_GLASS_PANE, + XMaterial.PINK_STAINED_GLASS_PANE, + XMaterial.GRAY_STAINED_GLASS_PANE, + XMaterial.LIGHT_GRAY_STAINED_GLASS_PANE, + XMaterial.CYAN_STAINED_GLASS_PANE, + XMaterial.PURPLE_STAINED_GLASS_PANE, + XMaterial.BLUE_STAINED_GLASS_PANE, + XMaterial.BROWN_STAINED_GLASS_PANE, + XMaterial.GREEN_STAINED_GLASS_PANE, + XMaterial.RED_STAINED_GLASS_PANE, + XMaterial.BLACK_STAINED_GLASS_PANE + }), + + /** + * This {@link List} contains all terracotta colors ordered by their appearance ingame. + */ + TERRACOTTA(new XMaterial[] { + XMaterial.WHITE_TERRACOTTA, + XMaterial.ORANGE_TERRACOTTA, + XMaterial.MAGENTA_TERRACOTTA, + XMaterial.LIGHT_BLUE_TERRACOTTA, + XMaterial.YELLOW_TERRACOTTA, + XMaterial.LIME_TERRACOTTA, + XMaterial.PINK_TERRACOTTA, + XMaterial.GRAY_TERRACOTTA, + XMaterial.LIGHT_GRAY_TERRACOTTA, + XMaterial.CYAN_TERRACOTTA, + XMaterial.PURPLE_TERRACOTTA, + XMaterial.BLUE_TERRACOTTA, + XMaterial.BROWN_TERRACOTTA, + XMaterial.GREEN_TERRACOTTA, + XMaterial.RED_TERRACOTTA, + XMaterial.BLACK_TERRACOTTA + }), + + /** + * This {@link List} contains all glazed terracotta colors ordered by their appearance ingame. + */ + GLAZED_TERRACOTTA(new XMaterial[] { + XMaterial.WHITE_GLAZED_TERRACOTTA, + XMaterial.ORANGE_GLAZED_TERRACOTTA, + XMaterial.MAGENTA_GLAZED_TERRACOTTA, + XMaterial.LIGHT_BLUE_GLAZED_TERRACOTTA, + XMaterial.YELLOW_GLAZED_TERRACOTTA, + XMaterial.LIME_GLAZED_TERRACOTTA, + XMaterial.PINK_GLAZED_TERRACOTTA, + XMaterial.GRAY_GLAZED_TERRACOTTA, + XMaterial.LIGHT_GRAY_GLAZED_TERRACOTTA, + XMaterial.CYAN_GLAZED_TERRACOTTA, + XMaterial.PURPLE_GLAZED_TERRACOTTA, + XMaterial.BLUE_GLAZED_TERRACOTTA, + XMaterial.BROWN_GLAZED_TERRACOTTA, + XMaterial.GREEN_GLAZED_TERRACOTTA, + XMaterial.RED_GLAZED_TERRACOTTA, + XMaterial.BLACK_GLAZED_TERRACOTTA + }), + + /** + * This {@link List} contains all concrete colors ordered by their appearance ingame. + */ + CONCRETE(new XMaterial[] { + XMaterial.WHITE_CONCRETE, + XMaterial.ORANGE_CONCRETE, + XMaterial.MAGENTA_CONCRETE, + XMaterial.LIGHT_BLUE_CONCRETE, + XMaterial.YELLOW_CONCRETE, + XMaterial.LIME_CONCRETE, + XMaterial.PINK_CONCRETE, + XMaterial.GRAY_CONCRETE, + XMaterial.LIGHT_GRAY_CONCRETE, + XMaterial.CYAN_CONCRETE, + XMaterial.PURPLE_CONCRETE, + XMaterial.BLUE_CONCRETE, + XMaterial.BROWN_CONCRETE, + XMaterial.GREEN_CONCRETE, + XMaterial.RED_CONCRETE, + XMaterial.BLACK_CONCRETE + }), + + /** + * This {@link List} contains all shulker box colors ordered by their appearance ingame. + */ + SHULKER_BOX(new XMaterial[] { + XMaterial.WHITE_SHULKER_BOX, + XMaterial.ORANGE_SHULKER_BOX, + XMaterial.MAGENTA_SHULKER_BOX, + XMaterial.LIGHT_BLUE_SHULKER_BOX, + XMaterial.YELLOW_SHULKER_BOX, + XMaterial.LIME_SHULKER_BOX, + XMaterial.PINK_SHULKER_BOX, + XMaterial.GRAY_SHULKER_BOX, + XMaterial.LIGHT_GRAY_SHULKER_BOX, + XMaterial.CYAN_SHULKER_BOX, + XMaterial.PURPLE_SHULKER_BOX, + XMaterial.BLUE_SHULKER_BOX, + XMaterial.BROWN_SHULKER_BOX, + XMaterial.GREEN_SHULKER_BOX, + XMaterial.RED_SHULKER_BOX, + XMaterial.BLACK_SHULKER_BOX + }); + + // @formatter:on + + /** + * This is our {@link List} of {@link Material Materials}, the backbone of this enum. + * Entries may be {@code null} on servers older than the version that introduced a given color + * (see the class-level note). + */ + private final List list; + + /** + * This creates a new constant of {@link ColoredMaterial}. + * The array must have a length of 16. Each {@link XMaterial} is resolved to the running + * server's {@link Material}; colors that do not exist on the current version resolve to + * {@code null} (kept in the list so colour-index ordering is preserved). + * + * @param materials + * The {@link XMaterial} variants for this {@link ColoredMaterial}. + */ + ColoredMaterial(@Nonnull XMaterial[] materials) { + Validate.isTrue(materials.length == 16, "Expected 16, received: " + materials.length + ". Did you miss a color?"); + + List resolved = new ArrayList<>(materials.length); + + for (XMaterial material : materials) { + // Resolves to null on versions where this colored variant does not exist (pre-flattening). + resolved.add(material.parseMaterial()); + } + + list = Collections.unmodifiableList(resolved); + } + + /** + * This returns an ordered {@link List} of {@link Material Materials} + * that are part o this {@link ColoredMaterial}. + * + * @return An ordered {@link List} of {@link Material Materials} + */ + public @Nonnull List asList() { + return list; + } + + /** + * This returns the {@link Material} at the given index. + * + * @param index + * The index + * + * @return The {@link Material} at that index (may be {@code null} on servers predating this color) + */ + public Material get(int index) { + Validate.isTrue(index >= 0 && index < 16, "The index must be between 0 and 15 (inclusive)."); + + return list.get(index); + } + + /** + * This returns the {@link Material} with the given {@link DyeColor}. + * + * @param color + * The {@link DyeColor} + * + * @return The {@link Material} with that {@link DyeColor} (may be {@code null} on servers predating this color) + */ + public Material get(@Nonnull DyeColor color) { + Validate.notNull(color, "Color cannot be null!"); + + return get(color.ordinal()); + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FileUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/FileUtils.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/FileUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/FileUtils.java index f8441dc75e..b1fccfa021 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FileUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/FileUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.io.File; @@ -22,3 +22,4 @@ public static boolean deleteDirectory(File folder) { return folder.delete(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/FireworkUtils.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/FireworkUtils.java index e09851349d..f608d8d184 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/FireworkUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/FireworkUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.Random; import java.util.concurrent.ThreadLocalRandom; @@ -15,7 +15,7 @@ import org.bukkit.entity.Firework; import org.bukkit.inventory.meta.FireworkMeta; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEntityType; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEntityType; /** * This is a simple utility class for spawning random and colorful {@link Firework} rockets. @@ -97,3 +97,4 @@ public static void launchRandom(@Nonnull Entity n, int amount) { return COLORS[ThreadLocalRandom.current().nextInt(COLORS.length)]; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/HeadTexture.java similarity index 96% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/HeadTexture.java index a4caf14774..b1673fb20a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/HeadTexture.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.nio.charset.StandardCharsets; import java.util.UUID; @@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.bakedlibs.dough.skins.PlayerSkin; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPlayerHead; /** * This enum holds all currently used Head textures in Slimefun. @@ -163,8 +163,14 @@ public enum HeadTexture { return SlimefunUtils.getCustomHead(getTexture()); } - public @Nonnull PlayerSkin getAsSkin() { - return PlayerSkin.fromHashCode(texture); + /** + * Returns a base64-encoded texture string for this head texture. + * + * @return The base64 texture string + */ + public @Nonnull String getBase64Texture() { + return VersionedPlayerHead.hashToBase64(texture); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/InfiniteBlockGenerator.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/InfiniteBlockGenerator.java similarity index 94% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/InfiniteBlockGenerator.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/InfiniteBlockGenerator.java index 9c0a80c5b7..b8691e31ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/InfiniteBlockGenerator.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/InfiniteBlockGenerator.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.function.Predicate; @@ -9,13 +9,14 @@ import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.event.block.BlockFormEvent; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.implementation.items.androids.MinerAndroid; import io.papermc.lib.PaperLib; /** @@ -91,8 +92,8 @@ public boolean test(@Nonnull Block b) { return false; } case BASALT_GENERATOR: - if (b.getRelative(BlockFace.DOWN).getType() == Material.SOUL_SOIL) { - return hasSurroundingMaterials(b, Material.LAVA, Material.BLUE_ICE); + if (b.getRelative(BlockFace.DOWN).getType() == XMaterial.SOUL_SOIL.parseMaterial()) { + return hasSurroundingMaterials(b, Material.LAVA, XMaterial.BLUE_ICE.parseMaterial()); } else { return false; } @@ -170,3 +171,4 @@ private boolean hasSurroundingMaterials(Block b, Material... materials) { return null; } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/JsonUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/JsonUtils.java similarity index 82% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/JsonUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/JsonUtils.java index 57a7f3eb80..36ac36dcb8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/JsonUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/JsonUtils.java @@ -1,12 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import javax.annotation.Nonnull; import com.google.gson.JsonElement; import com.google.gson.JsonParser; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * Some helper methods for dealing with Json data. @@ -37,7 +37,7 @@ private JsonUtils() {} * As of 1.18 Spigot includes a newer version of Gson that * favours static method access. */ - return JsonParser.parseString(json); + return new JsonParser().parse(json); } else { /* * For older versions, we will need to use this way. @@ -47,3 +47,4 @@ private JsonUtils() {} } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/LoreBuilder.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/LoreBuilder.java index 6a3a67cc9a..a17af4c954 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/LoreBuilder.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; @@ -6,11 +6,11 @@ import javax.annotation.Nonnull; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineTier; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.core.attributes.MachineTier; +import io.github.thebusybiscuit.slimefun5.core.attributes.MachineType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactivity; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; /** * This utility class provides a few handy methods and constants to build the lore of any @@ -78,3 +78,4 @@ private LoreBuilder() {} } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/NumberUtils.java similarity index 98% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/NumberUtils.java index 0b85e6e68d..0f11881654 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/NumberUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; @@ -15,7 +15,7 @@ import org.bukkit.ChatColor; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This class contains various utilities related to numbers and number formatting. @@ -316,3 +316,4 @@ public static int limitedAddition(int a, int b, int min, int max) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/PatternUtils.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/PatternUtils.java index f68c3a6f52..9184223b40 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/PatternUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.regex.Pattern; @@ -30,3 +30,4 @@ private PatternUtils() {} public static final Pattern USES_LEFT_LORE = Pattern.compile(ChatColor.YELLOW + "[0-9]+ Uses? " + ChatColor.GRAY + "left"); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/RadiationUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/RadiationUtils.java similarity index 81% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/RadiationUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/RadiationUtils.java index a9883b4a5b..645718c22d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/RadiationUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/RadiationUtils.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import javax.annotation.Nonnull; import com.google.common.base.Preconditions; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.api.player.StatusEffect; -import io.github.thebusybiscuit.slimefun4.core.attributes.RadiationSymptom; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.player.StatusEffect; +import io.github.thebusybiscuit.slimefun5.core.attributes.RadiationSymptom; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This class is a basic wrapper around the @@ -50,3 +50,4 @@ public static void removeExposure(@Nonnull Player p, int exposure) { RADIATION_EFFECT.addPermanent(p, level); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/SlimefunUtils.java similarity index 86% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/SlimefunUtils.java index ed5bdb9b4d..bee13c80f2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/SlimefunUtils.java @@ -1,4 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.InventoryCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -15,7 +21,8 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import com.cryptomorin.xseries.XMaterial; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.World; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -23,29 +30,29 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionData; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PotionCompat; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.ItemMetaCompat; import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.persistence.PersistentDataContainer; -import org.bukkit.persistence.PersistentDataType; import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.items.ItemMetaSnapshot; -import io.github.bakedlibs.dough.skins.PlayerHead; -import io.github.bakedlibs.dough.skins.PlayerSkin; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemSpawnEvent; -import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.DistinctiveItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; -import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.CapacitorTextureUpdateTask; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedPlayerHead; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.events.SlimefunItemSpawnEvent; +import io.github.thebusybiscuit.slimefun5.api.exceptions.PrematureCodeException; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.DistinctiveItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactive; +import io.github.thebusybiscuit.slimefun5.core.attributes.Soulbound; +import io.github.thebusybiscuit.slimefun5.core.debug.Debug; +import io.github.thebusybiscuit.slimefun5.core.debug.TestCase; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.implementation.tasks.CapacitorTextureUpdateTask; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; /** * This utility class holds method that are directly linked to Slimefun. @@ -146,10 +153,9 @@ public static boolean isSoulbound(@Nullable ItemStack item, @Nullable World worl private static boolean hasSoulboundFlag(@Nullable ItemMeta meta) { if (meta != null) { - PersistentDataContainer container = meta.getPersistentDataContainer(); NamespacedKey key = Slimefun.getRegistry().getSoulboundDataKey(); - return container.has(key, PersistentDataType.BYTE); + return PdcCompat.has(meta, key, "BYTE"); } return false; @@ -177,15 +183,14 @@ public static void setSoulbound(@Nullable ItemStack item, boolean makeSoulbound) boolean isSoulbound = isSoulbound(item); ItemMeta meta = item.getItemMeta(); - PersistentDataContainer container = meta.getPersistentDataContainer(); NamespacedKey key = Slimefun.getRegistry().getSoulboundDataKey(); if (makeSoulbound && !isSoulbound) { - container.set(key, PersistentDataType.BYTE, (byte) 1); + PdcCompat.set(meta, key, "BYTE", (byte) 1); } if (!makeSoulbound && isSoulbound) { - container.remove(key); + PdcCompat.remove(meta, key); } List lore = meta.hasLore() ? meta.getLore() : new ArrayList<>(); @@ -232,17 +237,16 @@ public static boolean isRadioactive(@Nullable ItemStack item) { if (Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { // com.mojang.authlib.GameProfile does not exist in a Test Environment - return new ItemStack(Material.PLAYER_HEAD); + return MaterialCompat.stack(XMaterial.PLAYER_HEAD); } String base64 = texture; if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) { - base64 = Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8)); + base64 = Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"https://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8)); } - PlayerSkin skin = PlayerSkin.fromBase64(base64); - return PlayerHead.getItemStack(skin); + return VersionedPlayerHead.getItemStack(base64); } public static boolean containsSimilarItem(Inventory inventory, ItemStack item, boolean checkLore) { @@ -256,7 +260,7 @@ public static boolean containsSimilarItem(Inventory inventory, ItemStack item, b item = ItemStackWrapper.wrap(item); } - for (ItemStack stack : inventory.getStorageContents()) { + for (ItemStack stack : InventoryCompat.getStorageContents(inventory)) { if (stack == null || stack.getType() == Material.AIR) { continue; } @@ -354,8 +358,8 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac * Some items can't rely on just IDs matching and will implement {@link DistinctiveItem} * in which case we want to use the method provided to compare */ - if (checkDistinction && sf_sfitem instanceof DistinctiveItem distinctive && sf_item instanceof DistinctiveItem) { - return distinctive.canStack(sf_sfitem.getItem().getItemMeta(), sf_item.getItem().getItemMeta()); + if (checkDistinction && sf_sfitem instanceof DistinctiveItem && sf_item instanceof DistinctiveItem) { + DistinctiveItem distinctive = (DistinctiveItem) sf_sfitem; return distinctive.canStack(sf_sfitem.getItem().getItemMeta(), sf_item.getItem().getItemMeta()); } return true; } else if (item.hasItemMeta()) { @@ -430,8 +434,8 @@ public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStac private static @Nonnull Optional getDistinctiveItem(@Nonnull String id) { SlimefunItem slimefunItem = SlimefunItem.getById(id); - if (slimefunItem instanceof DistinctiveItem distinctive) { - return Optional.of(distinctive); + if (slimefunItem instanceof DistinctiveItem) { + DistinctiveItem distinctive = (DistinctiveItem) slimefunItem; return Optional.of(distinctive); } return Optional.empty(); } @@ -455,10 +459,10 @@ private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemM // Fixes #3133: name and lore are not enough OptionalInt itemCustomModelData = itemMetaSnapshot.getCustomModelData(); - if (itemMeta.hasCustomModelData() && itemCustomModelData.isPresent() && itemMeta.getCustomModelData() != itemCustomModelData.getAsInt()) { + if (ItemMetaCompat.hasCustomModelData(itemMeta) && itemCustomModelData.isPresent() && ItemMetaCompat.getCustomModelData(itemMeta) != itemCustomModelData.getAsInt()) { return false; } else { - return itemMeta.hasCustomModelData() == itemCustomModelData.isPresent(); + return ItemMetaCompat.hasCustomModelData(itemMeta) == itemCustomModelData.isPresent(); } } @@ -481,32 +485,36 @@ private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemM } // Fixes #3133: name and lore are not enough - boolean hasItemMetaCustomModelData = itemMeta.hasCustomModelData(); - boolean hasSfItemMetaCustomModelData = sfitemMeta.hasCustomModelData(); - if (hasItemMetaCustomModelData && hasSfItemMetaCustomModelData && itemMeta.getCustomModelData() != sfitemMeta.getCustomModelData()) { + boolean hasItemMetaCustomModelData = ItemMetaCompat.hasCustomModelData(itemMeta); + boolean hasSfItemMetaCustomModelData = ItemMetaCompat.hasCustomModelData(sfitemMeta); + if (hasItemMetaCustomModelData && hasSfItemMetaCustomModelData && ItemMetaCompat.getCustomModelData(itemMeta) != ItemMetaCompat.getCustomModelData(sfitemMeta)) { return false; } else if (hasItemMetaCustomModelData != hasSfItemMetaCustomModelData) { return false; } - if (!(itemMeta instanceof PotionMeta potionMeta) || !(sfitemMeta instanceof PotionMeta sfPotionMeta)) { + if (!(itemMeta instanceof PotionMeta) || !(sfitemMeta instanceof PotionMeta)) { return true; } + PotionMeta potionMeta = (PotionMeta) itemMeta; + PotionMeta sfPotionMeta = (PotionMeta) sfitemMeta; MinecraftVersion current = Slimefun.getMinecraftVersion(); if (current.isBefore(20, 2)) { - // getBasePotionData pre 1.20.2 - return potionMeta.getBasePotionData().equals(sfPotionMeta.getBasePotionData()); + // getBasePotionData pre 1.20.2 (reached reflectively for the Java-8 1.8.8 compile floor) + PotionData data = PotionCompat.getBasePotionData(potionMeta); + PotionData sfData = PotionCompat.getBasePotionData(sfPotionMeta); + return data == null ? sfData == null : data.equals(sfData); } else if (current.isBefore(20, 5)) { // getBasePotionType without null check for 1.20.3 and 1.20.4 - return potionMeta.getBasePotionType() == sfPotionMeta.getBasePotionType(); + return PotionCompat.getBasePotionType(potionMeta) == PotionCompat.getBasePotionType(sfPotionMeta); } // check if potionMetha has a basePotionType (acting a null check for getBasePotionType // on 1.20.5+ - if (potionMeta.hasBasePotionType() != sfPotionMeta.hasBasePotionType()) { + if (PotionCompat.hasBasePotionType(potionMeta) != PotionCompat.hasBasePotionType(sfPotionMeta)) { return false; } - return potionMeta.getBasePotionType() == sfPotionMeta.getBasePotionType(); + return PotionCompat.getBasePotionType(potionMeta) == PotionCompat.getBasePotionType(sfPotionMeta); } /** @@ -681,10 +689,10 @@ public static boolean canPlayerUseItem(@Nonnull Player p, @Nullable ItemStack it */ public static boolean isInventoryEmpty(@Nonnull Inventory inventory) { if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { - return inventory.isEmpty(); + return InventoryCompat.isEmpty(inventory); } else { - for (ItemStack is : inventory.getStorageContents()) { - if (is != null && !is.getType().isAir()) { + for (ItemStack is : InventoryCompat.getStorageContents(inventory)) { + if (is != null && !MaterialCompat.isAir(is.getType())) { return false; } } @@ -692,3 +700,4 @@ public static boolean isInventoryEmpty(@Nonnull Inventory inventory) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/UnbreakingAlgorithm.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/UnbreakingAlgorithm.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/UnbreakingAlgorithm.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/UnbreakingAlgorithm.java index da9ce2c890..2264666399 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/UnbreakingAlgorithm.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/UnbreakingAlgorithm.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.function.IntFunction; @@ -6,7 +6,7 @@ import org.bukkit.enchantments.Enchantment; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; /** * This a enum evaluating and indicating a {@link DamageableItem} 's chance to be damaged @@ -54,3 +54,4 @@ public boolean evaluate(int unbreakingLevel) { } } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeDataConverter.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeDataConverter.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeDataConverter.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeDataConverter.java index 62abe710f6..39d4b372c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeDataConverter.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeDataConverter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.biomes; +package io.github.thebusybiscuit.slimefun5.utils.biomes; import javax.annotation.Nonnull; @@ -44,3 +44,4 @@ public interface BiomeDataConverter { T convert(@Nonnull JsonElement jsonElement); } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeMap.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeMap.java index 6f652a017e..deb6d158f7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeMap.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.biomes; +package io.github.thebusybiscuit.slimefun5.utils.biomes; import java.io.BufferedReader; import java.io.IOException; @@ -13,14 +13,14 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import org.bukkit.Keyed; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; import org.bukkit.block.Biome; import com.google.gson.JsonElement; -import io.github.thebusybiscuit.slimefun4.api.exceptions.BiomeMapException; -import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; +import io.github.thebusybiscuit.slimefun5.api.exceptions.BiomeMapException; +import io.github.thebusybiscuit.slimefun5.api.geo.GEOResource; import org.bukkit.plugin.java.JavaPlugin; /** @@ -188,3 +188,4 @@ public static BiomeMap fromResource(NamespacedKey key, JavaPlugin plugin, return fromResource(key, plugin, path, JsonElement::getAsString); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeMapParser.java similarity index 85% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeMapParser.java index d1e3483938..daa355defb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/BiomeMapParser.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.biomes; +package io.github.thebusybiscuit.slimefun5.utils.biomes; import java.util.HashMap; @@ -11,7 +11,8 @@ import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.KeyedCompat; import org.bukkit.block.Biome; import com.google.gson.JsonArray; @@ -20,9 +21,11 @@ import com.google.gson.JsonParseException; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.api.exceptions.BiomeMapException; -import io.github.thebusybiscuit.slimefun4.utils.JsonUtils; -import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.exceptions.BiomeMapException; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.JsonUtils; +import io.github.thebusybiscuit.slimefun5.utils.PatternUtils; /** * The {@link BiomeMapParser} allows you to parse json data into a {@link BiomeMap}. @@ -147,7 +150,7 @@ private void readEntry(@Nonnull JsonObject entry) throws BiomeMapException { // Check for duplicates if (prev != null) { - throw new BiomeMapException(key, "Biome '" + biome.getKey() + "' is registered twice"); + throw new BiomeMapException(key, "Biome '" + KeyedCompat.keyName(biome) + "' is registered twice"); } } } else { @@ -158,6 +161,11 @@ private void readEntry(@Nonnull JsonObject entry) throws BiomeMapException { } } + private static boolean isLegacyServer() { + MinecraftVersion version = Slimefun.getMinecraftVersion(); + return version != null && version.isBefore(MinecraftVersion.MINECRAFT_1_13); + } + private @Nonnull Set readBiomes(@Nonnull JsonArray array) throws BiomeMapException { Validate.notNull(array, "The JSON array should not be null!"); Set biomes = new HashSet<>(); @@ -173,8 +181,11 @@ private void readEntry(@Nonnull JsonObject entry) throws BiomeMapException { Biome biome = Biome.valueOf(formattedValue); biomes.add(biome); } catch (IllegalArgumentException x) { - // Lenient Parsers will ignore unknown biomes - if (isLenient) { + // Lenient parsers ignore unknown biomes. On legacy servers (pre-1.13) many + // biome enum names were renamed (e.g. BEACH -> BEACHES), so a modern name not + // existing is expected rather than a misconfiguration - skip it instead of + // failing the whole biome map with a stacktrace. + if (isLenient || isLegacyServer()) { continue; } @@ -208,3 +219,4 @@ public BiomeMap buildBiomeMap() { } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/package-info.java new file mode 100644 index 0000000000..9fa98df9bf --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/biomes/package-info.java @@ -0,0 +1,5 @@ +/** + * This package contains classes centered around our {@link io.github.thebusybiscuit.slimefun5.utils.biomes.BiomeMap} + * utility. + */ +package io.github.thebusybiscuit.slimefun5.utils.biomes; diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/BlockDataCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/BlockDataCompat.java new file mode 100644 index 0000000000..c1964f5eda --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/BlockDataCompat.java @@ -0,0 +1,352 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Method; +import java.util.function.Consumer; + +import javax.annotation.Nullable; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.entity.FallingBlock; + +/** + * Compatibility helpers for the {@code org.bukkit.block.data.BlockData} API, which only exists from + * Minecraft 1.13 onwards. + * + *

+ * Universal-jar contract: none of these methods reference any {@code block.data.*} + * type in their signatures - block data is passed around as {@link Object}. This is essential: the + * {@code block.data.*} interfaces are compileOnly stubs that are NOT shaded into the jar (org.bukkit + * classes cannot be loaded from a plugin jar), so a consumer that named e.g. {@code Orientable} in + * its bytecode would fail class verification with {@code NoClassDefFoundError} on a legacy server. + * Consumers therefore hold block data as {@link Object} and read/write its properties through the + * reflective {@link #get(Object, String)} / {@link #set(Object, String, Object)} helpers, never + * casting to a {@code block.data.*} type. + * + *

+ * On legacy servers every lookup fails gracefully (returns {@code null} / no-op); on modern servers + * the real {@code BlockData} methods are used. + */ +public final class BlockDataCompat { + + private BlockDataCompat() {} + + /** + * Resolves the real {@code org.bukkit.block.data.BlockData} class, or {@code null} on legacy + * versions where it does not exist. + */ + @Nullable + private static Class blockDataClass() { + try { + return Class.forName("org.bukkit.block.data.BlockData"); + } catch (Throwable e) { + return null; + } + } + + /** + * Reflective equivalent of {@code block.getBlockData()}. + * + * @param block + * The {@link Block} + * + * @return The block's block data as an opaque {@link Object}, or {@code null} on legacy versions + */ + @Nullable + public static Object getBlockData(Block block) { + try { + Method method = Block.class.getMethod("getBlockData"); + return method.invoke(block); + } catch (Throwable e) { + return null; + } + } + + /** + * Reflective equivalent of {@code state.getBlockData()}. + * + * @param state + * The {@link BlockState} + * + * @return The state's block data as an opaque {@link Object}, or {@code null} on legacy versions + */ + @Nullable + public static Object getBlockData(BlockState state) { + try { + Method method = BlockState.class.getMethod("getBlockData"); + return method.invoke(state); + } catch (Throwable e) { + return null; + } + } + + /** + * Reflective equivalent of {@code block.setBlockData(data)}. No-op on legacy versions. + * + * @param block + * The {@link Block} + * @param data + * The block data (an opaque {@link Object} obtained from this class) + */ + public static void setBlockData(Block block, Object data) { + Class blockData = blockDataClass(); + + if (blockData == null || data == null) { + return; + } + + try { + Method method = Block.class.getMethod("setBlockData", blockData); + method.invoke(block, data); + } catch (Throwable e) { + // Not supported on this version - silently ignore. + } + } + + /** + * Reflective equivalent of {@code block.setBlockData(data, applyPhysics)}. No-op on legacy versions. + * + * @param block + * The {@link Block} + * @param data + * The block data (an opaque {@link Object} obtained from this class) + * @param applyPhysics + * Whether to apply physics + */ + public static void setBlockData(Block block, Object data, boolean applyPhysics) { + Class blockData = blockDataClass(); + + if (blockData == null || data == null) { + return; + } + + try { + Method method = Block.class.getMethod("setBlockData", blockData, boolean.class); + method.invoke(block, data, applyPhysics); + } catch (Throwable e) { + // Not supported on this version - silently ignore. + } + } + + /** + * Reflective equivalent of {@code material.createBlockData()}. + * + * @param material + * The {@link Material} + * + * @return The created block data as an opaque {@link Object}, or {@code null} on legacy versions + */ + @Nullable + public static Object createBlockData(Material material) { + try { + Method method = Material.class.getMethod("createBlockData"); + return method.invoke(material); + } catch (Throwable e) { + return null; + } + } + + /** + * Reflective equivalent of {@code material.createBlockData(consumer)} (the consumer-configured + * overload). The consumer receives the block data as an opaque {@link Object} (use + * {@link #set(Object, String, Object)} to configure it). Returns {@code null} on legacy versions + * (the consumer is then never invoked). + * + * @param material + * The {@link Material} + * @param consumer + * A consumer that configures the created block data + * + * @return The created block data as an opaque {@link Object}, or {@code null} on legacy versions + */ + @Nullable + public static Object createBlockData(Material material, Consumer consumer) { + try { + Method method = Material.class.getMethod("createBlockData", Consumer.class); + return method.invoke(material, consumer); + } catch (Throwable e) { + return null; + } + } + + /** + * Reflectively reads a property of a block data object, e.g. {@code get(data, "getAxis")} or + * {@code get(data, "getFacing")}. The result is returned as an {@link Object} (which the caller + * may cast to a version-safe type such as {@code BlockFace}, but never to a {@code block.data.*} + * type). + * + * @param data + * The block data {@link Object} (may be {@code null}) + * @param getter + * The no-arg getter name + * + * @return The property value, or {@code null} if unavailable + */ + @Nullable + public static Object get(@Nullable Object data, String getter) { + return data == null ? null : ReflectionCompat.invoke(data, getter); + } + + /** + * Reflectively reads an {@code int} property of a block data object, e.g. + * {@code getInt(data, "getLevel")}. + * + * @param data + * The block data {@link Object} (may be {@code null}) + * @param getter + * The no-arg getter name + * + * @return The property value, or {@code 0} if unavailable + */ + public static int getInt(@Nullable Object data, String getter) { + Object result = get(data, getter); + return result instanceof Number ? ((Number) result).intValue() : 0; + } + + /** + * Reflectively writes a property of a block data object, e.g. {@code set(data, "setAxis", axis)}. + * No-op if the data or method is unavailable. + * + * @param data + * The block data {@link Object} (may be {@code null}) + * @param setter + * The single-arg setter name + * @param value + * The value to set + */ + public static void set(@Nullable Object data, String setter, Object value) { + if (data != null) { + ReflectionCompat.invoke(data, setter, value); + } + } + + /** + * Version-safe {@code instanceof} test against a {@code block.data.*} type by name, e.g. + * {@code isInstance(data, "org.bukkit.block.data.Ageable")}. Returns {@code false} on legacy + * versions where the type does not exist. + * + * @param data + * The block data {@link Object} (may be {@code null}) + * @param className + * The fully-qualified class name to test against + * + * @return Whether {@code data} is an instance of the named type + */ + public static boolean isInstance(@Nullable Object data, String className) { + if (data == null) { + return false; + } + + try { + return Class.forName(className).isInstance(data); + } catch (Throwable e) { + return false; + } + } + + /** + * Returns the {@link Material} represented by a {@link FallingBlock}, across versions. Uses the + * modern {@code getBlockData().getMaterial()} when available and falls back to the legacy + * {@code getMaterial()}. + * + * @param fallingBlock + * The {@link FallingBlock} + * + * @return The {@link Material}, or {@link Material#STONE} if it could not be determined + */ + public static Material getMaterial(FallingBlock fallingBlock) { + try { + Object data = FallingBlock.class.getMethod("getBlockData").invoke(fallingBlock); + + if (data != null) { + Object material = data.getClass().getMethod("getMaterial").invoke(data); + + if (material instanceof Material) { + return (Material) material; + } + } + } catch (Throwable ignored) { + // Fall through to the legacy accessor. + } + + try { + Object material = FallingBlock.class.getMethod("getMaterial").invoke(fallingBlock); + + if (material instanceof Material) { + return (Material) material; + } + } catch (Throwable ignored) { + // Neither accessor available. + } + + return Material.STONE; + } + + /** + * Reflective equivalent of {@code world.spawnFallingBlock(location, data)} (the block-data + * overload, 1.13+), falling back to the legacy {@code (Location, Material, byte)} variant. + * + * @param world + * The {@link World} + * @param location + * The spawn {@link Location} + * @param data + * The block data {@link Object} + * + * @return The spawned {@link FallingBlock}, or {@code null} if unsupported + */ + @Nullable + public static FallingBlock spawnFallingBlock(World world, Location location, Object data) { + Class blockData = blockDataClass(); + + if (blockData != null && data != null) { + try { + Method method = World.class.getMethod("spawnFallingBlock", Location.class, blockData); + return (FallingBlock) method.invoke(world, location, data); + } catch (Throwable ignored) { + // Fall through to the legacy accessor. + } + } + + try { + Object material = data != null ? ReflectionCompat.invoke(data, "getMaterial") : Material.STONE; + Material mat = material instanceof Material ? (Material) material : Material.STONE; + Method legacy = World.class.getMethod("spawnFallingBlock", Location.class, Material.class, byte.class); + return (FallingBlock) legacy.invoke(world, location, mat, (byte) 0); + } catch (Throwable e2) { + return null; + } + } + + /** + * Spawns a {@link FallingBlock} matching the given source {@link Block}. On 1.13+ it uses the + * block's {@code BlockData}; on 1.8-1.12 it spawns from the block's real {@link Material} and legacy + * data byte (so the falling block is the actual block, not a STONE placeholder). + * + * @param world The {@link World} + * @param location The spawn {@link Location} + * @param source The {@link Block} to copy + * + * @return The spawned {@link FallingBlock}, or {@code null} if unsupported + */ + @Nullable + public static FallingBlock spawnFallingBlock(World world, Location location, Block source) { + Object data = getBlockData(source); + if (data != null) { + FallingBlock fb = spawnFallingBlock(world, location, data); + if (fb != null) { + return fb; + } + } + + try { + Method legacy = World.class.getMethod("spawnFallingBlock", Location.class, Material.class, byte.class); + return (FallingBlock) legacy.invoke(world, location, source.getType(), source.getData()); + } catch (Throwable e) { + return null; + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/BukkitKeys.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/BukkitKeys.java new file mode 100644 index 0000000000..636f41053a --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/BukkitKeys.java @@ -0,0 +1,55 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Constructor; + +import javax.annotation.Nullable; + +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; + +/** + * Java-8 universal port: bridges Slimefun's own {@link NamespacedKey} to the real + * {@code org.bukkit.NamespacedKey} at the (1.12+/1.14+) server-API boundaries (PDC, registries, recipe + * lookups). Everything is reflective so no {@code org.bukkit.NamespacedKey} type reference exists in the + * bytecode; on servers without it (1.8–1.11) the boundaries are never reached and this returns + * {@code null}. + */ +public final class BukkitKeys { + + private BukkitKeys() {} + + /** + * Converts an own {@link NamespacedKey} to a real {@code org.bukkit.NamespacedKey} instance. + * + * @return the real key as an {@link Object}, or {@code null} if the type is absent (legacy) or + * construction failed + */ + @Nullable + public static Object toBukkit(@Nullable NamespacedKey key) { + if (key == null) { + return null; + } + + Class bukkitKey; + try { + bukkitKey = Class.forName("org.bukkit.NamespacedKey"); + } catch (Throwable ignored) { + return null; + } + + // 1.14-1.20 expose the (String, String) constructor; 1.21+/26.x removed it, so fall back to + // the fromString("namespace:key") factory. + try { + Constructor ctor = bukkitKey.getDeclaredConstructor(String.class, String.class); + ctor.setAccessible(true); + return ctor.newInstance(key.getNamespace(), key.getKey()); + } catch (Throwable ignored) { + // fall through + } + + try { + return bukkitKey.getMethod("fromString", String.class).invoke(null, key.getNamespace() + ":" + key.getKey()); + } catch (Throwable ignored) { + return null; + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/EntityCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/EntityCompat.java new file mode 100644 index 0000000000..ded5428d00 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/EntityCompat.java @@ -0,0 +1,105 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.function.Predicate; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; + +/** + * Compatibility helpers for entity-related API that changed across Minecraft versions. + * + *

+ * The predicate-filtered {@code World#getNearbyEntities(Location, double, double, double, Predicate)} + * overload was only added in 1.9. The unfiltered four-argument variant has existed since 1.8, so we + * fetch with that and apply the predicate in Java, which behaves identically on every version. + */ +public final class EntityCompat { + + private EntityCompat() {} + + /** + * Version-independent equivalent of the predicate-filtered {@code getNearbyEntities} overload. + * + * @param world + * The {@link World} to search in + * @param location + * The center {@link Location} + * @param x + * Half the box length in the x direction + * @param y + * Half the box length in the y direction + * @param z + * Half the box length in the z direction + * @param filter + * The predicate to filter entities, or {@code null} for no filtering + * + * @return The matching entities + */ + public static Collection getNearbyEntities(World world, Location location, double x, double y, double z, Predicate filter) { + Collection nearby = world.getNearbyEntities(location, x, y, z); + + if (filter == null) { + return nearby; + } + + Collection result = new ArrayList<>(); + + for (Entity entity : nearby) { + if (filter.test(entity)) { + result.add(entity); + } + } + + return result; + } + + /** + * Resolves an {@link EntityType} by name, returning {@code null} when the constant does not exist + * on the running server version (rather than throwing). Lets code reference entity types added in + * later versions without a hard compile or runtime dependency on the constant. + * + * @param name + * The {@link EntityType} constant name (e.g. {@code "PIGLIN"}) + * + * @return The matching {@link EntityType}, or {@code null} if absent on this version + */ + public static EntityType entityType(String name) { + try { + return EntityType.valueOf(name); + } catch (Throwable e) { + return null; + } + } + + /** + * Reflective {@code LivingEntity#isGliding()} (1.9+). Returns {@code false} on older servers, which + * have no elytra gliding. + * + * @param entity + * The entity (a {@code LivingEntity} at runtime) + * + * @return Whether the entity is gliding + */ + public static boolean isGliding(Object entity) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(entity, "isGliding")); + } + + /** + * Reflective {@code Entity#getFacing()} (1.13+). Falls back to {@link BlockFace#NORTH} on older + * servers where the method is absent. + * + * @param entity + * The entity (an {@code Entity} at runtime) + * + * @return The facing direction, or {@link BlockFace#NORTH} if unavailable + */ + public static BlockFace getFacing(Object entity) { + Object result = ReflectionCompat.invoke(entity, "getFacing"); + return result instanceof BlockFace ? (BlockFace) result : BlockFace.NORTH; + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/HandCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/HandCompat.java new file mode 100644 index 0000000000..6122cd7726 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/HandCompat.java @@ -0,0 +1,138 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Method; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.bukkit.Material; +import org.bukkit.inventory.EquipmentSlot; +import org.bukkit.inventory.ItemStack; + +/** + * Java-8 universal port: cross-version main/off-hand item access. + *

+ * {@code getItemInMainHand()/setItemInMainHand()} and the off-hand slot are 1.9+ APIs; on 1.8 there is + * a single hand accessed via the now-deprecated {@code getItemInHand()/setItemInHand()} and no off-hand + * at all. The holder is taken as {@link Object} (a {@code PlayerInventory} or {@code EntityEquipment} at + * runtime) and methods are resolved reflectively, so this class loads on every version. Off-hand reads + * return {@code AIR} on 1.8 and off-hand writes are ignored. + * + * @author Slimefun (Java-8 port) + */ +public final class HandCompat { + + private HandCompat() {} + + /** + * The off-hand {@link EquipmentSlot}, added in 1.9. {@code null} on 1.8 (no off-hand slot), where it + * is therefore never equal to a resolved hand — see {@link #getHand(Object)}. + */ + @Nullable + public static final EquipmentSlot OFF_HAND = resolveSlot("OFF_HAND"); + + @Nullable + private static EquipmentSlot resolveSlot(@Nonnull String name) { + try { + return EquipmentSlot.valueOf(name); + } catch (Throwable ignored) { + return null; + } + } + + /** + * The {@link EquipmentSlot} used in an interaction event. {@code getHand()} is a 1.9+ method; on 1.8 + * there is only one hand, so this falls back to {@link EquipmentSlot#HAND} (which exists on 1.8). + * + * @param event + * The interaction event (a {@code PlayerInteractEvent} / {@code PlayerInteractEntityEvent}) + * + * @return The hand used, defaulting to {@link EquipmentSlot#HAND} + */ + @Nonnull + public static EquipmentSlot getHand(@Nonnull Object event) { + Object result = ReflectionCompat.invoke(event, "getHand"); + return result instanceof EquipmentSlot ? (EquipmentSlot) result : EquipmentSlot.HAND; + } + + @Nullable + private static Method method(@Nonnull Object holder, @Nonnull String name, Class... params) { + try { + return holder.getClass().getMethod(name, params); + } catch (Throwable ignored) { + return null; + } + } + + @Nonnull + private static ItemStack air() { + return new ItemStack(Material.AIR); + } + + @Nonnull + public static ItemStack getMainHand(@Nonnull Object holder) { + Method m = method(holder, "getItemInMainHand"); + + if (m == null) { + m = method(holder, "getItemInHand"); // 1.8 single-hand fallback + } + + if (m != null) { + try { + Object result = m.invoke(holder); + return result instanceof ItemStack ? (ItemStack) result : air(); + } catch (Throwable ignored) { + // fall through + } + } + + return air(); + } + + @Nonnull + public static ItemStack getOffHand(@Nonnull Object holder) { + Method m = method(holder, "getItemInOffHand"); + + if (m != null) { + try { + Object result = m.invoke(holder); + return result instanceof ItemStack ? (ItemStack) result : air(); + } catch (Throwable ignored) { + // fall through + } + } + + // No off-hand slot before 1.9. + return air(); + } + + public static void setMainHand(@Nonnull Object holder, @Nullable ItemStack item) { + Method m = method(holder, "setItemInMainHand", ItemStack.class); + + if (m == null) { + m = method(holder, "setItemInHand", ItemStack.class); // 1.8 single-hand fallback + } + + if (m != null) { + try { + m.invoke(holder, item); + } catch (Throwable ignored) { + // ignore + } + } + } + + public static void setOffHand(@Nonnull Object holder, @Nullable ItemStack item) { + Method m = method(holder, "setItemInOffHand", ItemStack.class); + + if (m != null) { + try { + m.invoke(holder, item); + } catch (Throwable ignored) { + // ignore + } + } + + // No-op before 1.9. + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/InventoryCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/InventoryCompat.java new file mode 100644 index 0000000000..70cc8fd373 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/InventoryCompat.java @@ -0,0 +1,39 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +/** + * Java-8 universal port: {@code Inventory#getStorageContents()} is 1.9+. Reached reflectively, falling + * back to {@code getContents()} on older servers (equivalent for the non-player inventories Slimefun + * uses it on). + */ +public final class InventoryCompat { + + private InventoryCompat() {} + + public static ItemStack[] getStorageContents(Inventory inventory) { + Object result = ReflectionCompat.invoke(inventory, "getStorageContents"); + return result instanceof ItemStack[] ? (ItemStack[]) result : inventory.getContents(); + } + + /** + * {@code Inventory#isEmpty()} is 1.20+. Falls back to scanning {@code getContents()} for any non-null, + * non-air stack on older servers. + */ + public static boolean isEmpty(Inventory inventory) { + Object result = ReflectionCompat.invoke(inventory, "isEmpty"); + + if (result instanceof Boolean) { + return (Boolean) result; + } + + for (ItemStack item : inventory.getContents()) { + if (item != null && item.getType() != org.bukkit.Material.AIR) { + return false; + } + } + + return true; + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ItemMetaCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ItemMetaCompat.java new file mode 100644 index 0000000000..728bf5b07f --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ItemMetaCompat.java @@ -0,0 +1,40 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import javax.annotation.Nullable; + +import org.bukkit.inventory.meta.ItemMeta; + +/** + * Java-8 universal port: reflective access to {@link ItemMeta} methods that do not exist at the 1.8.8 + * compile floor. + *

+ * {@code setUnbreakable}/{@code isUnbreakable} are 1.11+ (on 1.8 the flag lived on the {@code Spigot} + * sub-API) and the custom-model-data accessors are 1.14+. All are reached reflectively so the code + * compiles against 1.8.8 while keeping full behaviour on modern servers; reads degrade to sensible + * defaults on legacy. + */ +public final class ItemMetaCompat { + + private ItemMetaCompat() {} + + public static void setUnbreakable(ItemMeta meta, boolean unbreakable) { + ReflectionCompat.invoke(meta, "setUnbreakable", unbreakable); + } + + public static boolean isUnbreakable(ItemMeta meta) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(meta, "isUnbreakable")); + } + + public static boolean hasCustomModelData(ItemMeta meta) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(meta, "hasCustomModelData")); + } + + public static int getCustomModelData(ItemMeta meta) { + Object result = ReflectionCompat.invoke(meta, "getCustomModelData"); + return result instanceof Integer ? (Integer) result : 0; + } + + public static void setCustomModelData(ItemMeta meta, @Nullable Integer data) { + ReflectionCompat.invoke(meta, "setCustomModelData", data); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ItemsAdderCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ItemsAdderCompat.java new file mode 100644 index 0000000000..b9c86f4b79 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ItemsAdderCompat.java @@ -0,0 +1,49 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.util.Collections; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; + +/** + * Java-8 universal port: ItemsAdder ({@code dev.lone.itemsadder.api.CustomBlock}) is an optional + * third-party plugin, not a compile dependency, so its API is reached reflectively. Calls are only made + * after the integration layer has confirmed the block is an ItemsAdder custom block; when the plugin is + * absent these degrade to an empty loot list / no-op. + */ +public final class ItemsAdderCompat { + + private static final String CUSTOM_BLOCK = "dev.lone.itemsadder.api.CustomBlock"; + + private ItemsAdderCompat() {} + + @SuppressWarnings("unchecked") + public static List getLoot(Block block) { + try { + Class customBlock = Class.forName(CUSTOM_BLOCK); + Object instance = customBlock.getMethod("byAlreadyPlaced", Block.class).invoke(null, block); + + if (instance != null) { + Object loot = customBlock.getMethod("getLoot").invoke(instance); + + if (loot instanceof List) { + return (List) loot; + } + } + } catch (Throwable ignored) { + // ItemsAdder absent or API changed — no loot. + } + + return Collections.emptyList(); + } + + public static void remove(Location location) { + try { + Class.forName(CUSTOM_BLOCK).getMethod("remove", Location.class).invoke(null, location); + } catch (Throwable ignored) { + // ItemsAdder absent — nothing to remove. + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/KeyedCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/KeyedCompat.java new file mode 100644 index 0000000000..9485c4d8fb --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/KeyedCompat.java @@ -0,0 +1,56 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import javax.annotation.Nullable; + +/** + * Java-8 universal port: {@code Keyed#getKey()} (returning a {@code NamespacedKey}) is 1.13+. Older + * types ({@code Enchantment}, {@code Biome}, ...) exposed only legacy names. These helpers read a + * keyed object's namespace/key reflectively, falling back to {@code getName()}/{@code name()} on legacy + * servers, so call sites that build config paths or log messages compile against the 1.8.8 floor. + */ +public final class KeyedCompat { + + private KeyedCompat() {} + + @Nullable + private static Object namespacedKey(Object keyed) { + return ReflectionCompat.invoke(keyed, "getKey"); + } + + public static String namespace(Object keyed) { + Object key = namespacedKey(keyed); + Object namespace = ReflectionCompat.invoke(key, "getNamespace"); + return namespace != null ? namespace.toString() : "minecraft"; + } + + public static String key(Object keyed) { + Object key = namespacedKey(keyed); + Object value = ReflectionCompat.invoke(key, "getKey"); + + if (value != null) { + return value.toString(); + } + + // Legacy fallback: getName() (e.g. Enchantment) or enum name(). + Object name = ReflectionCompat.invoke(keyed, "getName"); + + if (name == null && keyed instanceof Enum) { + name = ((Enum) keyed).name(); + } + + return name != null ? name.toString().toLowerCase() : String.valueOf(keyed); + } + + /** + * The full {@code namespace:key} string, or a best-effort legacy name. + */ + public static String keyName(Object keyed) { + Object key = namespacedKey(keyed); + + if (key != null) { + return key.toString(); + } + + return key(keyed); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/MaterialCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/MaterialCompat.java new file mode 100644 index 0000000000..ebcb5ce469 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/MaterialCompat.java @@ -0,0 +1,236 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import com.cryptomorin.xseries.XMaterial; + +/** + * Java-8 universal port: cross-version {@link Material} helpers for APIs added after 1.8.8. + * + * @author Slimefun (Java-8 port) + */ +public final class MaterialCompat { + + /** + * Legacy-safe placeholder material. Materials introduced after the running server's version + * resolve to {@code null} via {@link XMaterial#parseMaterial()}; substituting this keeps recipe + * ingredients and items constructible on legacy instead of crashing in {@code new ItemStack(null)}. + * {@code PAPER} exists on every supported Minecraft version. + */ + private static final Material FALLBACK = Material.PAPER; + + // Sensible legacy substitutes for materials that don't exist on older servers, so an icon resolves + // to something recognisable (e.g. NETHERITE_BLOCK -> DIAMOND_BLOCK on 1.8) instead of the placeholder. + private static final java.util.Map LEGACY_SUBSTITUTES = buildLegacySubstitutes(); + + private static java.util.Map buildLegacySubstitutes() { + java.util.Map m = new java.util.EnumMap<>(XMaterial.class); + m.put(XMaterial.NETHERITE_BLOCK, XMaterial.DIAMOND_BLOCK); + m.put(XMaterial.NETHERITE_INGOT, XMaterial.DIAMOND); + m.put(XMaterial.NETHERITE_SCRAP, XMaterial.IRON_NUGGET); + m.put(XMaterial.ANCIENT_DEBRIS, XMaterial.NETHERRACK); + m.put(XMaterial.BEEHIVE, XMaterial.DISPENSER); + m.put(XMaterial.BEE_NEST, XMaterial.DISPENSER); + m.put(XMaterial.HONEY_BLOCK, XMaterial.SLIME_BLOCK); + m.put(XMaterial.BARREL, XMaterial.CHEST); + m.put(XMaterial.BLAST_FURNACE, XMaterial.FURNACE); + m.put(XMaterial.SMOKER, XMaterial.FURNACE); + m.put(XMaterial.CAMPFIRE, XMaterial.NETHERRACK); + m.put(XMaterial.SMITHING_TABLE, XMaterial.CRAFTING_TABLE); + m.put(XMaterial.CARTOGRAPHY_TABLE, XMaterial.CRAFTING_TABLE); + m.put(XMaterial.FLETCHING_TABLE, XMaterial.CRAFTING_TABLE); + m.put(XMaterial.LOOM, XMaterial.CRAFTING_TABLE); + m.put(XMaterial.STONECUTTER, XMaterial.CRAFTING_TABLE); + m.put(XMaterial.GRINDSTONE, XMaterial.ANVIL); + m.put(XMaterial.LANTERN, XMaterial.GLOWSTONE); + m.put(XMaterial.COMPOSTER, XMaterial.CHEST); + m.put(XMaterial.MAGMA_BLOCK, XMaterial.NETHERRACK); + m.put(XMaterial.LODESTONE, XMaterial.IRON_BLOCK); + m.put(XMaterial.BLACKSTONE, XMaterial.COBBLESTONE); + m.put(XMaterial.OBSERVER, XMaterial.PISTON); + return m; + } + + /** + * A sensible substitute {@link Material} that exists on the running server for an {@link XMaterial} + * that doesn't (e.g. {@code NETHERITE_BLOCK} -> {@code DIAMOND_BLOCK} on 1.8), or {@code null} if there + * is no mapping. Used as a smarter fallback than a generic placeholder for guide/category icons. + */ + @Nullable + public static Material substitute(@Nonnull XMaterial xMaterial) { + XMaterial sub = LEGACY_SUBSTITUTES.get(xMaterial); + return sub != null ? sub.parseMaterial() : null; + } + + private MaterialCompat() {} + + /** + * Builds an {@link ItemStack} from an {@link XMaterial}, substituting {@link #FALLBACK} when the + * material does not exist on the running (legacy) server. Replaces the unsafe + * {@code new ItemStack(xMaterial.parseMaterial())} idiom, which throws {@link NullPointerException} + * on legacy servers where {@link XMaterial#parseMaterial()} returns {@code null}. + * + * @param xMaterial + * The {@link XMaterial} to resolve + * + * @return A non-null {@link ItemStack} + */ + @Nonnull + public static ItemStack stack(@Nonnull XMaterial xMaterial) { + // parseItem() carries the legacy data value on 1.8-1.12 (e.g. SKULL_ITEM:3 = player head, + // SKULL_ITEM:1 = wither skull, wool/dye colors). parseMaterial() drops it, yielding the data-0 + // variant - so a player head would render as a skeleton skull. Fall back only if parseItem fails. + ItemStack item = xMaterial.parseItem(); + if (item != null) { + item.setAmount(1); + return item; + } + Material material = xMaterial.parseMaterial(); + if (material == null) { + material = substitute(xMaterial); + } + return new ItemStack(material != null ? material : FALLBACK); + } + + /** + * Amount-aware variant of {@link #stack(XMaterial)}. + * + * @param xMaterial + * The {@link XMaterial} to resolve + * @param amount + * The stack size + * + * @return A non-null {@link ItemStack} of the given amount + */ + @Nonnull + public static ItemStack stack(@Nonnull XMaterial xMaterial, int amount) { + // See stack(XMaterial): parseItem() preserves the legacy data value that parseMaterial() drops. + ItemStack item = xMaterial.parseItem(); + if (item != null) { + item.setAmount(amount); + return item; + } + Material material = xMaterial.parseMaterial(); + if (material == null) { + material = substitute(xMaterial); + } + return new ItemStack(material != null ? material : FALLBACK, amount); + } + + /** + * Version-safe replacement for {@code Material#isAir()} (added in 1.13). Resolved by name so it + * works on every version: {@code AIR} on all, plus {@code CAVE_AIR}/{@code VOID_AIR} on 1.13+. + */ + public static boolean isAir(@Nullable Material material) { + if (material == null) { + return true; + } + + switch (material.name()) { + case "AIR": + case "CAVE_AIR": + case "VOID_AIR": + return true; + default: + return false; + } + } + + /** + * Reflective {@code Material#isInteractable()} (added in 1.13). Returns {@code false} on older + * servers, where the distinction is unavailable. + */ + public static boolean isInteractable(@Nullable Material material) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(material, "isInteractable")); + } + + /** + * Reflective {@code Material#isItem()} (1.13+). Returns {@code true} on older servers, where every + * material can exist as an item. + */ + public static boolean isItem(@Nullable Material material) { + Object result = ReflectionCompat.invoke(material, "isItem"); + return result instanceof Boolean ? (Boolean) result : true; + } + + /** + * Reflective {@code Material#isLegacy()} (1.13+). Returns {@code false} on older servers, which have + * no legacy-material concept. + */ + public static boolean isLegacy(@Nullable Material material) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(material, "isLegacy")); + } + + /** + * Reflective {@code Material#isFuel()} (1.13+). Returns {@code false} on older servers, where the + * distinction is unavailable. + */ + public static boolean isFuel(@Nullable Material material) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(material, "isFuel")); + } + + /** + * Whether the given {@link Material} is a vanilla furnace, treating the legacy lit-furnace material + * as equivalent. On 1.8-1.12 an actively burning/smelting furnace is a separate material, + * {@code BURNING_FURNACE} (id 62), distinct from the unlit {@code FURNACE} (id 61); the 1.13 + * flattening merged them into {@code FURNACE} with a {@code lit} block state. Code that gated on + * {@code type == Material.FURNACE} therefore silently ignored any lit furnace on legacy servers + * (breaking the {@link io.github.thebusybiscuit.slimefun5.implementation.items.blocks.EnhancedFurnace} + * speed/efficiency/fortune, which only act while it is burning). Blast furnaces and smokers are + * deliberately excluded (exact name match). + * + * @param material + * The {@link Material} (may be {@code null}) + * + * @return Whether it is a vanilla furnace (lit or unlit) across versions + */ + public static boolean isVanillaFurnace(@Nullable Material material) { + if (material == null) { + return false; + } + + switch (material.name()) { + case "FURNACE": + case "BURNING_FURNACE": // 1.8-1.12 lit furnace, flattened into FURNACE on 1.13+ + return true; + default: + return false; + } + } + + /** + * Whether the given {@link Material} can be placed as a block, version-aware. + *

+ * On 1.13+ this is just {@link Material#isBlock()}. On legacy versions (pre-1.13) some placeable + * blocks only have an item form whose {@code isBlock()} returns {@code false} - most + * importantly {@code SKULL_ITEM} (player/mob heads), which Slimefun uses for the vast majority of + * its machine blocks. Those are treated as placeable here so head-textured machines can register + * and function on 1.8-1.12 instead of being rejected. + * + * @param material + * The {@link Material} (may be {@code null}) + * + * @return Whether it can be placed as a block + */ + public static boolean isPlaceableBlock(@Nullable Material material) { + if (material == null) { + return false; + } + + if (material.isBlock()) { + return true; + } + + // Legacy item-form materials that are nonetheless placeable as blocks. + switch (material.name()) { + case "SKULL_ITEM": // player/mob heads (the placed form is SKULL) + return true; + default: + return false; + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/NbtItemCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/NbtItemCompat.java new file mode 100644 index 0000000000..9a1f663504 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/NbtItemCompat.java @@ -0,0 +1,123 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.util.Map; + +import javax.annotation.Nullable; + +import org.bukkit.Bukkit; +import org.bukkit.inventory.meta.ItemMeta; + +/** + * Java-8 universal port: stores Slimefun's item id in real item NBT on pre-1.14 servers, where the + * {@code PersistentDataContainer} API does not yet exist. + *

+ * It writes a string tag into CraftMetaItem's {@code unhandledTags} map, which CraftBukkit persists + * verbatim through {@code getItemMeta}/{@code setItemMeta}. Identity therefore survives renames and lore + * edits, unlike a lore-based marker (the approach big 1.8 servers use). Everything is reflective; no + * CraftBukkit/NMS type is referenced at compile time. On 1.14+ {@link PdcCompat} is used instead and this + * class is never initialised. + */ +public final class NbtItemCompat { + + private static final Constructor NBT_TAG_STRING_CTOR = resolveStringConstructor(); + + private NbtItemCompat() {} + + public static boolean isSupported() { + return NBT_TAG_STRING_CTOR != null; + } + + public static boolean setString(@Nullable ItemMeta meta, String key, String value) { + if (meta == null || NBT_TAG_STRING_CTOR == null) { + return false; + } + + try { + Map tags = unhandledTags(meta); + + if (tags == null) { + return false; + } + + tags.put(key, NBT_TAG_STRING_CTOR.newInstance(value)); + return true; + } catch (Throwable ignored) { + return false; + } + } + + @Nullable + public static String getString(@Nullable ItemMeta meta, String key) { + if (meta == null) { + return null; + } + + try { + Map tags = unhandledTags(meta); + + if (tags == null) { + return null; + } + + Object tag = tags.get(key); + return tag == null ? null : extractString(tag); + } catch (Throwable ignored) { + return null; + } + } + + @Nullable + @SuppressWarnings("unchecked") + private static Map unhandledTags(ItemMeta meta) throws IllegalAccessException { + Field field = findField(meta.getClass(), "unhandledTags"); + + if (field == null) { + return null; + } + + field.setAccessible(true); + return (Map) field.get(meta); + } + + @Nullable + private static String extractString(Object nbtTagString) throws IllegalAccessException { + // NBTTagString wraps a single String field whose name is obfuscated across versions; find it by + // type rather than by name. + for (Field field : nbtTagString.getClass().getDeclaredFields()) { + if (field.getType() == String.class) { + field.setAccessible(true); + return (String) field.get(nbtTagString); + } + } + + return null; + } + + @Nullable + private static Field findField(Class type, String name) { + for (Class current = type; current != null; current = current.getSuperclass()) { + try { + return current.getDeclaredField(name); + } catch (NoSuchFieldException ignored) { + // Declared further up the hierarchy (CraftMetaItem) — keep walking. + } + } + + return null; + } + + @Nullable + private static Constructor resolveStringConstructor() { + try { + String cbPackage = Bukkit.getServer().getClass().getPackage().getName(); + String version = cbPackage.substring(cbPackage.lastIndexOf('.') + 1); + Constructor ctor = Class.forName("net.minecraft.server." + version + ".NBTTagString").getConstructor(String.class); + ctor.setAccessible(true); + return ctor; + } catch (Throwable ignored) { + return null; + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ParticleCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ParticleCompat.java new file mode 100644 index 0000000000..330cc1228f --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ParticleCompat.java @@ -0,0 +1,84 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Method; + +import javax.annotation.Nullable; + +import org.bukkit.Location; +import org.bukkit.World; + +/** + * Java-8 universal port: cross-version particle spawning. + *

+ * {@code org.bukkit.Particle} and {@code World#spawnParticle(...)} are 1.9+ APIs that do not exist at + * the 1.8.8 compile floor. A {@code compileOnly} stub provides the {@code Particle} type/constants, but + * the {@code spawnParticle} method cannot be stubbed onto {@code World}, so call sites delegate + * here. This helper invokes the fullest {@code spawnParticle(Particle, Location, int, double, double, + * double, double, T)} overload reflectively, touching {@code org.bukkit.Particle} only via reflection so + * this class loads on every version. On 1.8 (no particle API) the calls become no-ops. + *

+ * The {@code particle} argument is typed as {@link Object} on purpose (it is an {@code org.bukkit.Particle} + * at runtime on 1.9+); this keeps the {@code Particle} type out of this class's signatures. + * + * @author Slimefun (Java-8 port) + */ +public final class ParticleCompat { + + private static final Method SPAWN_PARTICLE; + + static { + Method spawn = null; + + try { + Class particleClass = Class.forName("org.bukkit.Particle"); + spawn = World.class.getMethod("spawnParticle", particleClass, Location.class, int.class, double.class, double.class, double.class, double.class, Object.class); + } catch (Throwable ignored) { + // Pre-1.9 server: no particle API. Calls become no-ops. + spawn = null; + } + + SPAWN_PARTICLE = spawn; + } + + private ParticleCompat() {} + + private static void invoke(@Nullable World world, @Nullable Object particle, @Nullable Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable Object data) { + if (SPAWN_PARTICLE == null || world == null || particle == null || location == null) { + return; + } + + try { + SPAWN_PARTICLE.invoke(world, particle, location, count, offsetX, offsetY, offsetZ, extra, data); + } catch (Throwable ignored) { + // Particle not supported on this version / invalid data — ignore. + } + } + + // --- Location-based overloads (mirror World#spawnParticle signatures) --- + + public static void spawn(World world, Object particle, Location location, int count) { + invoke(world, particle, location, count, 0, 0, 0, 0, null); + } + + public static void spawn(World world, Object particle, Location location, int count, double offsetX, double offsetY, double offsetZ) { + invoke(world, particle, location, count, offsetX, offsetY, offsetZ, 0, null); + } + + public static void spawn(World world, Object particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) { + invoke(world, particle, location, count, offsetX, offsetY, offsetZ, extra, null); + } + + public static void spawn(World world, Object particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, Object data) { + invoke(world, particle, location, count, offsetX, offsetY, offsetZ, extra, data); + } + + // --- Coordinate-based overloads --- + + public static void spawn(World world, Object particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) { + invoke(world, particle, world == null ? null : new Location(world, x, y, z), count, offsetX, offsetY, offsetZ, extra, null); + } + + public static void spawn(World world, Object particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, Object data) { + invoke(world, particle, world == null ? null : new Location(world, x, y, z), count, offsetX, offsetY, offsetZ, extra, data); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/PdcCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/PdcCompat.java new file mode 100644 index 0000000000..fb877217f5 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/PdcCompat.java @@ -0,0 +1,209 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; + +/** + * Java-8 universal port: a single, fully-reflective Persistent-Data (PDC) abstraction. + *

+ * PDC is 1.14+. Rather than referencing {@code PersistentDataContainer}/{@code PersistentDataType}/ + * {@code PersistentDataHolder} (1.14+ types) in core bytecode, every operation here is reflective and + * keyed by Slimefun's own {@link NamespacedKey} (converted to the real {@code org.bukkit.NamespacedKey} + * via {@link BukkitKeys} only at the call into the server). On servers without PDC (1.8–1.13) the + * container/type/key resolve to {@code null} and all operations degrade to no-ops / defaults, so callers + * are inherently version-safe. {@code typeName} is a {@code PersistentDataType} field name such as + * {@code "STRING"}, {@code "BYTE"}, {@code "INTEGER"}, {@code "LONG"} or {@code "FLOAT"}. + */ +public final class PdcCompat { + + private PdcCompat() {} + + private static final boolean SUPPORTED = resolveSupported(); + + /** + * @return whether this server exposes the 1.14+ PersistentDataContainer API. + */ + public static boolean isSupported() { + return SUPPORTED; + } + + private static boolean resolveSupported() { + try { + Class.forName("org.bukkit.persistence.PersistentDataContainer"); + return true; + } catch (Throwable ignored) { + return false; + } + } + + // --- Legacy (pre-1.14) fallback --- + // The PersistentDataContainer API doesn't exist before 1.14, so the reflective calls below resolve + // to null and do nothing. For holders with a stable id (players/entities) we instead persist data + // in a YAML keyed by UUID, so e.g. the player's chosen guide language actually sticks on 1.8. + // Item holders have no id here and keep the no-op (their data flows through item-NBT paths). + private static org.bukkit.configuration.file.YamlConfiguration legacyStore; + private static java.io.File legacyFile; + + private static synchronized org.bukkit.configuration.file.YamlConfiguration legacy() { + if (legacyStore == null) { + legacyFile = new java.io.File(io.github.thebusybiscuit.slimefun5.implementation.Slimefun.instance().getDataFolder(), "legacy-pdc.yml"); + legacyStore = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(legacyFile); + } + return legacyStore; + } + + @Nullable + private static String legacyPath(Object holder, NamespacedKey key) { + Object id = ReflectionCompat.invoke(holder, "getUniqueId"); + return id != null ? id + "." + key.toString().replace(':', '_').replace('.', '_') : null; + } + + private static synchronized void legacySave() { + try { + if (legacyFile != null) { + legacyStore.save(legacyFile); + } + } catch (Exception ignored) { + // Best-effort persistence; never break a data write on a save failure. + } + } + + @Nullable + private static Object container(Object holder) { + return ReflectionCompat.invoke(holder, "getPersistentDataContainer"); + } + + @Nullable + private static Object dataType(String typeName) { + try { + return Class.forName("org.bukkit.persistence.PersistentDataType").getField(typeName).get(null); + } catch (Throwable ignored) { + return null; + } + } + + public static void set(Object holder, NamespacedKey key, String typeName, Object value) { + Object c = container(holder); + Object t = dataType(typeName); + Object k = BukkitKeys.toBukkit(key); + + if (c != null && t != null && k != null) { + ReflectionCompat.invoke(c, "set", k, t, value); + return; + } + + String path = legacyPath(holder, key); + if (path != null) { + legacy().set(path, value); + legacySave(); + } + } + + @Nullable + public static Object get(Object holder, NamespacedKey key, String typeName) { + Object c = container(holder); + Object t = dataType(typeName); + Object k = BukkitKeys.toBukkit(key); + + if (c != null && t != null && k != null) { + return ReflectionCompat.invoke(c, "get", k, t); + } + + String path = legacyPath(holder, key); + return path != null ? legacy().get(path) : null; + } + + public static Object getOrDefault(Object holder, NamespacedKey key, String typeName, Object defaultValue) { + Object value = get(holder, key, typeName); + return value != null ? value : defaultValue; + } + + public static boolean has(Object holder, NamespacedKey key, String typeName) { + Object c = container(holder); + Object t = dataType(typeName); + Object k = BukkitKeys.toBukkit(key); + + if (c != null && t != null && k != null) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(c, "has", k, t)); + } + + String path = legacyPath(holder, key); + return path != null && legacy().contains(path); + } + + /** + * Version-safe equality of two holders' PersistentDataContainers. On servers without PDC + * (1.8–1.13) the containers resolve to {@code null}; two such holders are treated as equal. + */ + public static boolean containersEqual(Object holderA, Object holderB) { + Object a = container(holderA); + Object b = container(holderB); + + if (a == null || b == null) { + return a == b; + } + + return a.equals(b); + } + + public static void remove(Object holder, NamespacedKey key) { + Object c = container(holder); + Object k = BukkitKeys.toBukkit(key); + + if (c != null && k != null) { + ReflectionCompat.invoke(c, "remove", k); + return; + } + + String path = legacyPath(holder, key); + if (path != null) { + legacy().set(path, null); + legacySave(); + } + } + + // --- Convenience accessors mirroring the dough PersistentDataAPI usage Slimefun relied on --- + + public static void setString(Object holder, NamespacedKey key, String value) { + set(holder, key, "STRING", value); + } + + @Nullable + public static String getString(Object holder, NamespacedKey key) { + Object value = get(holder, key, "STRING"); + return value instanceof String ? (String) value : null; + } + + public static Optional getOptionalString(Object holder, NamespacedKey key) { + return Optional.ofNullable(getString(holder, key)); + } + + public static void setByte(Object holder, NamespacedKey key, byte value) { + set(holder, key, "BYTE", value); + } + + public static byte getByte(Object holder, NamespacedKey key) { + Object value = get(holder, key, "BYTE"); + return value instanceof Byte ? (Byte) value : 0; + } + + public static boolean hasByte(Object holder, NamespacedKey key) { + return has(holder, key, "BYTE"); + } + + public static void setInt(Object holder, NamespacedKey key, int value) { + set(holder, key, "INTEGER", value); + } + + public static int getInt(Object holder, NamespacedKey key) { + return getInt(holder, key, 0); + } + + public static int getInt(Object holder, NamespacedKey key, int defaultValue) { + Object value = get(holder, key, "INTEGER"); + return value instanceof Integer ? (Integer) value : defaultValue; + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/PotionCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/PotionCompat.java new file mode 100644 index 0000000000..4dc2b7d550 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/PotionCompat.java @@ -0,0 +1,76 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import javax.annotation.Nullable; + +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionType; + +/** + * Java-8 universal port: compatibility helpers for the base-potion API that does not exist at the + * 1.8.8 compile floor. + *

+ * {@code PotionMeta#getBasePotionData}/{@code setBasePotionData} (and the {@link PotionData} class) + * arrived in 1.9, while {@code getBasePotionType}/{@code setBasePotionType} replaced them in 1.20.2. + * {@code PotionType#isExtendable}/{@code isUpgradeable} are likewise absent on legacy. All are reached + * reflectively so the code compiles against 1.8.8 while keeping full behaviour on modern servers. + */ +public final class PotionCompat { + + private PotionCompat() {} + + @Nullable + public static PotionType getBasePotionType(PotionMeta meta) { + return (PotionType) ReflectionCompat.invoke(meta, "getBasePotionType"); + } + + public static void setBasePotionType(PotionMeta meta, PotionType type) { + ReflectionCompat.invoke(meta, "setBasePotionType", type); + } + + @Nullable + public static PotionData getBasePotionData(PotionMeta meta) { + return (PotionData) ReflectionCompat.invoke(meta, "getBasePotionData"); + } + + public static void setBasePotionData(PotionMeta meta, PotionData data) { + ReflectionCompat.invoke(meta, "setBasePotionData", data); + } + + /** + * Builds a {@code PotionData} reflectively from its components and applies it, so callers never + * reference the {@link PotionData} type directly in their bytecode. {@link PotionData} only exists + * from 1.9 onwards; on a 1.8 server this is a no-op (the potion simply keeps no base potion data). + * + * @param meta + * The {@link PotionMeta} to modify + * @param type + * The {@link PotionType} + * @param extended + * Whether the potion is extended + * @param upgraded + * Whether the potion is upgraded + */ + public static void setBasePotionData(PotionMeta meta, PotionType type, boolean extended, boolean upgraded) { + try { + Class potionDataClass = Class.forName("org.bukkit.potion.PotionData"); + Object data = potionDataClass.getConstructor(PotionType.class, boolean.class, boolean.class) + .newInstance(type, extended, upgraded); + ReflectionCompat.invoke(meta, "setBasePotionData", data); + } catch (ReflectiveOperationException | LinkageError ignored) { + // PotionData is 1.9+; legacy servers have no base potion data + } + } + + public static boolean hasBasePotionType(PotionMeta meta) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(meta, "hasBasePotionType")); + } + + public static boolean isExtendable(PotionType type) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(type, "isExtendable")); + } + + public static boolean isUpgradeable(PotionType type) { + return Boolean.TRUE.equals(ReflectionCompat.invoke(type, "isUpgradeable")); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ProfileCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ProfileCompat.java new file mode 100644 index 0000000000..3f9a8f82cc --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ProfileCompat.java @@ -0,0 +1,36 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.util.UUID; + +import javax.annotation.Nullable; + +import org.bukkit.Bukkit; +import org.bukkit.profile.PlayerProfile; + +/** + * Java-8 universal port: the player-profile API ({@code Bukkit#createPlayerProfile}, + * {@code PlayerProfile}, {@code PlayerTextures}, {@code SkullMeta#setOwnerProfile}) arrived in 1.18 and + * does not exist at the 1.8.8 compile floor. + *

+ * These helpers resolve it reflectively. On a modern server the real profile API is used; on a legacy + * server {@link #createProfile(UUID, String)} returns {@code null} (callers skip the texture path) and + * {@link #setOwnerProfile(Object, PlayerProfile)} is a no-op. + */ +public final class ProfileCompat { + + private ProfileCompat() {} + + @Nullable + public static PlayerProfile createProfile(UUID uuid, String name) { + try { + Object profile = Bukkit.class.getMethod("createPlayerProfile", UUID.class, String.class).invoke(null, uuid, name); + return (PlayerProfile) profile; + } catch (Throwable ignored) { + return null; + } + } + + public static void setOwnerProfile(Object holder, PlayerProfile profile) { + ReflectionCompat.invoke(holder, "setOwnerProfile", profile); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/RecipeCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/RecipeCompat.java new file mode 100644 index 0000000000..03591c081e --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/RecipeCompat.java @@ -0,0 +1,32 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.util.Collections; +import java.util.Map; + +import org.bukkit.inventory.RecipeChoice; + +/** + * Java-8 universal port: {@code ShapedRecipe#getChoiceMap()} (returning {@code Map}) is 1.13+. Reached reflectively, returning an empty map on older servers (which used + * the ItemStack-based {@code getIngredientMap()} instead). + */ +public final class RecipeCompat { + + private RecipeCompat() {} + + @SuppressWarnings("unchecked") + public static Map getChoiceMap(Object shapedRecipe) { + Object map = ReflectionCompat.invoke(shapedRecipe, "getChoiceMap"); + return map instanceof Map ? (Map) map : Collections.emptyMap(); + } + + /** + * Reflective {@code ShapelessRecipe#getChoiceList()} (1.13+) → {@code List}; empty on + * older servers (which used the ItemStack-based {@code getIngredientList()}). + */ + @SuppressWarnings("unchecked") + public static java.util.List getChoiceList(Object shapelessRecipe) { + Object list = ReflectionCompat.invoke(shapelessRecipe, "getChoiceList"); + return list instanceof java.util.List ? (java.util.List) list : Collections.emptyList(); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ReflectionCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ReflectionCompat.java new file mode 100644 index 0000000000..45726d98e9 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/ReflectionCompat.java @@ -0,0 +1,170 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import javax.annotation.Nullable; + +/** + * Java-8 universal port: a tiny reflective method invoker for calling Bukkit/Paper APIs that do not + * exist at the 1.8.8 compile floor but are present on newer servers. + *

+ * It resolves a method by name, argument count, and assignable parameter types (so overloads with the + * same arity are disambiguated), then invokes it. Crucially, the matched method is re-resolved against a + * public supertype/interface before invocation: server objects are frequently instances of + * non-public {@code org.bukkit.craftbukkit.*} implementation classes (e.g. {@code CraftMetaItem}, + * {@code CraftPersistentDataContainer}), and invoking a {@link Method} whose declaring class is non-public + * throws {@link IllegalAccessException}. Resolving the same signature on a public interface (e.g. + * {@code PersistentDataHolder}, {@code PersistentDataContainer}) yields an invocable handle. + *

+ * Returns {@code null} when the method is absent (e.g. on legacy servers) or the call fails — callers + * supply a sensible default for primitive returns. This preserves full behaviour on modern servers while + * degrading gracefully on legacy ones. + * + * @author Slimefun (Java-8 port) + */ +public final class ReflectionCompat { + + private ReflectionCompat() {} + + @Nullable + public static Object invoke(@Nullable Object target, String name, Object... args) { + if (target == null) { + return null; + } + + try { + Method method = resolve(target.getClass(), name, args); + + if (method != null) { + return method.invoke(target, args); + } + } catch (Throwable ignored) { + // Method missing on this server version or invocation failed — fall through to null. + } + + return null; + } + + /** + * Invokes a {@code public static} method on {@code clazz} by name + arity + assignable param types. + * Returns {@code null} when the method is absent (e.g. on legacy servers) or the call fails. + */ + @Nullable + public static Object invokeStatic(Class clazz, String name, Object... args) { + try { + Method method = resolve(clazz, name, args); + + if (method != null) { + return method.invoke(null, args); + } + } catch (Throwable ignored) { + // Method missing on this server version or invocation failed — fall through to null. + } + + return null; + } + + @Nullable + private static Method resolve(Class type, String name, Object[] args) { + for (Method method : type.getMethods()) { + if (!method.getName().equals(name) || method.getParameterCount() != args.length) { + continue; + } + + Class[] paramTypes = method.getParameterTypes(); + boolean matches = true; + + for (int i = 0; i < args.length; i++) { + if (args[i] != null && !box(paramTypes[i]).isAssignableFrom(args[i].getClass())) { + matches = false; + break; + } + } + + if (matches) { + return invocable(method, paramTypes); + } + } + + return null; + } + + /** + * Ensures the matched method can actually be invoked. If its declaring class is non-public (a + * craftbukkit implementation type), the same signature is looked up on a public supertype/interface; + * forcing access is the last resort. + */ + private static Method invocable(Method method, Class[] paramTypes) { + if (Modifier.isPublic(method.getDeclaringClass().getModifiers())) { + return method; + } + + Method publicMethod = searchPublic(method.getDeclaringClass(), method.getName(), paramTypes); + + if (publicMethod != null) { + return publicMethod; + } + + try { + method.setAccessible(true); + } catch (Throwable ignored) { + // Strong encapsulation may forbid this — invocation will then fail and the caller gets null. + } + + return method; + } + + @Nullable + private static Method searchPublic(Class type, String name, Class[] paramTypes) { + for (Class current = type; current != null; current = current.getSuperclass()) { + if (Modifier.isPublic(current.getModifiers())) { + try { + Method candidate = current.getMethod(name, paramTypes); + + if (Modifier.isPublic(candidate.getDeclaringClass().getModifiers())) { + return candidate; + } + } catch (NoSuchMethodException ignored) { + // Not declared here — keep walking. + } + } + + for (Class iface : current.getInterfaces()) { + Method candidate = searchPublic(iface, name, paramTypes); + + if (candidate != null) { + return candidate; + } + } + } + + return null; + } + + private static Class box(Class type) { + if (!type.isPrimitive()) { + return type; + } + + if (type == int.class) { + return Integer.class; + } else if (type == boolean.class) { + return Boolean.class; + } else if (type == long.class) { + return Long.class; + } else if (type == double.class) { + return Double.class; + } else if (type == float.class) { + return Float.class; + } else if (type == short.class) { + return Short.class; + } else if (type == byte.class) { + return Byte.class; + } else if (type == char.class) { + return Character.class; + } + + return type; + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/RegistryCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/RegistryCompat.java new file mode 100644 index 0000000000..236a7ec7a9 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/RegistryCompat.java @@ -0,0 +1,33 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import javax.annotation.Nullable; + +import org.bukkit.NamespacedKey; + +/** + * Java-8 universal port: {@code org.bukkit.Registry} (1.14+) does not exist at the 1.8.8 compile floor, + * so it cannot be referenced as a type. This helper resolves {@code Registry..get(NamespacedKey)} + * entirely through reflection (no {@code Registry} type anywhere), returning {@code null} on versions + * that lack the registry. Callers supply a legacy fallback (e.g. {@code Enchantment#getByName}). + */ +public final class RegistryCompat { + + private RegistryCompat() {} + + @Nullable + public static Object get(String registryFieldName, String key) { + try { + Class registryClass = Class.forName("org.bukkit.Registry"); + Object registry = registryClass.getField(registryFieldName).get(null); + + // NamespacedKey resolves to the server's real class at runtime (the stub is compile-only); + // on servers without it (<1.12) this throws and we fall through to null. + Object namespacedKey = NamespacedKey.minecraft(key); + Class nskClass = Class.forName("org.bukkit.NamespacedKey"); + + return registryClass.getMethod("get", nskClass).invoke(registry, namespacedKey); + } catch (Throwable ignored) { + return null; + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/SoundCategory.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/SoundCategory.java new file mode 100644 index 0000000000..3bd3e135b2 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/SoundCategory.java @@ -0,0 +1,23 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +/** + * Java-8 universal port: a version-independent stand-in for {@code org.bukkit.SoundCategory} + * (introduced in MC 1.11). The constants mirror Bukkit's exactly so call sites only need to swap + * their import. {@link io.github.thebusybiscuit.slimefun5.utils.compatibility.SoundCompat} maps these + * to the real Bukkit {@code SoundCategory} reflectively on 1.11+, and simply ignores the category on + * older servers (which have no sound categories). + * + * @author Slimefun (Java-8 port) + */ +public enum SoundCategory { + MASTER, + MUSIC, + RECORDS, + WEATHER, + BLOCKS, + HOSTILE, + NEUTRAL, + PLAYERS, + AMBIENT, + VOICE; +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/SoundCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/SoundCompat.java new file mode 100644 index 0000000000..5055a39403 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/SoundCompat.java @@ -0,0 +1,138 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Method; +import java.util.Optional; + +import javax.annotation.Nullable; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import com.cryptomorin.xseries.XSound; + +/** + * Java-8 universal port: cross-version sound playback. + *

+ * Sound enum names were renamed across 1.9/1.13, and {@code SoundCategory} plus the category-aware + * {@code playSound} overloads only exist on 1.11+. This helper resolves a modern sound id to the + * running server's {@link Sound} via {@link XSound}, then plays it through the category overload + * reflectively when available (1.11+) and falls back to the plain {@code playSound(Location, Sound, + * float, float)} overload (present since 1.8) otherwise. {@code org.bukkit.SoundCategory} is only ever + * touched via reflection, so this class loads on every supported version. + * + * @author Slimefun (Java-8 port) + */ +public final class SoundCompat { + + private static final Class BUKKIT_CATEGORY; + private static final Method WORLD_PLAY_WITH_CATEGORY; + private static final Method PLAYER_PLAY_WITH_CATEGORY; + + static { + Class category = null; + Method worldMethod = null; + Method playerMethod = null; + + try { + category = Class.forName("org.bukkit.SoundCategory"); + worldMethod = World.class.getMethod("playSound", Location.class, Sound.class, category, float.class, float.class); + playerMethod = Player.class.getMethod("playSound", Location.class, Sound.class, category, float.class, float.class); + } catch (Throwable ignored) { + // Pre-1.11 server: no SoundCategory / no category-aware overload. Fall back below. + category = null; + worldMethod = null; + playerMethod = null; + } + + BUKKIT_CATEGORY = category; + WORLD_PLAY_WITH_CATEGORY = worldMethod; + PLAYER_PLAY_WITH_CATEGORY = playerMethod; + } + + private SoundCompat() {} + + @Nullable + private static Sound resolve(@Nullable String soundId) { + if (soundId == null) { + return null; + } + + Optional sound = XSound.matchXSound(soundId); + return sound.isPresent() ? sound.get().parseSound() : null; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Nullable + private static Object toBukkitCategory(@Nullable SoundCategory category) { + if (BUKKIT_CATEGORY == null || category == null) { + return null; + } + + try { + return Enum.valueOf((Class) BUKKIT_CATEGORY, category.name()); + } catch (Throwable ignored) { + return null; + } + } + + /** + * Plays a sound at a {@link Location} for everyone nearby, honouring the {@link SoundCategory} on + * servers that support it. + */ + public static void playAt(@Nullable Location loc, @Nullable String soundId, @Nullable SoundCategory category, float volume, float pitch) { + if (loc == null || loc.getWorld() == null) { + return; + } + + Sound sound = resolve(soundId); + + if (sound == null) { + return; + } + + World world = loc.getWorld(); + Object bukkitCategory = toBukkitCategory(category); + + if (WORLD_PLAY_WITH_CATEGORY != null && bukkitCategory != null) { + try { + WORLD_PLAY_WITH_CATEGORY.invoke(world, loc, sound, bukkitCategory, volume, pitch); + return; + } catch (Throwable ignored) { + // Fall through to the legacy overload. + } + } + + world.playSound(loc, sound, volume, pitch); + } + + /** + * Plays a sound to a single {@link Player}, honouring the {@link SoundCategory} on servers that + * support it. + */ + public static void playFor(@Nullable Player player, @Nullable Location loc, @Nullable String soundId, @Nullable SoundCategory category, float volume, float pitch) { + if (player == null || loc == null) { + return; + } + + Sound sound = resolve(soundId); + + if (sound == null) { + return; + } + + Object bukkitCategory = toBukkitCategory(category); + + if (PLAYER_PLAY_WITH_CATEGORY != null && bukkitCategory != null) { + try { + PLAYER_PLAY_WITH_CATEGORY.invoke(player, loc, sound, bukkitCategory, volume, pitch); + return; + } catch (Throwable ignored) { + // Fall through to the legacy overload. + } + } + + player.playSound(loc, sound, volume, pitch); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/Tag.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/Tag.java new file mode 100644 index 0000000000..71fffe8521 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/Tag.java @@ -0,0 +1,209 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; + +/** + * Version-independent replacement for {@code org.bukkit.Tag}. + * + *

+ * The real {@code org.bukkit.Tag} interface is declared as {@code Tag} and only + * exists from Minecraft 1.13 onwards. On the 1.8.8 API floor that this project compiles against, + * {@link Material} does not implement {@code Keyed}, so {@code SlimefunTag implements Tag} + * cannot be expressed against the real type. This compat interface drops the {@code Keyed} bound and + * is therefore usable on every supported version. + * + *

+ * The vanilla tag constants below resolve to the server's real {@code org.bukkit.Tag} values + * reflectively on modern servers (so modern versions keep the complete, up-to-date tag contents) and + * fall back to a name-based {@link Material} set on legacy versions where the tag system is absent. + * + * @param + * The type contained in this {@link Tag}, usually {@link Material} + */ +public interface Tag { + + /** + * @return The values held by this {@link Tag}. + */ + Set getValues(); + + /** + * @param value + * The value to test + * + * @return Whether the given value is contained in this {@link Tag}. + */ + boolean isTagged(T value); + + /** Registry name mirroring {@code org.bukkit.Tag.REGISTRY_ITEMS}. */ + String REGISTRY_ITEMS = "items"; + + /** Registry name mirroring {@code org.bukkit.Tag.REGISTRY_BLOCKS}. */ + String REGISTRY_BLOCKS = "blocks"; + + // Vanilla tag constants used across Slimefun. Each is backed by the real server tag on modern + // versions and a best-effort name list on legacy versions. + + Tag LOGS = new MinecraftTag(REGISTRY_BLOCKS, "logs", "LOG", "LOG_2", "OAK_LOG", "SPRUCE_LOG", "BIRCH_LOG", "JUNGLE_LOG", "ACACIA_LOG", "DARK_OAK_LOG"); + Tag PLANKS = new MinecraftTag(REGISTRY_BLOCKS, "planks", "WOOD", "OAK_PLANKS", "SPRUCE_PLANKS", "BIRCH_PLANKS", "JUNGLE_PLANKS", "ACACIA_PLANKS", "DARK_OAK_PLANKS"); + Tag LEAVES = new MinecraftTag(REGISTRY_BLOCKS, "leaves", "LEAVES", "LEAVES_2", "OAK_LEAVES", "SPRUCE_LEAVES", "BIRCH_LEAVES", "JUNGLE_LEAVES", "ACACIA_LEAVES", "DARK_OAK_LEAVES"); + Tag SAPLINGS = new MinecraftTag(REGISTRY_BLOCKS, "saplings", "SAPLING", "OAK_SAPLING", "SPRUCE_SAPLING", "BIRCH_SAPLING", "JUNGLE_SAPLING", "ACACIA_SAPLING", "DARK_OAK_SAPLING"); + Tag SMALL_FLOWERS = new MinecraftTag(REGISTRY_BLOCKS, "small_flowers", "DANDELION", "POPPY", "RED_ROSE", "YELLOW_FLOWER", "BLUE_ORCHID", "ALLIUM", "AZURE_BLUET", "RED_TULIP", "ORANGE_TULIP", "WHITE_TULIP", "PINK_TULIP", "OXEYE_DAISY"); + Tag CORALS = new MinecraftTag(REGISTRY_BLOCKS, "corals"); + Tag CORAL_BLOCKS = new MinecraftTag(REGISTRY_BLOCKS, "coral_blocks"); + Tag WOODEN_SLABS = new MinecraftTag(REGISTRY_BLOCKS, "wooden_slabs", "WOOD_STEP", "WOODEN_SLAB", "OAK_SLAB", "SPRUCE_SLAB", "BIRCH_SLAB", "JUNGLE_SLAB", "ACACIA_SLAB", "DARK_OAK_SLAB"); + Tag WOODEN_BUTTONS = new MinecraftTag(REGISTRY_BLOCKS, "wooden_buttons", "WOOD_BUTTON", "WOODEN_BUTTON", "OAK_BUTTON", "SPRUCE_BUTTON", "BIRCH_BUTTON", "JUNGLE_BUTTON", "ACACIA_BUTTON", "DARK_OAK_BUTTON"); + Tag WOODEN_FENCES = new MinecraftTag(REGISTRY_BLOCKS, "wooden_fences", "FENCE", "OAK_FENCE", "SPRUCE_FENCE", "BIRCH_FENCE", "JUNGLE_FENCE", "ACACIA_FENCE", "DARK_OAK_FENCE"); + Tag WOODEN_TRAPDOORS = new MinecraftTag(REGISTRY_BLOCKS, "wooden_trapdoors", "TRAP_DOOR", "WOODEN_TRAPDOOR", "OAK_TRAPDOOR", "SPRUCE_TRAPDOOR", "BIRCH_TRAPDOOR", "JUNGLE_TRAPDOOR", "ACACIA_TRAPDOOR", "DARK_OAK_TRAPDOOR"); + Tag WOODEN_PRESSURE_PLATES = new MinecraftTag(REGISTRY_BLOCKS, "wooden_pressure_plates", "WOOD_PLATE", "OAK_PRESSURE_PLATE", "SPRUCE_PRESSURE_PLATE", "BIRCH_PRESSURE_PLATE", "JUNGLE_PRESSURE_PLATE", "ACACIA_PRESSURE_PLATE", "DARK_OAK_PRESSURE_PLATE"); + Tag WOODEN_DOORS = new MinecraftTag(REGISTRY_BLOCKS, "wooden_doors", "WOOD_DOOR", "WOODEN_DOOR", "OAK_DOOR", "SPRUCE_DOOR", "BIRCH_DOOR", "JUNGLE_DOOR", "ACACIA_DOOR", "DARK_OAK_DOOR"); + Tag STANDING_SIGNS = new MinecraftTag(REGISTRY_BLOCKS, "standing_signs", "SIGN_POST", "SIGN", "OAK_SIGN", "SPRUCE_SIGN", "BIRCH_SIGN", "JUNGLE_SIGN", "ACACIA_SIGN", "DARK_OAK_SIGN"); + Tag SIGNS = new MinecraftTag(REGISTRY_BLOCKS, "signs", "SIGN", "WALL_SIGN", "SIGN_POST", "OAK_SIGN", "OAK_WALL_SIGN", "SPRUCE_SIGN", "BIRCH_SIGN", "JUNGLE_SIGN", "ACACIA_SIGN", "DARK_OAK_SIGN"); + Tag FIRE = new MinecraftTag(REGISTRY_BLOCKS, "fire", "FIRE", "SOUL_FIRE"); + Tag ITEMS_BOATS = new MinecraftTag(REGISTRY_ITEMS, "boats", "BOAT", "OAK_BOAT", "SPRUCE_BOAT", "BIRCH_BOAT", "JUNGLE_BOAT", "ACACIA_BOAT", "DARK_OAK_BOAT"); + Tag ITEMS_FISHES = new MinecraftTag(REGISTRY_ITEMS, "fishes", "RAW_FISH", "COOKED_FISH", "COD", "SALMON", "TROPICAL_FISH", "PUFFERFISH", "COOKED_COD", "COOKED_SALMON"); + + /** + * Looks up a vanilla Minecraft {@link Tag} by registry and key, returning a snapshot wrapped as a + * compat {@link Tag}. Returns {@code null} when the tag does not exist (or on legacy versions + * without the tag system). + * + * @param registry + * Either {@link #REGISTRY_ITEMS} or {@link #REGISTRY_BLOCKS} + * @param key + * The key portion of the tag (e.g. {@code "logs"}) + * + * @return A compat {@link Tag} snapshot, or {@code null} if unavailable + */ + static Tag lookup(String registry, String key) { + Set values = MinecraftTag.resolveVanilla(registry, key); + + if (values == null) { + return null; + } + + return new SnapshotTag(values); + } +} + +/** + * A {@link Tag} backed by the server's real {@code org.bukkit.Tag} (resolved reflectively and cached + * lazily), with a name-based {@link Material} fallback for legacy versions. + */ +class MinecraftTag implements Tag { + + private final String registry; + private final String key; + private final String[] fallbackNames; + private volatile Set cached; + + MinecraftTag(String registry, String key, String... fallbackNames) { + this.registry = registry; + this.key = key; + this.fallbackNames = fallbackNames; + } + + @Override + public Set getValues() { + Set result = cached; + + if (result == null) { + Set resolved = resolveVanilla(registry, key); + + if (resolved == null || resolved.isEmpty()) { + resolved = resolveFallback(); + } + + result = Collections.unmodifiableSet(resolved); + cached = result; + } + + return result; + } + + @Override + public boolean isTagged(Material value) { + return getValues().contains(value); + } + + private Set resolveFallback() { + Set set = new HashSet<>(); + + for (String name : fallbackNames) { + Material material = Material.matchMaterial(name); + + if (material != null) { + set.add(material); + } + } + + return set; + } + + /** + * Reflectively resolves the materials of a real {@code org.bukkit.Tag}. Returns {@code null} when + * the server does not support the tag system (legacy versions) or the tag does not exist. + */ + static Set resolveVanilla(String registry, String key) { + try { + // Bukkit#getTag expects the REAL org.bukkit.NamespacedKey; build it reflectively from our own + // key (BukkitKeys) and resolve the real class for the method signature. On legacy versions + // getTag/NamespacedKey are absent, so this throws and we fall back. + Class bukkitKeyClass = Class.forName("org.bukkit.NamespacedKey"); + Object namespacedKey = BukkitKeys.toBukkit(NamespacedKey.minecraft(key)); + Method getTag = Bukkit.class.getMethod("getTag", String.class, bukkitKeyClass, Class.class); + Object tag = getTag.invoke(null, registry, namespacedKey, Material.class); + + if (tag == null) { + return null; + } + + Object values = tag.getClass().getMethod("getValues").invoke(tag); + + if (values instanceof Set) { + Set result = new HashSet<>(); + + for (Object element : (Set) values) { + if (element instanceof Material) { + result.add((Material) element); + } + } + + return result; + } + + return null; + } catch (Throwable e) { + return null; + } + } +} + +/** + * A {@link Tag} wrapping a fixed, pre-resolved {@link Set} of {@link Material Materials}. + */ +class SnapshotTag implements Tag { + + private final Set values; + + SnapshotTag(Set values) { + this.values = Collections.unmodifiableSet(new HashSet<>(values)); + } + + @Override + public Set getValues() { + return values; + } + + @Override + public boolean isTagged(Material value) { + return values.contains(value); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedEnchantment.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedEnchantment.java new file mode 100644 index 0000000000..6958dc8b45 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedEnchantment.java @@ -0,0 +1,55 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import org.bukkit.enchantments.Enchantment; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +// Java-8 universal port: resolve enchantments without referencing org.bukkit.Registry (1.14+, absent on +// the 1.8.8 floor). Modern servers resolve via Registry.ENCHANTMENT (through RegistryCompat); legacy +// servers fall back to the deprecated Enchantment#getByName using the pre-1.13 field names. +// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#86-110 +public class VersionedEnchantment { + + public static final Enchantment EFFICIENCY; + public static final Enchantment UNBREAKING; + public static final Enchantment PROTECTION; + public static final Enchantment SHARPNESS; + public static final Enchantment LUCK_OF_THE_SEA; + public static final Enchantment AQUA_AFFINITY; + public static final Enchantment FORTUNE; + public static final Enchantment MENDING; + public static final Enchantment BINDING_CURSE; + public static final Enchantment VANISHING_CURSE; + + static { + // modern registry key, then pre-1.13 legacy field name + EFFICIENCY = getKey("efficiency", "DIG_SPEED"); + UNBREAKING = getKey("unbreaking", "DURABILITY"); + PROTECTION = getKey("protection", "PROTECTION_ENVIRONMENTAL"); + SHARPNESS = getKey("sharpness", "DAMAGE_ALL"); + LUCK_OF_THE_SEA = getKey("luck_of_the_sea", "LUCK"); + AQUA_AFFINITY = getKey("aqua_affinity", "WATER_WORKER"); + FORTUNE = getKey("fortune", "LOOT_BONUS_BLOCKS"); + // Added after 1.8 — no pre-1.13 alias, so null on the very oldest servers. + MENDING = getKey("mending", "MENDING"); + BINDING_CURSE = getKey("binding_curse", "BINDING_CURSE"); + VANISHING_CURSE = getKey("vanishing_curse", "VANISHING_CURSE"); + } + + @Nullable + @SuppressWarnings("deprecation") + private static Enchantment getKey(@Nonnull String key, @Nonnull String legacyName) { + Object modern = RegistryCompat.get("ENCHANTMENT", key); + + if (modern instanceof Enchantment) { + return (Enchantment) modern; + } + + try { + return Enchantment.getByName(legacyName); + } catch (Throwable ignored) { + return null; + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedEntityType.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedEntityType.java new file mode 100644 index 0000000000..feea0611cd --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedEntityType.java @@ -0,0 +1,42 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import org.bukkit.entity.EntityType; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +// Java-8 universal port: resolve entity types without referencing org.bukkit.Registry (1.14+, absent on +// the 1.8.8 floor). Modern servers resolve via Registry.ENTITY_TYPE (through RegistryCompat); legacy +// servers fall back to EntityType.valueOf using the pre-1.13 enum names. +// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#158-193 +public class VersionedEntityType { + + public static final EntityType MOOSHROOM; + public static final EntityType SNOW_GOLEM; + public static final EntityType FIREWORK; + + static { + // MUSHROOM_COW is renamed to MOOSHROOM in 1.20.5 + MOOSHROOM = getKey("mooshroom", "MUSHROOM_COW"); + + // SNOWMAN is renamed to SNOW_GOLEM in 1.20.5 + SNOW_GOLEM = getKey("snow_golem", "SNOWMAN"); + + FIREWORK = getKey("firework_rocket", "FIREWORK"); + } + + @Nullable + private static EntityType getKey(@Nonnull String key, @Nonnull String legacyName) { + Object modern = RegistryCompat.get("ENTITY_TYPE", key); + + if (modern instanceof EntityType) { + return (EntityType) modern; + } + + try { + return EntityType.valueOf(legacyName); + } catch (Throwable ignored) { + return null; + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedItemFlag.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedItemFlag.java new file mode 100644 index 0000000000..9ffc21cd4f --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedItemFlag.java @@ -0,0 +1,57 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Field; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.meta.ItemMeta; + +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; + +public class VersionedItemFlag { + + public static final @Nullable ItemFlag HIDE_ADDITIONAL_TOOLTIP; + + // HIDE_ATTRIBUTES and HIDE_ENCHANTS were removed in 1.21.5+ in favor of + // the tooltip_display component. We resolve them via reflection so the + // plugin does not crash on newer versions where these constants no longer exist. + public static final @Nullable ItemFlag HIDE_ATTRIBUTES; + public static final @Nullable ItemFlag HIDE_ENCHANTS; + + static { + MinecraftVersion version = Slimefun.getMinecraftVersion(); + + if (version != null && version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5)) { + ItemFlag flag = getKey("HIDE_ADDITIONAL_TOOLTIP"); + HIDE_ADDITIONAL_TOOLTIP = flag != null ? flag : getKey("HIDE_POTION_EFFECTS"); + } else { + HIDE_ADDITIONAL_TOOLTIP = getKey("HIDE_POTION_EFFECTS"); + } + + HIDE_ATTRIBUTES = getKey("HIDE_ATTRIBUTES"); + HIDE_ENCHANTS = getKey("HIDE_ENCHANTS"); + } + + // Safely adds ItemFlags to ItemMeta, skipping null flags that don't exist in the current Minecraft version + public static void addFlags(@Nonnull ItemMeta meta, @Nullable ItemFlag... flags) { + for (ItemFlag flag : flags) { + if (flag != null) { + meta.addItemFlags(flag); + } + } + } + + @Nullable + private static ItemFlag getKey(@Nonnull String key) { + try { + Field field = ItemFlag.class.getDeclaredField(key); + return (ItemFlag) field.get(null); + } catch(Exception e) { + return null; + } + } +} + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedParticle.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedParticle.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedParticle.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedParticle.java index fafd340cc0..8e830b8a48 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedParticle.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedParticle.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.compatibility; +package io.github.thebusybiscuit.slimefun5.utils.compatibility; import java.lang.reflect.Field; @@ -7,8 +7,8 @@ import org.bukkit.Particle; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; // https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#281-318 public class VersionedParticle { @@ -23,6 +23,19 @@ public class VersionedParticle { public static final Particle ENCHANT; static { + // org.bukkit.Particle is a 1.9+ type. On 1.8 it doesn't exist, so touching Particle.class or + // Particle.X here would fail class initialization (NoClassDefFoundError). Guard on the API's + // presence and leave every field null pre-1.9 - ParticleCompat already no-ops on a null particle. + if (!classExists("org.bukkit.Particle")) { + DUST = null; + SMOKE = null; + HAPPY_VILLAGER = null; + ENCHANTED_HIT = null; + EXPLOSION = null; + WITCH = null; + FIREWORK = null; + ENCHANT = null; + } else { MinecraftVersion version = Slimefun.getMinecraftVersion(); // REDSTONE is renamed to DUST in 1.20.5 @@ -64,6 +77,16 @@ public class VersionedParticle { ENCHANT = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) ? Particle.ENCHANT : getKey("ENCHANTMENT_TABLE"); + } + } + + private static boolean classExists(@Nonnull String name) { + try { + Class.forName(name); + return true; + } catch (Throwable ignored) { + return false; + } } @Nullable @@ -76,3 +99,4 @@ private static Particle getKey(@Nonnull String key) { } } } + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPlayerHead.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPlayerHead.java new file mode 100644 index 0000000000..e6e408316a --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPlayerHead.java @@ -0,0 +1,273 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; +import org.bukkit.block.Block; +import org.bukkit.block.Skull; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.profile.PlayerProfile; +import org.bukkit.profile.PlayerTextures; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; + +/** + * Java-8 universal port: applies head textures across versions. The player-profile API (1.18+) is + * reached reflectively via {@link ProfileCompat} (so legacy servers simply skip the texture path), and + * the HTTP lookups use Java 8's {@link HttpURLConnection} instead of the 11+ {@code java.net.http} client. + */ +public final class VersionedPlayerHead { + + private static final String PROFILE_NAME = "CS-CoreLib"; + + private VersionedPlayerHead() {} + + public static @Nonnull ItemStack getItemStack(@Nonnull String base64) { + // XMaterial#parseItem carries the legacy data value (SKULL_ITEM:3 = player head) on 1.8-1.12, + // unlike parseMaterial() which drops it and would yield a skeleton skull (data 0). + ItemStack item = XMaterial.PLAYER_HEAD.parseItem(); + + if (item == null) { + item = MaterialCompat.stack(XMaterial.PLAYER_HEAD); + } + + SkullMeta meta = (SkullMeta) item.getItemMeta(); + + applyTextureToMeta(meta, base64); + + item.setItemMeta(meta); + return item; + } + + public static void applyTextureToMeta(@Nonnull SkullMeta meta, @Nonnull String base64) { + UUID uuid = UUID.nameUUIDFromBytes(base64.getBytes(StandardCharsets.UTF_8)); + PlayerProfile profile = ProfileCompat.createProfile(uuid, PROFILE_NAME); + + if (profile != null) { + // Modern path (1.18+): the Bukkit PlayerProfile / PlayerTextures API. + URL skinUrl = extractSkinUrl(base64); + + if (skinUrl != null) { + PlayerTextures textures = profile.getTextures(); + textures.setSkin(skinUrl); + profile.setTextures(textures); + ProfileCompat.setOwnerProfile(meta, profile); + } + } else { + // Legacy path (1.8-1.17): set the GameProfile "textures" property directly on the meta. + applyLegacyTexture(meta, uuid, base64); + } + } + + /** + * Applies a head texture on servers without the {@code PlayerProfile} API (pre-1.18) by reflectively + * setting a {@code com.mojang.authlib.GameProfile} (with a {@code textures} property) on the + * {@code CraftMetaSkull#profile} field. No-op if the server's internals don't match. + * + * @param meta + * The {@link SkullMeta} to modify + * @param uuid + * A stable UUID derived from the texture + * @param base64 + * The base64-encoded textures value + */ + private static void applyLegacyTexture(@Nonnull SkullMeta meta, @Nonnull UUID uuid, @Nonnull String base64) { + try { + Class gameProfileClass = Class.forName("com.mojang.authlib.GameProfile"); + Class propertyClass = Class.forName("com.mojang.authlib.properties.Property"); + + Object gameProfile = gameProfileClass.getConstructor(UUID.class, String.class).newInstance(uuid, PROFILE_NAME); + Object properties = gameProfileClass.getMethod("getProperties").invoke(gameProfile); + Object property = propertyClass.getConstructor(String.class, String.class).newInstance("textures", base64); + + // PropertyMap extends Guava's ForwardingMultimap -> put(key, value) + properties.getClass().getMethod("put", Object.class, Object.class).invoke(properties, "textures", property); + + java.lang.reflect.Field profileField = meta.getClass().getDeclaredField("profile"); + profileField.setAccessible(true); + profileField.set(meta, gameProfile); + } catch (Throwable e) { + // Server internals differ - leave the head without a custom texture rather than crashing. + } + } + + public static void setSkin(@Nonnull Block block, @Nonnull String base64, boolean sendBlockUpdate) { + Material material = block.getType(); + if (material != XMaterial.PLAYER_HEAD.parseMaterial() && material != XMaterial.PLAYER_WALL_HEAD.parseMaterial()) { + return; + } + + UUID uuid = UUID.nameUUIDFromBytes(base64.getBytes(StandardCharsets.UTF_8)); + URL skinUrl = extractSkinUrl(base64); + + if (skinUrl != null) { + PlayerProfile profile = ProfileCompat.createProfile(uuid, PROFILE_NAME); + + if (profile != null) { + Skull skull = (Skull) block.getState(); + PlayerTextures textures = profile.getTextures(); + textures.setSkin(skinUrl); + profile.setTextures(textures); + ProfileCompat.setOwnerProfile(skull, profile); + skull.update(sendBlockUpdate, false); + } + } + } + + public static void setSkinFromHash(@Nonnull Block block, @Nonnull UUID uuid, @Nonnull String hashCode, boolean sendBlockUpdate) { + Material material = block.getType(); + if (material != XMaterial.PLAYER_HEAD.parseMaterial() && material != XMaterial.PLAYER_WALL_HEAD.parseMaterial()) { + return; + } + + URL skinUrl = getTextureUrl(hashCode); + + if (skinUrl != null) { + PlayerProfile profile = ProfileCompat.createProfile(uuid, PROFILE_NAME); + + if (profile != null) { + Skull skull = (Skull) block.getState(); + PlayerTextures textures = profile.getTextures(); + textures.setSkin(skinUrl); + profile.setTextures(textures); + ProfileCompat.setOwnerProfile(skull, profile); + skull.update(sendBlockUpdate, false); + } + } + } + + public static @Nonnull String hashToBase64(@Nonnull String hashCode) { + String value = "{\"textures\":{\"SKIN\":{\"url\":\"https://textures.minecraft.net/texture/" + hashCode + "\"}}}"; + return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8)); + } + + public static @Nonnull CompletableFuture fetchSkinTexture(@Nonnull UUID playerUuid) { + return CompletableFuture.supplyAsync(() -> { + try { + String targetUrl = "https://sessionserver.mojang.com/session/minecraft/profile/" + + playerUuid.toString().replace("-", "") + "?unsigned=false"; + + String body = httpGet(targetUrl, null); + JsonObject obj = new JsonParser().parse(body).getAsJsonObject(); + + if (obj.has("error")) { + throw new RuntimeException(obj.get("error").getAsString()); + } + + for (JsonElement el : obj.get("properties").getAsJsonArray()) { + if (el.isJsonObject() && el.getAsJsonObject().get("name").getAsString().equals("textures")) { + return el.getAsJsonObject().get("value").getAsString(); + } + } + + return null; + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } + + public static @Nonnull CompletableFuture lookupUUID(@Nonnull String username) { + return CompletableFuture.supplyAsync(() -> { + try { + String targetUrl = "https://playerdb.co/api/player/minecraft/" + username; + + String body = httpGet(targetUrl, "Mozilla/5.0 Dough (+https://github.com/baked-libs/dough)"); + JsonObject jsonObject = new JsonParser().parse(body).getAsJsonObject(); + + if (jsonObject.get("success").getAsBoolean()) { + JsonObject data = jsonObject.getAsJsonObject("data"); + JsonObject player = data.getAsJsonObject("player"); + return UUID.fromString(player.get("id").getAsString()); + } + + return null; + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } + + /** + * Java-8 HTTP GET via {@link HttpURLConnection} (the universal jar cannot use the 11+ HTTP client). + * Reads the response body from the input stream, falling back to the error stream on a non-2xx + * status so error JSON (e.g. Mojang's {@code {"error":...}}) is still returned to the caller. + */ + @Nonnull + private static String httpGet(@Nonnull String targetUrl, @Nullable String userAgent) throws IOException { + HttpURLConnection connection = (HttpURLConnection) new URL(targetUrl).openConnection(); + + try { + connection.setRequestMethod("GET"); + connection.setConnectTimeout(30000); + connection.setReadTimeout(30000); + + if (userAgent != null) { + connection.setRequestProperty("user-agent", userAgent); + } + + InputStream stream; + try { + stream = connection.getInputStream(); + } catch (IOException e) { + stream = connection.getErrorStream(); + + if (stream == null) { + throw e; + } + } + + try (InputStream in = stream; ByteArrayOutputStream out = new ByteArrayOutputStream()) { + byte[] buffer = new byte[4096]; + int read; + + while ((read = in.read(buffer)) != -1) { + out.write(buffer, 0, read); + } + + return new String(out.toByteArray(), StandardCharsets.UTF_8); + } + } finally { + connection.disconnect(); + } + } + + @Nullable + private static URL getTextureUrl(@Nonnull String hashCode) { + try { + return URI.create("https://textures.minecraft.net/texture/" + hashCode).toURL(); + } catch (MalformedURLException e) { + return null; + } + } + + @Nullable + private static URL extractSkinUrl(@Nonnull String base64) { + try { + String decoded = new String(Base64.getDecoder().decode(base64), StandardCharsets.UTF_8); + JsonObject json = new JsonParser().parse(decoded).getAsJsonObject(); + String url = json.getAsJsonObject("textures").getAsJsonObject("SKIN").get("url").getAsString(); + return URI.create(url).toURL(); + } catch (Exception e) { + return null; + } + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPotionEffectType.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPotionEffectType.java new file mode 100644 index 0000000000..514ed39386 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPotionEffectType.java @@ -0,0 +1,63 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Field; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.bukkit.potion.PotionEffectType; + +// Java-8 port: the post-1.20.5 names (SLOWNESS, HASTE, ...) do not exist at the 1.8.8 floor, so we +// resolve every field reflectively by name (modern first, legacy fallback) instead of referencing the +// modern constants directly. See VersionedParticle for the same pattern. +// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#216-228 +public class VersionedPotionEffectType { + + public static final PotionEffectType SLOWNESS; + public static final PotionEffectType HASTE; + public static final PotionEffectType MINING_FATIGUE; + public static final PotionEffectType STRENGTH; + public static final PotionEffectType INSTANT_HEALTH; + public static final PotionEffectType INSTANT_DAMAGE; + public static final PotionEffectType JUMP_BOOST; + public static final PotionEffectType NAUSEA; + public static final PotionEffectType RESISTANCE; + // Added in 1.13 with no legacy alias; null on versions lacking it. + public static final PotionEffectType SLOW_FALLING; + // Added in 1.9 with no legacy alias; null on versions lacking it. + public static final PotionEffectType LEVITATION; + // Added in 1.14 with no legacy alias; null on versions lacking it. + public static final PotionEffectType BAD_OMEN; + + static { + SLOWNESS = resolve("SLOWNESS", "SLOW"); + HASTE = resolve("HASTE", "FAST_DIGGING"); + MINING_FATIGUE = resolve("MINING_FATIGUE", "SLOW_DIGGING"); + STRENGTH = resolve("STRENGTH", "INCREASE_DAMAGE"); + INSTANT_HEALTH = resolve("INSTANT_HEALTH", "HEAL"); + INSTANT_DAMAGE = resolve("INSTANT_DAMAGE", "HARM"); + JUMP_BOOST = resolve("JUMP_BOOST", "JUMP"); + NAUSEA = resolve("NAUSEA", "CONFUSION"); + RESISTANCE = resolve("RESISTANCE", "DAMAGE_RESISTANCE"); + SLOW_FALLING = resolve("SLOW_FALLING", "SLOW_FALLING"); + LEVITATION = resolve("LEVITATION", "LEVITATION"); + BAD_OMEN = resolve("BAD_OMEN", "BAD_OMEN"); + } + + @Nullable + private static PotionEffectType resolve(@Nonnull String modern, @Nonnull String legacy) { + PotionEffectType type = getKey(modern); + return type != null ? type : getKey(legacy); + } + + @Nullable + private static PotionEffectType getKey(@Nonnull String key) { + try { + Field field = PotionEffectType.class.getDeclaredField(key); + return (PotionEffectType) field.get(null); + } catch(Exception e) { + return null; + } + } +} + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPotionType.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPotionType.java new file mode 100644 index 0000000000..995c088fca --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VersionedPotionType.java @@ -0,0 +1,52 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import java.lang.reflect.Field; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.bukkit.potion.PotionType; + +// Java-8 port: the post-1.20.5 names do not exist at the 1.8.8 floor, so we resolve every field +// reflectively by name (modern first, legacy fallback). See VersionedParticle for the same pattern. +// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#242-250 +public class VersionedPotionType { + + public static final PotionType LEAPING; + public static final PotionType SWIFTNESS; + public static final PotionType HEALING; + public static final PotionType HARMING; + public static final PotionType REGENERATION; + // Constants absent on the 1.8.8 enum (no legacy alias); null on versions lacking them. + public static final PotionType AWKWARD; + public static final PotionType TURTLE_MASTER; + public static final PotionType SLOW_FALLING; + + static { + LEAPING = resolve("LEAPING", "JUMP"); + SWIFTNESS = resolve("SWIFTNESS", "SPEED"); + HEALING = resolve("HEALING", "INSTANT_HEAL"); + HARMING = resolve("HARMING", "INSTANT_DAMAGE"); + REGENERATION = resolve("REGENERATION", "REGEN"); + AWKWARD = resolve("AWKWARD", "AWKWARD"); + TURTLE_MASTER = resolve("TURTLE_MASTER", "TURTLE_MASTER"); + SLOW_FALLING = resolve("SLOW_FALLING", "SLOW_FALLING"); + } + + @Nullable + private static PotionType resolve(@Nonnull String modern, @Nonnull String legacy) { + PotionType type = getKey(modern); + return type != null ? type : getKey(legacy); + } + + @Nullable + private static PotionType getKey(@Nonnull String key) { + try { + Field field = PotionType.class.getDeclaredField(key); + return (PotionType) field.get(null); + } catch(Exception e) { + return null; + } + } +} + diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VillagerCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VillagerCompat.java new file mode 100644 index 0000000000..2b162eeb85 --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/VillagerCompat.java @@ -0,0 +1,33 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import javax.annotation.Nullable; + +import org.bukkit.entity.Villager; + +/** + * Java-8 universal port: the {@link Villager.Profession} enum gained {@code NITWIT} (1.11) and + * {@code NONE} (1.14), and the leveled-trade setters {@code setVillagerExperience}/{@code setVillagerLevel} + * are 1.11+. Profession constants are resolved by name (null when absent) and the setters go through + * reflection so the code compiles against the 1.8.8 floor while keeping full behaviour on modern servers. + */ +public final class VillagerCompat { + + private VillagerCompat() {} + + @Nullable + public static Villager.Profession profession(String name) { + try { + return Villager.Profession.valueOf(name); + } catch (Throwable ignored) { + return null; + } + } + + public static void setVillagerExperience(Villager villager, int experience) { + ReflectionCompat.invoke(villager, "setVillagerExperience", experience); + } + + public static void setVillagerLevel(Villager villager, int level) { + ReflectionCompat.invoke(villager, "setVillagerLevel", level); + } +} diff --git a/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/WorldCompat.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/WorldCompat.java new file mode 100644 index 0000000000..310e98a3dc --- /dev/null +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/compatibility/WorldCompat.java @@ -0,0 +1,35 @@ +package io.github.thebusybiscuit.slimefun5.utils.compatibility; + +import org.bukkit.Location; +import org.bukkit.World; + +/** + * Java-8 universal port: cross-version {@link World} helpers for APIs added after 1.8.8. + *

+ * {@code World#getMinHeight()} is 1.17+ (worlds started at y=0 before) and the predicate-less + * {@code WorldBorder#isInside(Location)} is 1.20.4+. Both are reached reflectively. + */ +public final class WorldCompat { + + private WorldCompat() {} + + /** + * Reflective {@code World#getMinHeight()} (1.17+). Returns {@code 0} on older servers, where worlds + * always start at y=0. + */ + public static int getMinHeight(World world) { + Object result = ReflectionCompat.invoke(world, "getMinHeight"); + return result instanceof Integer ? (Integer) result : 0; + } + + /** + * Reflective {@code WorldBorder#isInside(Location)} (1.20.4+). Returns {@code true} (treat as inside) + * on older servers where the method is absent, so legacy behaviour is unchanged. + */ + public static boolean isInside(World world, Location location) { + Object border = ReflectionCompat.invoke(world, "getWorldBorder"); + Object inside = ReflectionCompat.invoke(border, "isInside", location); + // Only treat as outside when the call explicitly returned false. + return !Boolean.FALSE.equals(inside); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ColoredFireworkStar.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/ColoredFireworkStar.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ColoredFireworkStar.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/ColoredFireworkStar.java index 36ccef1cb8..12c70ddfc7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ColoredFireworkStar.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/ColoredFireworkStar.java @@ -1,11 +1,12 @@ -package io.github.thebusybiscuit.slimefun4.utils.itemstack; +package io.github.thebusybiscuit.slimefun5.utils.itemstack; import io.github.bakedlibs.dough.items.ItemStackEditor; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedItemFlag; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedItemFlag; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; import org.bukkit.Material; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkEffectMeta; @@ -13,7 +14,7 @@ /** * This simple {@link ItemStack} implementation allows us to obtain - * a colored {@code Material.FIREWORK_STAR} {@link ItemStack} quickly. + * a colored {@code XMaterial.FIREWORK_STAR.parseMaterial()} {@link ItemStack} quickly. * * @author TheBusyBiscuit * @@ -23,12 +24,13 @@ public class ColoredFireworkStar { @ParametersAreNonnullByDefault public static ItemStack create(Color color, String name, String... lore) { FireworkEffect effect = FireworkEffect.builder().with(Type.BURST).withColor(color).build(); - return new ItemStackEditor(Material.FIREWORK_STAR) + return new ItemStackEditor(XMaterial.FIREWORK_STAR.parseMaterial()) .setDisplayName(name) .setLore(lore) - .addFlags(VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP) + .andMetaConsumer(meta -> VersionedItemFlag.addFlags(meta, VersionedItemFlag.HIDE_ADDITIONAL_TOOLTIP)) .andMetaConsumer(FireworkEffectMeta.class, meta -> meta.setEffect(effect)) .create(); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/ItemStackWrapper.java similarity index 93% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/ItemStackWrapper.java index 9091db07b8..73a2d67629 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/ItemStackWrapper.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.itemstack; +package io.github.thebusybiscuit.slimefun5.utils.itemstack; import java.util.ArrayList; import java.util.List; @@ -74,10 +74,8 @@ public boolean equals(Object obj) { throw new UnsupportedOperationException(ERROR_MESSAGE); } - @Override - public int hashCode() { - throw new UnsupportedOperationException(ERROR_MESSAGE); - } + // Note: ItemStack#hashCode() is final on the 1.8.8 API floor, so it cannot be overridden here. + // The wrapper is never used as a hash key, so inheriting ItemStack's hashCode is acceptable. @Override public ItemStack clone() { @@ -132,8 +130,8 @@ public void addUnsafeEnchantment(Enchantment ench, int level) { public static @Nonnull ItemStackWrapper wrap(@Nonnull ItemStack itemStack) { Validate.notNull(itemStack, "The ItemStack cannot be null!"); - if (itemStack instanceof ItemStackWrapper wrapper) { - return wrapper; + if (itemStack instanceof ItemStackWrapper) { + ItemStackWrapper wrapper = (ItemStackWrapper) itemStack; return wrapper; } return new ItemStackWrapper(itemStack); @@ -185,3 +183,4 @@ public void addUnsafeEnchantment(Enchantment ench, int level) { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/SlimefunGuideItem.java similarity index 74% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/SlimefunGuideItem.java index 2acc1df0e0..a4a11a13bb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/SlimefunGuideItem.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/SlimefunGuideItem.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.utils.itemstack; +package io.github.thebusybiscuit.slimefun5.utils.itemstack; + +import io.github.thebusybiscuit.slimefun5.utils.compatibility.PdcCompat; import java.util.ArrayList; import java.util.List; @@ -11,10 +13,10 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideImplementation; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; /** * This is just a helper {@link ItemStack} class for the {@link SlimefunGuide} {@link ItemStack}. @@ -41,10 +43,11 @@ public SlimefunGuideItem(@Nonnull SlimefunGuideImplementation implementation, @N meta.setLore(lore); - PersistentDataAPI.setString(meta, Slimefun.getRegistry().getGuideDataKey(), type.name()); + PdcCompat.setString(meta, Slimefun.getRegistry().getGuideDataKey(), type.name()); Slimefun.getItemTextureService().setTexture(meta, "SLIMEFUN_GUIDE"); setItemMeta(meta); } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/package-info.java similarity index 71% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/package-info.java index 5eda112b56..b2734ccdba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/itemstack/package-info.java @@ -2,4 +2,4 @@ * This package contains some utility classes that revolve around the creation or handling of an * {@link org.bukkit.inventory.ItemStack}. */ -package io.github.thebusybiscuit.slimefun4.utils.itemstack; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.utils.itemstack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/package-info.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/package-info.java similarity index 73% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/package-info.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/package-info.java index 2aee49f530..a899569f99 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/package-info.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/package-info.java @@ -2,4 +2,4 @@ * This package contains some utility classes that offer handy ways to do stuff. * They are often not directly related to Slimefun. */ -package io.github.thebusybiscuit.slimefun4.utils; \ No newline at end of file +package io.github.thebusybiscuit.slimefun5.utils; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/tags/SlimefunTag.java similarity index 91% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/tags/SlimefunTag.java index 7eab9b680f..a3c9b92a6d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/tags/SlimefunTag.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.tags; +package io.github.thebusybiscuit.slimefun5.utils.tags; import java.util.Collections; import java.util.HashMap; @@ -11,25 +11,24 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractAutoCrafter; +import io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters.AbstractAutoCrafter; import org.apache.commons.lang.Validate; import org.bukkit.Material; -import org.bukkit.NamespacedKey; -import org.bukkit.Tag; -import org.bukkit.block.data.Waterlogged; - -import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.EnhancedFurnace; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators.CropGrowthAccelerator; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; -import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner.IndustrialMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveShovel; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfTheSeeker; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfVeinMining; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.SmeltersPickaxe; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; + +import io.github.thebusybiscuit.slimefun5.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.BlockPlacer; +import io.github.thebusybiscuit.slimefun5.implementation.items.blocks.EnhancedFurnace; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.accelerators.CropGrowthAccelerator; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.Talisman; +import io.github.thebusybiscuit.slimefun5.implementation.items.multiblocks.miner.IndustrialMiner; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.ClimbingPick; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.ExplosiveShovel; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.PickaxeOfTheSeeker; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.PickaxeOfVeinMining; +import io.github.thebusybiscuit.slimefun5.implementation.items.tools.SmeltersPickaxe; /** * This enum contains various implementations of the {@link Tag} interface. @@ -173,7 +172,7 @@ public enum SlimefunTag implements Tag { SENSITIVE_MATERIALS, /** - * These Materials are sensitive to fluids, they cannot be {@link Waterlogged} + * These Materials are sensitive to fluids, they cannot be {@code Waterlogged} * and would break in contact with water. */ FLUID_SENSITIVE_MATERIALS, @@ -342,7 +341,6 @@ public static void reloadAll() throws TagMisconfigurationException { } } - @Override public @Nonnull NamespacedKey getKey() { return key; } @@ -439,3 +437,4 @@ public boolean isEmpty() { } } + diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/tags/TagParser.java similarity index 69% rename from src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java rename to core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/tags/TagParser.java index 7667e9ceed..86c9da2c3c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/core/src/main/java/io/github/thebusybiscuit/slimefun5/utils/tags/TagParser.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.tags; +package io.github.thebusybiscuit.slimefun5.utils.tags; import java.io.BufferedReader; import java.io.IOException; @@ -11,14 +11,17 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.Keyed; +import io.github.thebusybiscuit.slimefun5.libraries.keys.Keyed; import org.bukkit.Material; -import org.bukkit.NamespacedKey; -import org.bukkit.Tag; +import io.github.thebusybiscuit.slimefun5.libraries.keys.NamespacedKey; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.Tag; + +import com.cryptomorin.xseries.XMaterial; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -27,10 +30,10 @@ import com.google.gson.JsonPrimitive; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.JsonUtils; -import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; +import io.github.thebusybiscuit.slimefun5.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.JsonUtils; +import io.github.thebusybiscuit.slimefun5.utils.PatternUtils; /** * The {@link TagParser} is responsible for parsing a JSON input into a {@link SlimefunTag}. @@ -105,8 +108,8 @@ public void parse(@Nonnull String json, @Nonnull BiConsumer, Set, Set materials, Set> tags, boolean throwException) throws TagMisconfigurationException { if (PatternUtils.MINECRAFT_NAMESPACEDKEY.matcher(value).matches()) { // Match the NamespacedKey against Materials - Material material = Material.matchMaterial(value); + Material material = matchMaterialCompat(value); if (material != null) { // If the Material could be matched, simply add it to our Set materials.add(material); - } else if (throwException) { + } else if (throwException && !isLegacyServer()) { + // On a legacy server an unresolved material almost always means it was added in a + // newer Minecraft version, not a misconfiguration - skip it silently so the rest of + // the tag still loads. On modern servers this stays a hard error. throw new TagMisconfigurationException(key, "Minecraft Material '" + value + "' seems to not exist!"); } } else if (PatternUtils.MINECRAFT_TAG.matcher(value).matches()) { // Get the actual Key portion and match it to item and block tags. String keyValue = CommonPatterns.COLON.split(value)[1]; - NamespacedKey namespacedKey = NamespacedKey.minecraft(keyValue); - Tag itemsTag = Bukkit.getTag(Tag.REGISTRY_ITEMS, namespacedKey, Material.class); - Tag blocksTag = Bukkit.getTag(Tag.REGISTRY_BLOCKS, namespacedKey, Material.class); + Tag itemsTag = Tag.lookup(Tag.REGISTRY_ITEMS, keyValue); + Tag blocksTag = Tag.lookup(Tag.REGISTRY_BLOCKS, keyValue); if (itemsTag != null) { // We will prioritize the item tag @@ -155,8 +160,8 @@ private void parsePrimitiveValue(String value, Set materials, Set materials, Set materials, Set> tags) throws TagMisconfigurationException { JsonElement id = entry.get("id"); JsonElement required = entry.get("required"); // Check if the entry contains elements of the correct type - if (id instanceof JsonPrimitive idJson && idJson.isString() && required instanceof JsonPrimitive requiredJson && requiredJson.isBoolean()) { - boolean isRequired = required.getAsBoolean(); + if (id instanceof JsonPrimitive && ((JsonPrimitive) id).isString() && required instanceof JsonPrimitive && ((JsonPrimitive) required).isBoolean()) { + JsonPrimitive idJson = (JsonPrimitive) id; boolean isRequired = required.getAsBoolean(); /* * If the Tag is required, an exception may be thrown. @@ -200,3 +236,4 @@ private void parseComplexValue(JsonObject entry, Set materials, Set { @@ -71,3 +71,4 @@ public boolean test(ItemStack item) { } } + diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineRecipe.java b/core/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineRecipe.java similarity index 100% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineRecipe.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineRecipe.java diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java b/core/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java similarity index 94% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java index 9c368d67ad..d520d71875 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java +++ b/core/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java @@ -8,8 +8,8 @@ import org.bukkit.inventory.Inventory; import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -75,3 +75,4 @@ public boolean canOpen(Block b, Player p) { } } + diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockTicker.java b/core/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockTicker.java similarity index 83% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockTicker.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockTicker.java index 23d3bd2b8d..c22f277a92 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockTicker.java +++ b/core/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockTicker.java @@ -4,10 +4,11 @@ import org.bukkit.block.Block; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IncompatibleItemHandlerException; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.MaterialCompat; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; @@ -24,7 +25,7 @@ public void update() { @Override public Optional validate(SlimefunItem item) { - if (!item.getItem().getType().isBlock()) { + if (!MaterialCompat.isPlaceableBlock(item.getItem().getType())) { return Optional.of(new IncompatibleItemHandlerException("Only Materials that are blocks can have a BlockTicker.", item, this)); } @@ -75,3 +76,4 @@ public void startNewTick() { } } + diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java b/core/src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java similarity index 100% rename from src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java b/core/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java similarity index 98% rename from src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java index 78c9cc90a7..9d08008a87 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java +++ b/core/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java @@ -37,9 +37,9 @@ import io.github.bakedlibs.dough.blocks.BlockPosition; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.NumberUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; @@ -202,7 +202,7 @@ private void loadBlock(File file, FileConfiguration cfg, String key) { * error to the console (if enabled). */ if (Slimefun.getRegistry().logDuplicateBlockEntries()) { - Slimefun.logger().log(Level.INFO, "Ignoring duplicate block @ %d, %d, %d (%s -> %s)".formatted(l.getBlockX(), l.getBlockY(), l.getBlockZ(), blockInfo.getString("id"), storage.get(l).getString("id"))); + Slimefun.logger().log(Level.INFO, String.format("Ignoring duplicate block @ %d, %d, %d (%s -> %s)", l.getBlockX(), l.getBlockY(), l.getBlockZ(), blockInfo.getString("id"), storage.get(l).getString("id"))); } return; @@ -944,3 +944,4 @@ public boolean hasUniversalInventory(Location l) { return id != null && hasUniversalInventory(id); } } + diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/EmptyBlockData.java b/core/src/main/java/me/mrCookieSlime/Slimefun/api/EmptyBlockData.java similarity index 100% rename from src/main/java/me/mrCookieSlime/Slimefun/api/EmptyBlockData.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/api/EmptyBlockData.java diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java b/core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java similarity index 98% rename from src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java index f270ba6ee1..7f430edbf8 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java +++ b/core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java @@ -10,7 +10,7 @@ import org.bukkit.inventory.ItemStack; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; // This class will be deprecated, relocated and rewritten in a future version. public class BlockMenu extends DirtyChestMenu { @@ -123,3 +123,4 @@ public void delete(Location l) { } } } + diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java b/core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java similarity index 96% rename from src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java index 1ef479341f..3d23bbf106 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java +++ b/core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java @@ -14,9 +14,9 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.ChestMenuUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -233,8 +233,8 @@ protected void clone(@Nonnull DirtyChestMenu menu) { menu.addItem(size - 1, null); } - if (menu instanceof BlockMenu blockMenu) { - newInstance(blockMenu, blockMenu.getLocation()); + if (menu instanceof BlockMenu) { + BlockMenu blockMenu = (BlockMenu) menu; newInstance(blockMenu, blockMenu.getLocation()); } for (int slot = 0; slot < 54; slot++) { @@ -299,3 +299,4 @@ public static boolean isUniversalInventory(String id) { } } + diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java b/core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java similarity index 98% rename from src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java index dd2bf8cd12..c9efbe2b49 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java +++ b/core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java @@ -15,7 +15,7 @@ import io.github.bakedlibs.dough.inventory.InvUtils; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; @@ -171,3 +171,4 @@ public void replaceExistingItem(int slot, ItemStack item, boolean event) { } } + diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalBlockMenu.java b/core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalBlockMenu.java similarity index 100% rename from src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalBlockMenu.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalBlockMenu.java diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemTransportFlow.java b/core/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemTransportFlow.java similarity index 92% rename from src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemTransportFlow.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemTransportFlow.java index 44d30158f4..efb893350c 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemTransportFlow.java +++ b/core/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemTransportFlow.java @@ -3,7 +3,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; +import io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -33,3 +33,4 @@ public enum ItemTransportFlow { WITHDRAW; } + diff --git a/src/main/java/me/mrCookieSlime/Slimefun/package-info.java b/core/src/main/java/me/mrCookieSlime/Slimefun/package-info.java similarity index 62% rename from src/main/java/me/mrCookieSlime/Slimefun/package-info.java rename to core/src/main/java/me/mrCookieSlime/Slimefun/package-info.java index 35f9fff788..837350f75a 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/package-info.java +++ b/core/src/main/java/me/mrCookieSlime/Slimefun/package-info.java @@ -1,5 +1,5 @@ /** - * Old Slimefun 4.0 code. + * Legacy (pre-rewrite) Slimefun code. */ @java.lang.Deprecated package me.mrCookieSlime.Slimefun; \ No newline at end of file diff --git a/src/main/java/me/mrCookieSlime/package-info.java b/core/src/main/java/me/mrCookieSlime/package-info.java similarity index 100% rename from src/main/java/me/mrCookieSlime/package-info.java rename to core/src/main/java/me/mrCookieSlime/package-info.java diff --git a/core/src/main/resources/SlimefunMetrics.jar b/core/src/main/resources/SlimefunMetrics.jar new file mode 100644 index 0000000000..4924fa5e44 Binary files /dev/null and b/core/src/main/resources/SlimefunMetrics.jar differ diff --git a/src/main/resources/biome-maps/nether_ice_v1.16.json b/core/src/main/resources/biome-maps/nether_ice_v1.16.json similarity index 100% rename from src/main/resources/biome-maps/nether_ice_v1.16.json rename to core/src/main/resources/biome-maps/nether_ice_v1.16.json diff --git a/src/main/resources/biome-maps/oil_v1.16.json b/core/src/main/resources/biome-maps/oil_v1.16.json similarity index 94% rename from src/main/resources/biome-maps/oil_v1.16.json rename to core/src/main/resources/biome-maps/oil_v1.16.json index d0d5636e4e..34bacf9db9 100644 --- a/src/main/resources/biome-maps/oil_v1.16.json +++ b/core/src/main/resources/biome-maps/oil_v1.16.json @@ -15,9 +15,7 @@ { "value" : 20, "biomes" : [ - "minecraft:swamp", - "minecraft:swamp_hills" - ] + "minecraft:swamp"] }, { "value" : 24, @@ -42,7 +40,6 @@ "value" : 45, "biomes" : [ "minecraft:desert", - "minecraft:desert_hills", "minecraft:desert_lakes" ] }, diff --git a/src/main/resources/biome-maps/oil_v1.18.json b/core/src/main/resources/biome-maps/oil_v1.18.json similarity index 100% rename from src/main/resources/biome-maps/oil_v1.18.json rename to core/src/main/resources/biome-maps/oil_v1.18.json diff --git a/src/main/resources/biome-maps/salt_v1.16.json b/core/src/main/resources/biome-maps/salt_v1.16.json similarity index 88% rename from src/main/resources/biome-maps/salt_v1.16.json rename to core/src/main/resources/biome-maps/salt_v1.16.json index 1fd00fde09..6066e7d1aa 100644 --- a/src/main/resources/biome-maps/salt_v1.16.json +++ b/core/src/main/resources/biome-maps/salt_v1.16.json @@ -2,9 +2,7 @@ { "value" : 20, "biomes" : [ - "minecraft:swamp", - "minecraft:swamp_hills" - ] + "minecraft:swamp"] }, { "value" : 40, diff --git a/src/main/resources/biome-maps/salt_v1.18.json b/core/src/main/resources/biome-maps/salt_v1.18.json similarity index 100% rename from src/main/resources/biome-maps/salt_v1.18.json rename to core/src/main/resources/biome-maps/salt_v1.18.json diff --git a/src/main/resources/biome-maps/uranium_v1.16.json b/core/src/main/resources/biome-maps/uranium_v1.16.json similarity index 81% rename from src/main/resources/biome-maps/uranium_v1.16.json rename to core/src/main/resources/biome-maps/uranium_v1.16.json index 425266cefb..544e5110f4 100644 --- a/src/main/resources/biome-maps/uranium_v1.16.json +++ b/core/src/main/resources/biome-maps/uranium_v1.16.json @@ -12,15 +12,9 @@ "biomes" : [ "minecraft:mountains", "minecraft:wooded_mountains", - "minecraft:desert_hills", - "minecraft:wooded_hills", - "minecraft:taiga_hills", "minecraft:mountain_edge", - "minecraft:jungle_hills", "minecraft:gravelly_mountains", "minecraft:taiga_mountains", - "minecraft:tall_birch_hills", - "minecraft:dark_forest_hills", "minecraft:snowy_taiga_mountains", "minecraft:giant_spruce_taiga_hills", "minecraft:modified_gravelly_mountains", diff --git a/src/main/resources/biome-maps/uranium_v1.17.json b/core/src/main/resources/biome-maps/uranium_v1.17.json similarity index 82% rename from src/main/resources/biome-maps/uranium_v1.17.json rename to core/src/main/resources/biome-maps/uranium_v1.17.json index 7c8e1f8ba1..fb84b08ebb 100644 --- a/src/main/resources/biome-maps/uranium_v1.17.json +++ b/core/src/main/resources/biome-maps/uranium_v1.17.json @@ -12,15 +12,9 @@ "biomes" : [ "minecraft:mountains", "minecraft:wooded_mountains", - "minecraft:desert_hills", - "minecraft:wooded_hills", - "minecraft:taiga_hills", "minecraft:mountain_edge", - "minecraft:jungle_hills", "minecraft:gravelly_mountains", "minecraft:taiga_mountains", - "minecraft:tall_birch_hills", - "minecraft:dark_forest_hills", "minecraft:snowy_taiga_mountains", "minecraft:giant_spruce_taiga_hills", "minecraft:modified_gravelly_mountains", diff --git a/src/main/resources/biome-maps/uranium_v1.18.json b/core/src/main/resources/biome-maps/uranium_v1.18.json similarity index 100% rename from src/main/resources/biome-maps/uranium_v1.18.json rename to core/src/main/resources/biome-maps/uranium_v1.18.json diff --git a/src/main/resources/config.yml b/core/src/main/resources/config.yml similarity index 95% rename from src/main/resources/config.yml rename to core/src/main/resources/config.yml index 5e36b700b7..39bebabac8 100644 --- a/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -2,10 +2,10 @@ options: # Instead of disabling Auto Updates consider using the "stable" version of Slimefun. # These builds are much more tested and are far less likely to have any issues. # Note: When running a stable build auto-updates ONLY update to other stable builds! Perfect eh? - # You can download the latest stable build here: https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/ + # You can download the latest stable build here: https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun5/stable/ auto-update: true - chat-prefix: '&a&lSlimefun 4&7> ' + chat-prefix: '&a&lSlimefun 5&7> ' armor-update-interval: 10 enable-armor-effects: true enable-radiation: true diff --git a/src/main/resources/item-models.yml b/core/src/main/resources/item-models.yml similarity index 100% rename from src/main/resources/item-models.yml rename to core/src/main/resources/item-models.yml diff --git a/src/main/resources/languages/af/categories.yml b/core/src/main/resources/languages/af/categories.yml similarity index 100% rename from src/main/resources/languages/af/categories.yml rename to core/src/main/resources/languages/af/categories.yml diff --git a/src/main/resources/languages/af/messages.yml b/core/src/main/resources/languages/af/messages.yml similarity index 100% rename from src/main/resources/languages/af/messages.yml rename to core/src/main/resources/languages/af/messages.yml diff --git a/src/main/resources/languages/af/recipes.yml b/core/src/main/resources/languages/af/recipes.yml similarity index 100% rename from src/main/resources/languages/af/recipes.yml rename to core/src/main/resources/languages/af/recipes.yml diff --git a/src/main/resources/languages/af/researches.yml b/core/src/main/resources/languages/af/researches.yml similarity index 100% rename from src/main/resources/languages/af/researches.yml rename to core/src/main/resources/languages/af/researches.yml diff --git a/src/main/resources/languages/af/resources.yml b/core/src/main/resources/languages/af/resources.yml similarity index 100% rename from src/main/resources/languages/af/resources.yml rename to core/src/main/resources/languages/af/resources.yml diff --git a/src/main/resources/languages/ar/categories.yml b/core/src/main/resources/languages/ar/categories.yml similarity index 100% rename from src/main/resources/languages/ar/categories.yml rename to core/src/main/resources/languages/ar/categories.yml diff --git a/src/main/resources/languages/ar/messages.yml b/core/src/main/resources/languages/ar/messages.yml similarity index 100% rename from src/main/resources/languages/ar/messages.yml rename to core/src/main/resources/languages/ar/messages.yml diff --git a/src/main/resources/languages/ar/recipes.yml b/core/src/main/resources/languages/ar/recipes.yml similarity index 100% rename from src/main/resources/languages/ar/recipes.yml rename to core/src/main/resources/languages/ar/recipes.yml diff --git a/src/main/resources/languages/ar/researches.yml b/core/src/main/resources/languages/ar/researches.yml similarity index 100% rename from src/main/resources/languages/ar/researches.yml rename to core/src/main/resources/languages/ar/researches.yml diff --git a/src/main/resources/languages/ar/resources.yml b/core/src/main/resources/languages/ar/resources.yml similarity index 100% rename from src/main/resources/languages/ar/resources.yml rename to core/src/main/resources/languages/ar/resources.yml diff --git a/src/main/resources/languages/be/categories.yml b/core/src/main/resources/languages/be/categories.yml similarity index 100% rename from src/main/resources/languages/be/categories.yml rename to core/src/main/resources/languages/be/categories.yml diff --git a/src/main/resources/languages/be/messages.yml b/core/src/main/resources/languages/be/messages.yml similarity index 100% rename from src/main/resources/languages/be/messages.yml rename to core/src/main/resources/languages/be/messages.yml diff --git a/src/main/resources/languages/be/recipes.yml b/core/src/main/resources/languages/be/recipes.yml similarity index 100% rename from src/main/resources/languages/be/recipes.yml rename to core/src/main/resources/languages/be/recipes.yml diff --git a/src/main/resources/languages/be/researches.yml b/core/src/main/resources/languages/be/researches.yml similarity index 100% rename from src/main/resources/languages/be/researches.yml rename to core/src/main/resources/languages/be/researches.yml diff --git a/src/main/resources/languages/be/resources.yml b/core/src/main/resources/languages/be/resources.yml similarity index 100% rename from src/main/resources/languages/be/resources.yml rename to core/src/main/resources/languages/be/resources.yml diff --git a/src/main/resources/languages/bg/categories.yml b/core/src/main/resources/languages/bg/categories.yml similarity index 100% rename from src/main/resources/languages/bg/categories.yml rename to core/src/main/resources/languages/bg/categories.yml diff --git a/src/main/resources/languages/bg/messages.yml b/core/src/main/resources/languages/bg/messages.yml similarity index 99% rename from src/main/resources/languages/bg/messages.yml rename to core/src/main/resources/languages/bg/messages.yml index b4553da96d..da09cea6d3 100644 --- a/src/main/resources/languages/bg/messages.yml +++ b/core/src/main/resources/languages/bg/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Slimefun Ръководство' settings: 'Настройки & Информация' languages: 'Изберете вашия предпочитан език' - credits: 'Slimefun4 Контрибутори' - wiki: 'Slimefun4 Уики' - addons: 'Добавки за Slimefun4' + credits: 'Slimefun5 Контрибутори' + wiki: 'Slimefun5 Уики' + addons: 'Добавки за Slimefun5' bugs: 'Бъг Доклади' source: 'Програмен Код' versions: 'Инсталирани версии' diff --git a/src/main/resources/languages/bg/recipes.yml b/core/src/main/resources/languages/bg/recipes.yml similarity index 100% rename from src/main/resources/languages/bg/recipes.yml rename to core/src/main/resources/languages/bg/recipes.yml diff --git a/src/main/resources/languages/bg/researches.yml b/core/src/main/resources/languages/bg/researches.yml similarity index 100% rename from src/main/resources/languages/bg/researches.yml rename to core/src/main/resources/languages/bg/researches.yml diff --git a/src/main/resources/languages/bg/resources.yml b/core/src/main/resources/languages/bg/resources.yml similarity index 100% rename from src/main/resources/languages/bg/resources.yml rename to core/src/main/resources/languages/bg/resources.yml diff --git a/src/main/resources/languages/cs/categories.yml b/core/src/main/resources/languages/cs/categories.yml similarity index 100% rename from src/main/resources/languages/cs/categories.yml rename to core/src/main/resources/languages/cs/categories.yml diff --git a/src/main/resources/languages/cs/messages.yml b/core/src/main/resources/languages/cs/messages.yml similarity index 99% rename from src/main/resources/languages/cs/messages.yml rename to core/src/main/resources/languages/cs/messages.yml index cf75d51422..8da1672c0f 100644 --- a/src/main/resources/languages/cs/messages.yml +++ b/core/src/main/resources/languages/cs/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Slimefun příručka' settings: 'Nastavení a informace' languages: 'Zvol svůj preferovaný jazyk' - credits: 'Slimefun4 pomocníci' - wiki: 'Slimefun4 Wiki' - addons: 'Doplňky pro Slimefun4' + credits: 'Slimefun5 pomocníci' + wiki: 'Slimefun5 Wiki' + addons: 'Doplňky pro Slimefun5' bugs: 'Nahlášení chyb' source: 'Zdrojový kód' versions: 'Nainstalovaná verze' diff --git a/src/main/resources/languages/cs/recipes.yml b/core/src/main/resources/languages/cs/recipes.yml similarity index 100% rename from src/main/resources/languages/cs/recipes.yml rename to core/src/main/resources/languages/cs/recipes.yml diff --git a/src/main/resources/languages/cs/researches.yml b/core/src/main/resources/languages/cs/researches.yml similarity index 100% rename from src/main/resources/languages/cs/researches.yml rename to core/src/main/resources/languages/cs/researches.yml diff --git a/src/main/resources/languages/cs/resources.yml b/core/src/main/resources/languages/cs/resources.yml similarity index 100% rename from src/main/resources/languages/cs/resources.yml rename to core/src/main/resources/languages/cs/resources.yml diff --git a/src/main/resources/languages/da/categories.yml b/core/src/main/resources/languages/da/categories.yml similarity index 100% rename from src/main/resources/languages/da/categories.yml rename to core/src/main/resources/languages/da/categories.yml diff --git a/src/main/resources/languages/da/messages.yml b/core/src/main/resources/languages/da/messages.yml similarity index 100% rename from src/main/resources/languages/da/messages.yml rename to core/src/main/resources/languages/da/messages.yml diff --git a/src/main/resources/languages/da/recipes.yml b/core/src/main/resources/languages/da/recipes.yml similarity index 100% rename from src/main/resources/languages/da/recipes.yml rename to core/src/main/resources/languages/da/recipes.yml diff --git a/src/main/resources/languages/da/researches.yml b/core/src/main/resources/languages/da/researches.yml similarity index 100% rename from src/main/resources/languages/da/researches.yml rename to core/src/main/resources/languages/da/researches.yml diff --git a/src/main/resources/languages/da/resources.yml b/core/src/main/resources/languages/da/resources.yml similarity index 100% rename from src/main/resources/languages/da/resources.yml rename to core/src/main/resources/languages/da/resources.yml diff --git a/src/main/resources/languages/de/categories.yml b/core/src/main/resources/languages/de/categories.yml similarity index 100% rename from src/main/resources/languages/de/categories.yml rename to core/src/main/resources/languages/de/categories.yml diff --git a/src/main/resources/languages/de/messages.yml b/core/src/main/resources/languages/de/messages.yml similarity index 99% rename from src/main/resources/languages/de/messages.yml rename to core/src/main/resources/languages/de/messages.yml index 5debea0c8e..a9b71397cd 100644 --- a/src/main/resources/languages/de/messages.yml +++ b/core/src/main/resources/languages/de/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Slimefun-Handbuch' settings: 'Einstellungen & Infos' languages: 'Wähle deine bevorzugte Sprache' - credits: 'Slimefun4: Mitwirkende' - wiki: 'Slimefun4-Wiki' - addons: 'Addons für Slimefun4' + credits: 'Slimefun5: Mitwirkende' + wiki: 'Slimefun5-Wiki' + addons: 'Addons für Slimefun5' bugs: 'Fehlermeldungen' source: 'Quellcode' versions: 'Installierte Versionen' diff --git a/src/main/resources/languages/de/recipes.yml b/core/src/main/resources/languages/de/recipes.yml similarity index 100% rename from src/main/resources/languages/de/recipes.yml rename to core/src/main/resources/languages/de/recipes.yml diff --git a/src/main/resources/languages/de/researches.yml b/core/src/main/resources/languages/de/researches.yml similarity index 100% rename from src/main/resources/languages/de/researches.yml rename to core/src/main/resources/languages/de/researches.yml diff --git a/src/main/resources/languages/de/resources.yml b/core/src/main/resources/languages/de/resources.yml similarity index 100% rename from src/main/resources/languages/de/resources.yml rename to core/src/main/resources/languages/de/resources.yml diff --git a/src/main/resources/languages/el/categories.yml b/core/src/main/resources/languages/el/categories.yml similarity index 100% rename from src/main/resources/languages/el/categories.yml rename to core/src/main/resources/languages/el/categories.yml diff --git a/src/main/resources/languages/el/messages.yml b/core/src/main/resources/languages/el/messages.yml similarity index 100% rename from src/main/resources/languages/el/messages.yml rename to core/src/main/resources/languages/el/messages.yml diff --git a/src/main/resources/languages/el/recipes.yml b/core/src/main/resources/languages/el/recipes.yml similarity index 100% rename from src/main/resources/languages/el/recipes.yml rename to core/src/main/resources/languages/el/recipes.yml diff --git a/src/main/resources/languages/el/researches.yml b/core/src/main/resources/languages/el/researches.yml similarity index 100% rename from src/main/resources/languages/el/researches.yml rename to core/src/main/resources/languages/el/researches.yml diff --git a/src/main/resources/languages/el/resources.yml b/core/src/main/resources/languages/el/resources.yml similarity index 100% rename from src/main/resources/languages/el/resources.yml rename to core/src/main/resources/languages/el/resources.yml diff --git a/src/main/resources/languages/en/categories.yml b/core/src/main/resources/languages/en/categories.yml similarity index 100% rename from src/main/resources/languages/en/categories.yml rename to core/src/main/resources/languages/en/categories.yml diff --git a/src/main/resources/languages/en/messages.yml b/core/src/main/resources/languages/en/messages.yml similarity index 99% rename from src/main/resources/languages/en/messages.yml rename to core/src/main/resources/languages/en/messages.yml index 77bd80895a..ade85c6c42 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/core/src/main/resources/languages/en/messages.yml @@ -142,9 +142,9 @@ guide: main: 'Slimefun Guide' settings: 'Settings & Info' languages: 'Select your preferred language' - credits: 'Slimefun4 Contributors' - wiki: 'Slimefun4 Wiki' - addons: 'Addons for Slimefun4' + credits: 'Slimefun5 Contributors' + wiki: 'Slimefun5 Wiki' + addons: 'Addons for Slimefun5' bugs: 'Bug Reports' source: 'Source Code' versions: 'Installed versions' diff --git a/src/main/resources/languages/en/recipes.yml b/core/src/main/resources/languages/en/recipes.yml similarity index 100% rename from src/main/resources/languages/en/recipes.yml rename to core/src/main/resources/languages/en/recipes.yml diff --git a/src/main/resources/languages/en/researches.yml b/core/src/main/resources/languages/en/researches.yml similarity index 100% rename from src/main/resources/languages/en/researches.yml rename to core/src/main/resources/languages/en/researches.yml diff --git a/src/main/resources/languages/en/resources.yml b/core/src/main/resources/languages/en/resources.yml similarity index 100% rename from src/main/resources/languages/en/resources.yml rename to core/src/main/resources/languages/en/resources.yml diff --git a/src/main/resources/languages/es/categories.yml b/core/src/main/resources/languages/es/categories.yml similarity index 100% rename from src/main/resources/languages/es/categories.yml rename to core/src/main/resources/languages/es/categories.yml diff --git a/src/main/resources/languages/es/messages.yml b/core/src/main/resources/languages/es/messages.yml similarity index 99% rename from src/main/resources/languages/es/messages.yml rename to core/src/main/resources/languages/es/messages.yml index a512c91313..8f52343ea2 100644 --- a/src/main/resources/languages/es/messages.yml +++ b/core/src/main/resources/languages/es/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Guía de Slimefun.' settings: 'Configuración e Información.' languages: 'Selecciona tu idioma.' - credits: 'Colaboradores de Slimefun4' - wiki: 'Wiki de Slimefun4' - addons: 'Complementos para Slimefun4' + credits: 'Colaboradores de Slimefun5' + wiki: 'Wiki de Slimefun5' + addons: 'Complementos para Slimefun5' bugs: 'Reportes de Bugs' source: 'Código base' versions: 'Versiones instaladas' diff --git a/src/main/resources/languages/es/recipes.yml b/core/src/main/resources/languages/es/recipes.yml similarity index 100% rename from src/main/resources/languages/es/recipes.yml rename to core/src/main/resources/languages/es/recipes.yml diff --git a/src/main/resources/languages/es/researches.yml b/core/src/main/resources/languages/es/researches.yml similarity index 100% rename from src/main/resources/languages/es/researches.yml rename to core/src/main/resources/languages/es/researches.yml diff --git a/src/main/resources/languages/es/resources.yml b/core/src/main/resources/languages/es/resources.yml similarity index 100% rename from src/main/resources/languages/es/resources.yml rename to core/src/main/resources/languages/es/resources.yml diff --git a/src/main/resources/languages/fa/categories.yml b/core/src/main/resources/languages/fa/categories.yml similarity index 100% rename from src/main/resources/languages/fa/categories.yml rename to core/src/main/resources/languages/fa/categories.yml diff --git a/src/main/resources/languages/fa/messages.yml b/core/src/main/resources/languages/fa/messages.yml similarity index 97% rename from src/main/resources/languages/fa/messages.yml rename to core/src/main/resources/languages/fa/messages.yml index eadfe05e13..1e253db8d9 100644 --- a/src/main/resources/languages/fa/messages.yml +++ b/core/src/main/resources/languages/fa/messages.yml @@ -58,9 +58,9 @@ guide: title: main: 'راهنمای Slimefun' settings: 'تنظیمات و اطلاعات' - credits: 'مشارکت کنندگان Slimefun4' - wiki: 'ویکی Slimefun4' - addons: 'افزون ها برای Slimefun4' + credits: 'مشارکت کنندگان Slimefun5' + wiki: 'ویکی Slimefun5' + addons: 'افزون ها برای Slimefun5' bugs: 'گزارش اشکال ها' source: 'کد منبع' versions: 'نسخه های نصب شده' diff --git a/src/main/resources/languages/fa/recipes.yml b/core/src/main/resources/languages/fa/recipes.yml similarity index 100% rename from src/main/resources/languages/fa/recipes.yml rename to core/src/main/resources/languages/fa/recipes.yml diff --git a/src/main/resources/languages/fa/researches.yml b/core/src/main/resources/languages/fa/researches.yml similarity index 100% rename from src/main/resources/languages/fa/researches.yml rename to core/src/main/resources/languages/fa/researches.yml diff --git a/src/main/resources/languages/fa/resources.yml b/core/src/main/resources/languages/fa/resources.yml similarity index 100% rename from src/main/resources/languages/fa/resources.yml rename to core/src/main/resources/languages/fa/resources.yml diff --git a/src/main/resources/languages/fi/categories.yml b/core/src/main/resources/languages/fi/categories.yml similarity index 100% rename from src/main/resources/languages/fi/categories.yml rename to core/src/main/resources/languages/fi/categories.yml diff --git a/src/main/resources/languages/fi/messages.yml b/core/src/main/resources/languages/fi/messages.yml similarity index 100% rename from src/main/resources/languages/fi/messages.yml rename to core/src/main/resources/languages/fi/messages.yml diff --git a/src/main/resources/languages/fi/recipes.yml b/core/src/main/resources/languages/fi/recipes.yml similarity index 100% rename from src/main/resources/languages/fi/recipes.yml rename to core/src/main/resources/languages/fi/recipes.yml diff --git a/src/main/resources/languages/fi/researches.yml b/core/src/main/resources/languages/fi/researches.yml similarity index 100% rename from src/main/resources/languages/fi/researches.yml rename to core/src/main/resources/languages/fi/researches.yml diff --git a/src/main/resources/languages/fi/resources.yml b/core/src/main/resources/languages/fi/resources.yml similarity index 100% rename from src/main/resources/languages/fi/resources.yml rename to core/src/main/resources/languages/fi/resources.yml diff --git a/src/main/resources/languages/fr/categories.yml b/core/src/main/resources/languages/fr/categories.yml similarity index 100% rename from src/main/resources/languages/fr/categories.yml rename to core/src/main/resources/languages/fr/categories.yml diff --git a/src/main/resources/languages/fr/messages.yml b/core/src/main/resources/languages/fr/messages.yml similarity index 99% rename from src/main/resources/languages/fr/messages.yml rename to core/src/main/resources/languages/fr/messages.yml index a3ef433730..3ac54eb561 100644 --- a/src/main/resources/languages/fr/messages.yml +++ b/core/src/main/resources/languages/fr/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Guide Slimefun' settings: 'Paramètres et informations' languages: 'Choisissez votre langue' - credits: 'Contributeurs de Slimefun4' - wiki: 'Wiki Slimefun4' - addons: 'Extensions de Slimefun4' + credits: 'Contributeurs de Slimefun5' + wiki: 'Wiki Slimefun5' + addons: 'Extensions de Slimefun5' bugs: 'Signaler un bug' source: 'Code Source' versions: 'Versions installées' diff --git a/src/main/resources/languages/fr/recipes.yml b/core/src/main/resources/languages/fr/recipes.yml similarity index 100% rename from src/main/resources/languages/fr/recipes.yml rename to core/src/main/resources/languages/fr/recipes.yml diff --git a/src/main/resources/languages/fr/researches.yml b/core/src/main/resources/languages/fr/researches.yml similarity index 100% rename from src/main/resources/languages/fr/researches.yml rename to core/src/main/resources/languages/fr/researches.yml diff --git a/src/main/resources/languages/fr/resources.yml b/core/src/main/resources/languages/fr/resources.yml similarity index 100% rename from src/main/resources/languages/fr/resources.yml rename to core/src/main/resources/languages/fr/resources.yml diff --git a/src/main/resources/languages/he/categories.yml b/core/src/main/resources/languages/he/categories.yml similarity index 100% rename from src/main/resources/languages/he/categories.yml rename to core/src/main/resources/languages/he/categories.yml diff --git a/src/main/resources/languages/he/messages.yml b/core/src/main/resources/languages/he/messages.yml similarity index 100% rename from src/main/resources/languages/he/messages.yml rename to core/src/main/resources/languages/he/messages.yml diff --git a/src/main/resources/languages/he/recipes.yml b/core/src/main/resources/languages/he/recipes.yml similarity index 100% rename from src/main/resources/languages/he/recipes.yml rename to core/src/main/resources/languages/he/recipes.yml diff --git a/src/main/resources/languages/he/researches.yml b/core/src/main/resources/languages/he/researches.yml similarity index 100% rename from src/main/resources/languages/he/researches.yml rename to core/src/main/resources/languages/he/researches.yml diff --git a/src/main/resources/languages/he/resources.yml b/core/src/main/resources/languages/he/resources.yml similarity index 100% rename from src/main/resources/languages/he/resources.yml rename to core/src/main/resources/languages/he/resources.yml diff --git a/src/main/resources/languages/hi/categories.yml b/core/src/main/resources/languages/hi/categories.yml similarity index 100% rename from src/main/resources/languages/hi/categories.yml rename to core/src/main/resources/languages/hi/categories.yml diff --git a/src/main/resources/languages/hi/messages.yml b/core/src/main/resources/languages/hi/messages.yml similarity index 100% rename from src/main/resources/languages/hi/messages.yml rename to core/src/main/resources/languages/hi/messages.yml diff --git a/src/main/resources/languages/hi/recipes.yml b/core/src/main/resources/languages/hi/recipes.yml similarity index 100% rename from src/main/resources/languages/hi/recipes.yml rename to core/src/main/resources/languages/hi/recipes.yml diff --git a/src/main/resources/languages/hi/researches.yml b/core/src/main/resources/languages/hi/researches.yml similarity index 100% rename from src/main/resources/languages/hi/researches.yml rename to core/src/main/resources/languages/hi/researches.yml diff --git a/src/main/resources/languages/hi/resources.yml b/core/src/main/resources/languages/hi/resources.yml similarity index 100% rename from src/main/resources/languages/hi/resources.yml rename to core/src/main/resources/languages/hi/resources.yml diff --git a/src/main/resources/languages/hr/categories.yml b/core/src/main/resources/languages/hr/categories.yml similarity index 100% rename from src/main/resources/languages/hr/categories.yml rename to core/src/main/resources/languages/hr/categories.yml diff --git a/src/main/resources/languages/hr/messages.yml b/core/src/main/resources/languages/hr/messages.yml similarity index 100% rename from src/main/resources/languages/hr/messages.yml rename to core/src/main/resources/languages/hr/messages.yml diff --git a/src/main/resources/languages/hr/recipes.yml b/core/src/main/resources/languages/hr/recipes.yml similarity index 100% rename from src/main/resources/languages/hr/recipes.yml rename to core/src/main/resources/languages/hr/recipes.yml diff --git a/src/main/resources/languages/hr/researches.yml b/core/src/main/resources/languages/hr/researches.yml similarity index 100% rename from src/main/resources/languages/hr/researches.yml rename to core/src/main/resources/languages/hr/researches.yml diff --git a/src/main/resources/languages/hr/resources.yml b/core/src/main/resources/languages/hr/resources.yml similarity index 100% rename from src/main/resources/languages/hr/resources.yml rename to core/src/main/resources/languages/hr/resources.yml diff --git a/src/main/resources/languages/hu/categories.yml b/core/src/main/resources/languages/hu/categories.yml similarity index 100% rename from src/main/resources/languages/hu/categories.yml rename to core/src/main/resources/languages/hu/categories.yml diff --git a/src/main/resources/languages/hu/messages.yml b/core/src/main/resources/languages/hu/messages.yml similarity index 99% rename from src/main/resources/languages/hu/messages.yml rename to core/src/main/resources/languages/hu/messages.yml index 9f135acb48..b040e91b34 100644 --- a/src/main/resources/languages/hu/messages.yml +++ b/core/src/main/resources/languages/hu/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Slimefun Útmutató' settings: 'Beállítások és Információk' languages: 'Válaszd ki a kívánt nyelvet' - credits: 'Slimefun4 közreműködők' - wiki: 'Slimefun4 Wiki' - addons: 'A Slimefun4 kiegészítői' + credits: 'Slimefun5 közreműködők' + wiki: 'Slimefun5 Wiki' + addons: 'A Slimefun5 kiegészítői' bugs: 'Hibajelentések' source: 'Forráskód' versions: 'Telepített verziók' diff --git a/src/main/resources/languages/hu/recipes.yml b/core/src/main/resources/languages/hu/recipes.yml similarity index 100% rename from src/main/resources/languages/hu/recipes.yml rename to core/src/main/resources/languages/hu/recipes.yml diff --git a/src/main/resources/languages/hu/researches.yml b/core/src/main/resources/languages/hu/researches.yml similarity index 100% rename from src/main/resources/languages/hu/researches.yml rename to core/src/main/resources/languages/hu/researches.yml diff --git a/src/main/resources/languages/hu/resources.yml b/core/src/main/resources/languages/hu/resources.yml similarity index 100% rename from src/main/resources/languages/hu/resources.yml rename to core/src/main/resources/languages/hu/resources.yml diff --git a/src/main/resources/languages/id/categories.yml b/core/src/main/resources/languages/id/categories.yml similarity index 100% rename from src/main/resources/languages/id/categories.yml rename to core/src/main/resources/languages/id/categories.yml diff --git a/src/main/resources/languages/id/messages.yml b/core/src/main/resources/languages/id/messages.yml similarity index 99% rename from src/main/resources/languages/id/messages.yml rename to core/src/main/resources/languages/id/messages.yml index d19eb84def..c24901f273 100644 --- a/src/main/resources/languages/id/messages.yml +++ b/core/src/main/resources/languages/id/messages.yml @@ -84,9 +84,9 @@ guide: main: 'Panduan Slimefun' settings: 'Pengaturan & Informasi' languages: 'Pilih Bahasa Yang Anda Inginkan' - credits: 'Para Kontributor Slimefun4' - wiki: 'Slimefun4 Wiki' - addons: 'Addons untuk Slimefun4' + credits: 'Para Kontributor Slimefun5' + wiki: 'Slimefun5 Wiki' + addons: 'Addons untuk Slimefun5' bugs: 'Laporkan masalah' source: 'Kode sumber' versions: 'Versi Terinstal' diff --git a/src/main/resources/languages/id/recipes.yml b/core/src/main/resources/languages/id/recipes.yml similarity index 100% rename from src/main/resources/languages/id/recipes.yml rename to core/src/main/resources/languages/id/recipes.yml diff --git a/src/main/resources/languages/id/researches.yml b/core/src/main/resources/languages/id/researches.yml similarity index 100% rename from src/main/resources/languages/id/researches.yml rename to core/src/main/resources/languages/id/researches.yml diff --git a/src/main/resources/languages/id/resources.yml b/core/src/main/resources/languages/id/resources.yml similarity index 100% rename from src/main/resources/languages/id/resources.yml rename to core/src/main/resources/languages/id/resources.yml diff --git a/src/main/resources/languages/it/categories.yml b/core/src/main/resources/languages/it/categories.yml similarity index 100% rename from src/main/resources/languages/it/categories.yml rename to core/src/main/resources/languages/it/categories.yml diff --git a/src/main/resources/languages/it/messages.yml b/core/src/main/resources/languages/it/messages.yml similarity index 99% rename from src/main/resources/languages/it/messages.yml rename to core/src/main/resources/languages/it/messages.yml index f01aee0f4c..5ce8eb18f2 100644 --- a/src/main/resources/languages/it/messages.yml +++ b/core/src/main/resources/languages/it/messages.yml @@ -94,8 +94,8 @@ guide: main: 'Guida della Slimefun' settings: 'Impostazioni e informazioni' languages: 'Seleziona la tua lingua preferita' - credits: 'Collaboratori di Slimefun4' - addons: 'Addons per Slimefun4' + credits: 'Collaboratori di Slimefun5' + addons: 'Addons per Slimefun5' source: 'Codice Sorgente' credits: commit: 'Contributo' diff --git a/src/main/resources/languages/it/recipes.yml b/core/src/main/resources/languages/it/recipes.yml similarity index 100% rename from src/main/resources/languages/it/recipes.yml rename to core/src/main/resources/languages/it/recipes.yml diff --git a/src/main/resources/languages/it/researches.yml b/core/src/main/resources/languages/it/researches.yml similarity index 100% rename from src/main/resources/languages/it/researches.yml rename to core/src/main/resources/languages/it/researches.yml diff --git a/src/main/resources/languages/it/resources.yml b/core/src/main/resources/languages/it/resources.yml similarity index 100% rename from src/main/resources/languages/it/resources.yml rename to core/src/main/resources/languages/it/resources.yml diff --git a/src/main/resources/languages/ja/categories.yml b/core/src/main/resources/languages/ja/categories.yml similarity index 100% rename from src/main/resources/languages/ja/categories.yml rename to core/src/main/resources/languages/ja/categories.yml diff --git a/src/main/resources/languages/ja/messages.yml b/core/src/main/resources/languages/ja/messages.yml similarity index 99% rename from src/main/resources/languages/ja/messages.yml rename to core/src/main/resources/languages/ja/messages.yml index 43a343ae1f..0574dc025f 100644 --- a/src/main/resources/languages/ja/messages.yml +++ b/core/src/main/resources/languages/ja/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Slimefunガイド' settings: '設定・情報' languages: '言語の選択' - credits: 'Slimefun4 開発者' + credits: 'Slimefun5 開発者' wiki: 'スライムファン4のウィキ' - addons: 'Slimefun4 アドオン' + addons: 'Slimefun5 アドオン' bugs: 'バグ報告' source: 'ソースコード' versions: 'バージョン一覧' diff --git a/src/main/resources/languages/ja/recipes.yml b/core/src/main/resources/languages/ja/recipes.yml similarity index 100% rename from src/main/resources/languages/ja/recipes.yml rename to core/src/main/resources/languages/ja/recipes.yml diff --git a/src/main/resources/languages/ja/researches.yml b/core/src/main/resources/languages/ja/researches.yml similarity index 100% rename from src/main/resources/languages/ja/researches.yml rename to core/src/main/resources/languages/ja/researches.yml diff --git a/src/main/resources/languages/ja/resources.yml b/core/src/main/resources/languages/ja/resources.yml similarity index 100% rename from src/main/resources/languages/ja/resources.yml rename to core/src/main/resources/languages/ja/resources.yml diff --git a/src/main/resources/languages/ko/categories.yml b/core/src/main/resources/languages/ko/categories.yml similarity index 100% rename from src/main/resources/languages/ko/categories.yml rename to core/src/main/resources/languages/ko/categories.yml diff --git a/src/main/resources/languages/ko/messages.yml b/core/src/main/resources/languages/ko/messages.yml similarity index 99% rename from src/main/resources/languages/ko/messages.yml rename to core/src/main/resources/languages/ko/messages.yml index 85d87150ff..fcfda4733c 100644 --- a/src/main/resources/languages/ko/messages.yml +++ b/core/src/main/resources/languages/ko/messages.yml @@ -68,8 +68,8 @@ guide: settings: '설정 & 정보' languages: '당신이 원하는 언어를 선택하십시오.' credits: '슬라임펀4 기부자들입니다.' - wiki: 'Slimefun4 위키' - addons: 'Slimefun4의 애드온' + wiki: 'Slimefun5 위키' + addons: 'Slimefun5의 애드온' bugs: '버그 리포트' source: '소스 코드' credits: diff --git a/src/main/resources/languages/ko/recipes.yml b/core/src/main/resources/languages/ko/recipes.yml similarity index 100% rename from src/main/resources/languages/ko/recipes.yml rename to core/src/main/resources/languages/ko/recipes.yml diff --git a/src/main/resources/languages/ko/researches.yml b/core/src/main/resources/languages/ko/researches.yml similarity index 100% rename from src/main/resources/languages/ko/researches.yml rename to core/src/main/resources/languages/ko/researches.yml diff --git a/src/main/resources/languages/ko/resources.yml b/core/src/main/resources/languages/ko/resources.yml similarity index 100% rename from src/main/resources/languages/ko/resources.yml rename to core/src/main/resources/languages/ko/resources.yml diff --git a/src/main/resources/languages/lt/categories.yml b/core/src/main/resources/languages/lt/categories.yml similarity index 100% rename from src/main/resources/languages/lt/categories.yml rename to core/src/main/resources/languages/lt/categories.yml diff --git a/src/main/resources/languages/lt/messages.yml b/core/src/main/resources/languages/lt/messages.yml similarity index 100% rename from src/main/resources/languages/lt/messages.yml rename to core/src/main/resources/languages/lt/messages.yml diff --git a/src/main/resources/languages/lt/recipes.yml b/core/src/main/resources/languages/lt/recipes.yml similarity index 100% rename from src/main/resources/languages/lt/recipes.yml rename to core/src/main/resources/languages/lt/recipes.yml diff --git a/src/main/resources/languages/lt/researches.yml b/core/src/main/resources/languages/lt/researches.yml similarity index 100% rename from src/main/resources/languages/lt/researches.yml rename to core/src/main/resources/languages/lt/researches.yml diff --git a/src/main/resources/languages/lt/resources.yml b/core/src/main/resources/languages/lt/resources.yml similarity index 100% rename from src/main/resources/languages/lt/resources.yml rename to core/src/main/resources/languages/lt/resources.yml diff --git a/src/main/resources/languages/lv/categories.yml b/core/src/main/resources/languages/lv/categories.yml similarity index 100% rename from src/main/resources/languages/lv/categories.yml rename to core/src/main/resources/languages/lv/categories.yml diff --git a/src/main/resources/languages/lv/messages.yml b/core/src/main/resources/languages/lv/messages.yml similarity index 99% rename from src/main/resources/languages/lv/messages.yml rename to core/src/main/resources/languages/lv/messages.yml index 93097df43d..9e71f54c9f 100644 --- a/src/main/resources/languages/lv/messages.yml +++ b/core/src/main/resources/languages/lv/messages.yml @@ -33,7 +33,7 @@ guide: main: 'Slimefun grāmata' settings: 'Iestatījumi un informācija' languages: 'Izvēlies savu vēlamo valodu,' - credits: 'Slimefun4 Ieguldītāji' + credits: 'Slimefun5 Ieguldītāji' credits: commit: 'Ieguldījums' commits: 'Ieguldījumi' diff --git a/src/main/resources/languages/lv/recipes.yml b/core/src/main/resources/languages/lv/recipes.yml similarity index 100% rename from src/main/resources/languages/lv/recipes.yml rename to core/src/main/resources/languages/lv/recipes.yml diff --git a/src/main/resources/languages/lv/researches.yml b/core/src/main/resources/languages/lv/researches.yml similarity index 100% rename from src/main/resources/languages/lv/researches.yml rename to core/src/main/resources/languages/lv/researches.yml diff --git a/src/main/resources/languages/lv/resources.yml b/core/src/main/resources/languages/lv/resources.yml similarity index 100% rename from src/main/resources/languages/lv/resources.yml rename to core/src/main/resources/languages/lv/resources.yml diff --git a/src/main/resources/languages/mk/categories.yml b/core/src/main/resources/languages/mk/categories.yml similarity index 100% rename from src/main/resources/languages/mk/categories.yml rename to core/src/main/resources/languages/mk/categories.yml diff --git a/src/main/resources/languages/mk/messages.yml b/core/src/main/resources/languages/mk/messages.yml similarity index 100% rename from src/main/resources/languages/mk/messages.yml rename to core/src/main/resources/languages/mk/messages.yml diff --git a/src/main/resources/languages/mk/recipes.yml b/core/src/main/resources/languages/mk/recipes.yml similarity index 100% rename from src/main/resources/languages/mk/recipes.yml rename to core/src/main/resources/languages/mk/recipes.yml diff --git a/src/main/resources/languages/mk/researches.yml b/core/src/main/resources/languages/mk/researches.yml similarity index 100% rename from src/main/resources/languages/mk/researches.yml rename to core/src/main/resources/languages/mk/researches.yml diff --git a/src/main/resources/languages/mk/resources.yml b/core/src/main/resources/languages/mk/resources.yml similarity index 100% rename from src/main/resources/languages/mk/resources.yml rename to core/src/main/resources/languages/mk/resources.yml diff --git a/src/main/resources/languages/ms/categories.yml b/core/src/main/resources/languages/ms/categories.yml similarity index 100% rename from src/main/resources/languages/ms/categories.yml rename to core/src/main/resources/languages/ms/categories.yml diff --git a/src/main/resources/languages/ms/messages.yml b/core/src/main/resources/languages/ms/messages.yml similarity index 100% rename from src/main/resources/languages/ms/messages.yml rename to core/src/main/resources/languages/ms/messages.yml diff --git a/src/main/resources/languages/ms/recipes.yml b/core/src/main/resources/languages/ms/recipes.yml similarity index 100% rename from src/main/resources/languages/ms/recipes.yml rename to core/src/main/resources/languages/ms/recipes.yml diff --git a/src/main/resources/languages/ms/researches.yml b/core/src/main/resources/languages/ms/researches.yml similarity index 100% rename from src/main/resources/languages/ms/researches.yml rename to core/src/main/resources/languages/ms/researches.yml diff --git a/src/main/resources/languages/ms/resources.yml b/core/src/main/resources/languages/ms/resources.yml similarity index 100% rename from src/main/resources/languages/ms/resources.yml rename to core/src/main/resources/languages/ms/resources.yml diff --git a/src/main/resources/languages/nl/categories.yml b/core/src/main/resources/languages/nl/categories.yml similarity index 100% rename from src/main/resources/languages/nl/categories.yml rename to core/src/main/resources/languages/nl/categories.yml diff --git a/src/main/resources/languages/nl/messages.yml b/core/src/main/resources/languages/nl/messages.yml similarity index 99% rename from src/main/resources/languages/nl/messages.yml rename to core/src/main/resources/languages/nl/messages.yml index 049d06f7ee..f1b19bcb2e 100644 --- a/src/main/resources/languages/nl/messages.yml +++ b/core/src/main/resources/languages/nl/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Slimefun Handboek' settings: 'Instellingen & Informatie' languages: 'Kies een taal bij voorkeur' - credits: 'Slimefun4 Bijdragers' - wiki: 'Slimefun4 Wiki' - addons: 'Uitbreidingen voor Slimefun4' + credits: 'Slimefun5 Bijdragers' + wiki: 'Slimefun5 Wiki' + addons: 'Uitbreidingen voor Slimefun5' bugs: 'Fouten rapporteren' source: 'Bron Code' versions: 'Geïnstalleerde versies' diff --git a/src/main/resources/languages/nl/recipes.yml b/core/src/main/resources/languages/nl/recipes.yml similarity index 100% rename from src/main/resources/languages/nl/recipes.yml rename to core/src/main/resources/languages/nl/recipes.yml diff --git a/src/main/resources/languages/nl/researches.yml b/core/src/main/resources/languages/nl/researches.yml similarity index 100% rename from src/main/resources/languages/nl/researches.yml rename to core/src/main/resources/languages/nl/researches.yml diff --git a/src/main/resources/languages/nl/resources.yml b/core/src/main/resources/languages/nl/resources.yml similarity index 100% rename from src/main/resources/languages/nl/resources.yml rename to core/src/main/resources/languages/nl/resources.yml diff --git a/src/main/resources/languages/no/categories.yml b/core/src/main/resources/languages/no/categories.yml similarity index 100% rename from src/main/resources/languages/no/categories.yml rename to core/src/main/resources/languages/no/categories.yml diff --git a/src/main/resources/languages/no/messages.yml b/core/src/main/resources/languages/no/messages.yml similarity index 100% rename from src/main/resources/languages/no/messages.yml rename to core/src/main/resources/languages/no/messages.yml diff --git a/src/main/resources/languages/no/recipes.yml b/core/src/main/resources/languages/no/recipes.yml similarity index 100% rename from src/main/resources/languages/no/recipes.yml rename to core/src/main/resources/languages/no/recipes.yml diff --git a/src/main/resources/languages/no/researches.yml b/core/src/main/resources/languages/no/researches.yml similarity index 100% rename from src/main/resources/languages/no/researches.yml rename to core/src/main/resources/languages/no/researches.yml diff --git a/src/main/resources/languages/no/resources.yml b/core/src/main/resources/languages/no/resources.yml similarity index 100% rename from src/main/resources/languages/no/resources.yml rename to core/src/main/resources/languages/no/resources.yml diff --git a/src/main/resources/languages/pl/categories.yml b/core/src/main/resources/languages/pl/categories.yml similarity index 100% rename from src/main/resources/languages/pl/categories.yml rename to core/src/main/resources/languages/pl/categories.yml diff --git a/src/main/resources/languages/pl/messages.yml b/core/src/main/resources/languages/pl/messages.yml similarity index 99% rename from src/main/resources/languages/pl/messages.yml rename to core/src/main/resources/languages/pl/messages.yml index bae152e144..11b0c28250 100644 --- a/src/main/resources/languages/pl/messages.yml +++ b/core/src/main/resources/languages/pl/messages.yml @@ -68,9 +68,9 @@ guide: main: 'Przewodnik Slimefun' settings: 'Ustawienia i informacje' languages: 'Wybierz preferowany język' - credits: 'Autorzy Slimefun4' - wiki: 'Wiki Slimefun4' - addons: 'Dodatki dla Slimefun4' + credits: 'Autorzy Slimefun5' + wiki: 'Wiki Slimefun5' + addons: 'Dodatki dla Slimefun5' bugs: 'Zgłaszanie błędów' source: 'Kod Źródłowy' versions: 'Zainstalowane wersje' diff --git a/src/main/resources/languages/pl/recipes.yml b/core/src/main/resources/languages/pl/recipes.yml similarity index 100% rename from src/main/resources/languages/pl/recipes.yml rename to core/src/main/resources/languages/pl/recipes.yml diff --git a/src/main/resources/languages/pl/researches.yml b/core/src/main/resources/languages/pl/researches.yml similarity index 100% rename from src/main/resources/languages/pl/researches.yml rename to core/src/main/resources/languages/pl/researches.yml diff --git a/src/main/resources/languages/pl/resources.yml b/core/src/main/resources/languages/pl/resources.yml similarity index 100% rename from src/main/resources/languages/pl/resources.yml rename to core/src/main/resources/languages/pl/resources.yml diff --git a/src/main/resources/languages/pt-BR/categories.yml b/core/src/main/resources/languages/pt-BR/categories.yml similarity index 100% rename from src/main/resources/languages/pt-BR/categories.yml rename to core/src/main/resources/languages/pt-BR/categories.yml diff --git a/src/main/resources/languages/pt-BR/messages.yml b/core/src/main/resources/languages/pt-BR/messages.yml similarity index 99% rename from src/main/resources/languages/pt-BR/messages.yml rename to core/src/main/resources/languages/pt-BR/messages.yml index 9b63333863..9084d09cd4 100644 --- a/src/main/resources/languages/pt-BR/messages.yml +++ b/core/src/main/resources/languages/pt-BR/messages.yml @@ -80,9 +80,9 @@ guide: main: 'Guia do Slimefun' settings: 'Config & Info' languages: 'Selecione seu idioma preferido' - credits: 'Contribuidores do Slimefun4' - wiki: 'Wiki do Slimefun4' - addons: 'Add-ons do Slimefun4' + credits: 'Contribuidores do Slimefun5' + wiki: 'Wiki do Slimefun5' + addons: 'Add-ons do Slimefun5' bugs: 'Relatório de Erros' source: 'Código Fonte' versions: 'Versões instaladas' diff --git a/src/main/resources/languages/pt-BR/recipes.yml b/core/src/main/resources/languages/pt-BR/recipes.yml similarity index 100% rename from src/main/resources/languages/pt-BR/recipes.yml rename to core/src/main/resources/languages/pt-BR/recipes.yml diff --git a/src/main/resources/languages/pt-BR/researches.yml b/core/src/main/resources/languages/pt-BR/researches.yml similarity index 100% rename from src/main/resources/languages/pt-BR/researches.yml rename to core/src/main/resources/languages/pt-BR/researches.yml diff --git a/src/main/resources/languages/pt-BR/resources.yml b/core/src/main/resources/languages/pt-BR/resources.yml similarity index 100% rename from src/main/resources/languages/pt-BR/resources.yml rename to core/src/main/resources/languages/pt-BR/resources.yml diff --git a/src/main/resources/languages/pt/categories.yml b/core/src/main/resources/languages/pt/categories.yml similarity index 100% rename from src/main/resources/languages/pt/categories.yml rename to core/src/main/resources/languages/pt/categories.yml diff --git a/src/main/resources/languages/pt/messages.yml b/core/src/main/resources/languages/pt/messages.yml similarity index 99% rename from src/main/resources/languages/pt/messages.yml rename to core/src/main/resources/languages/pt/messages.yml index 23ddfacb86..2a0964ea0c 100644 --- a/src/main/resources/languages/pt/messages.yml +++ b/core/src/main/resources/languages/pt/messages.yml @@ -96,9 +96,9 @@ guide: main: 'Guia Slimefun' settings: 'Configurações e informação' languages: 'Selecione a sua linguagem' - credits: 'Contribuidores de Slimefun4' - wiki: 'Wiki de Slimefun4' - addons: 'Addons para Slimefun4' + credits: 'Contribuidores de Slimefun5' + wiki: 'Wiki de Slimefun5' + addons: 'Addons para Slimefun5' bugs: 'Bugs' source: 'Código fonte' versions: 'Versões instaladas' diff --git a/src/main/resources/languages/pt/recipes.yml b/core/src/main/resources/languages/pt/recipes.yml similarity index 100% rename from src/main/resources/languages/pt/recipes.yml rename to core/src/main/resources/languages/pt/recipes.yml diff --git a/src/main/resources/languages/pt/researches.yml b/core/src/main/resources/languages/pt/researches.yml similarity index 100% rename from src/main/resources/languages/pt/researches.yml rename to core/src/main/resources/languages/pt/researches.yml diff --git a/src/main/resources/languages/pt/resources.yml b/core/src/main/resources/languages/pt/resources.yml similarity index 100% rename from src/main/resources/languages/pt/resources.yml rename to core/src/main/resources/languages/pt/resources.yml diff --git a/src/main/resources/languages/ro/categories.yml b/core/src/main/resources/languages/ro/categories.yml similarity index 100% rename from src/main/resources/languages/ro/categories.yml rename to core/src/main/resources/languages/ro/categories.yml diff --git a/src/main/resources/languages/ro/messages.yml b/core/src/main/resources/languages/ro/messages.yml similarity index 96% rename from src/main/resources/languages/ro/messages.yml rename to core/src/main/resources/languages/ro/messages.yml index 2990fecf43..451dcc38f3 100644 --- a/src/main/resources/languages/ro/messages.yml +++ b/core/src/main/resources/languages/ro/messages.yml @@ -31,9 +31,9 @@ guide: main: 'Ghid Slimefun' settings: 'Setări și informații' languages: 'Selectați limba preferată' - credits: 'Contribuitori Slimefun4' - wiki: 'Wiki Slimefun4' - addons: 'Addons pentru Slimefun4' + credits: 'Contribuitori Slimefun5' + wiki: 'Wiki Slimefun5' + addons: 'Addons pentru Slimefun5' bugs: 'Raportare Buguri' source: 'Cod sursă' versions: 'Versiuni instalate' diff --git a/src/main/resources/languages/ro/recipes.yml b/core/src/main/resources/languages/ro/recipes.yml similarity index 100% rename from src/main/resources/languages/ro/recipes.yml rename to core/src/main/resources/languages/ro/recipes.yml diff --git a/src/main/resources/languages/ro/researches.yml b/core/src/main/resources/languages/ro/researches.yml similarity index 100% rename from src/main/resources/languages/ro/researches.yml rename to core/src/main/resources/languages/ro/researches.yml diff --git a/src/main/resources/languages/ro/resources.yml b/core/src/main/resources/languages/ro/resources.yml similarity index 100% rename from src/main/resources/languages/ro/resources.yml rename to core/src/main/resources/languages/ro/resources.yml diff --git a/src/main/resources/languages/ru/categories.yml b/core/src/main/resources/languages/ru/categories.yml similarity index 100% rename from src/main/resources/languages/ru/categories.yml rename to core/src/main/resources/languages/ru/categories.yml diff --git a/src/main/resources/languages/ru/messages.yml b/core/src/main/resources/languages/ru/messages.yml similarity index 99% rename from src/main/resources/languages/ru/messages.yml rename to core/src/main/resources/languages/ru/messages.yml index 61b0dbfb5b..3cff4ca14a 100644 --- a/src/main/resources/languages/ru/messages.yml +++ b/core/src/main/resources/languages/ru/messages.yml @@ -83,9 +83,9 @@ guide: main: 'Руководство Slimefun' settings: 'Информация и настройки' languages: 'Выберите Ваш предпочитаемый язык' - credits: 'Авторы Slimefun4' - wiki: 'Slimefun4 Вики' - addons: 'Дополнения к Slimefun4' + credits: 'Авторы Slimefun5' + wiki: 'Slimefun5 Вики' + addons: 'Дополнения к Slimefun5' bugs: 'Отчёты об ошибках' source: 'Исходный код' versions: 'Установленные версии' diff --git a/src/main/resources/languages/ru/recipes.yml b/core/src/main/resources/languages/ru/recipes.yml similarity index 100% rename from src/main/resources/languages/ru/recipes.yml rename to core/src/main/resources/languages/ru/recipes.yml diff --git a/src/main/resources/languages/ru/researches.yml b/core/src/main/resources/languages/ru/researches.yml similarity index 100% rename from src/main/resources/languages/ru/researches.yml rename to core/src/main/resources/languages/ru/researches.yml diff --git a/src/main/resources/languages/ru/resources.yml b/core/src/main/resources/languages/ru/resources.yml similarity index 100% rename from src/main/resources/languages/ru/resources.yml rename to core/src/main/resources/languages/ru/resources.yml diff --git a/src/main/resources/languages/si/categories.yml b/core/src/main/resources/languages/si/categories.yml similarity index 100% rename from src/main/resources/languages/si/categories.yml rename to core/src/main/resources/languages/si/categories.yml diff --git a/src/main/resources/languages/si/messages.yml b/core/src/main/resources/languages/si/messages.yml similarity index 100% rename from src/main/resources/languages/si/messages.yml rename to core/src/main/resources/languages/si/messages.yml diff --git a/src/main/resources/languages/si/recipes.yml b/core/src/main/resources/languages/si/recipes.yml similarity index 100% rename from src/main/resources/languages/si/recipes.yml rename to core/src/main/resources/languages/si/recipes.yml diff --git a/src/main/resources/languages/si/researches.yml b/core/src/main/resources/languages/si/researches.yml similarity index 100% rename from src/main/resources/languages/si/researches.yml rename to core/src/main/resources/languages/si/researches.yml diff --git a/src/main/resources/languages/si/resources.yml b/core/src/main/resources/languages/si/resources.yml similarity index 100% rename from src/main/resources/languages/si/resources.yml rename to core/src/main/resources/languages/si/resources.yml diff --git a/src/main/resources/languages/sk/categories.yml b/core/src/main/resources/languages/sk/categories.yml similarity index 100% rename from src/main/resources/languages/sk/categories.yml rename to core/src/main/resources/languages/sk/categories.yml diff --git a/src/main/resources/languages/sk/messages.yml b/core/src/main/resources/languages/sk/messages.yml similarity index 99% rename from src/main/resources/languages/sk/messages.yml rename to core/src/main/resources/languages/sk/messages.yml index 17e1f58236..bd06d5f18c 100644 --- a/src/main/resources/languages/sk/messages.yml +++ b/core/src/main/resources/languages/sk/messages.yml @@ -59,8 +59,8 @@ guide: main: 'Slimefun príručka' settings: 'Nastavenia a informácie' languages: 'Nastav si preferovaný jazyk' - credits: 'Slimefun4 prispievatelia' - addons: 'Doplnky pre Slimefun4' + credits: 'Slimefun5 prispievatelia' + addons: 'Doplnky pre Slimefun5' bugs: 'Report bugov' source: 'Zdrojový kód' versions: 'Nainštalované verzie' diff --git a/src/main/resources/languages/sk/recipes.yml b/core/src/main/resources/languages/sk/recipes.yml similarity index 100% rename from src/main/resources/languages/sk/recipes.yml rename to core/src/main/resources/languages/sk/recipes.yml diff --git a/src/main/resources/languages/sk/researches.yml b/core/src/main/resources/languages/sk/researches.yml similarity index 100% rename from src/main/resources/languages/sk/researches.yml rename to core/src/main/resources/languages/sk/researches.yml diff --git a/src/main/resources/languages/sk/resources.yml b/core/src/main/resources/languages/sk/resources.yml similarity index 100% rename from src/main/resources/languages/sk/resources.yml rename to core/src/main/resources/languages/sk/resources.yml diff --git a/src/main/resources/languages/sv/categories.yml b/core/src/main/resources/languages/sv/categories.yml similarity index 100% rename from src/main/resources/languages/sv/categories.yml rename to core/src/main/resources/languages/sv/categories.yml diff --git a/src/main/resources/languages/sv/messages.yml b/core/src/main/resources/languages/sv/messages.yml similarity index 99% rename from src/main/resources/languages/sv/messages.yml rename to core/src/main/resources/languages/sv/messages.yml index aa141bee30..bab9c19db4 100644 --- a/src/main/resources/languages/sv/messages.yml +++ b/core/src/main/resources/languages/sv/messages.yml @@ -62,9 +62,9 @@ guide: main: 'Slimefun-handbok' settings: 'Inställningar & Info' languages: 'Välj ditt föredragna språk' - credits: 'Slimefun4-medhjälpare' - wiki: 'Slimefun4 Wiki' - addons: 'Tilläg till Slimefun4' + credits: 'Slimefun5-medhjälpare' + wiki: 'Slimefun5 Wiki' + addons: 'Tilläg till Slimefun5' bugs: 'Bugg Rapporter' source: 'Källkoden' versions: 'Installerade versioner' diff --git a/src/main/resources/languages/sv/recipes.yml b/core/src/main/resources/languages/sv/recipes.yml similarity index 100% rename from src/main/resources/languages/sv/recipes.yml rename to core/src/main/resources/languages/sv/recipes.yml diff --git a/src/main/resources/languages/sv/researches.yml b/core/src/main/resources/languages/sv/researches.yml similarity index 100% rename from src/main/resources/languages/sv/researches.yml rename to core/src/main/resources/languages/sv/researches.yml diff --git a/src/main/resources/languages/sv/resources.yml b/core/src/main/resources/languages/sv/resources.yml similarity index 100% rename from src/main/resources/languages/sv/resources.yml rename to core/src/main/resources/languages/sv/resources.yml diff --git a/src/main/resources/languages/th/categories.yml b/core/src/main/resources/languages/th/categories.yml similarity index 100% rename from src/main/resources/languages/th/categories.yml rename to core/src/main/resources/languages/th/categories.yml diff --git a/src/main/resources/languages/th/messages.yml b/core/src/main/resources/languages/th/messages.yml similarity index 99% rename from src/main/resources/languages/th/messages.yml rename to core/src/main/resources/languages/th/messages.yml index b2a7cbac04..3fec2ac71d 100644 --- a/src/main/resources/languages/th/messages.yml +++ b/core/src/main/resources/languages/th/messages.yml @@ -54,8 +54,8 @@ guide: main: 'คู่มือ Slimefun' settings: 'ตั้งค่า & แสดงค่าต่างๆ' languages: 'เลือกภาษาที่คุณต้องการ' - credits: 'ผู้มีส่วนร่วมใน Slimefun4' - addons: 'Addons สำหรับ Slimefun4' + credits: 'ผู้มีส่วนร่วมใน Slimefun5' + addons: 'Addons สำหรับ Slimefun5' bugs: 'รายงานบัค' credits: commit: 'ผูกมัด' diff --git a/src/main/resources/languages/th/recipes.yml b/core/src/main/resources/languages/th/recipes.yml similarity index 100% rename from src/main/resources/languages/th/recipes.yml rename to core/src/main/resources/languages/th/recipes.yml diff --git a/src/main/resources/languages/th/researches.yml b/core/src/main/resources/languages/th/researches.yml similarity index 100% rename from src/main/resources/languages/th/researches.yml rename to core/src/main/resources/languages/th/researches.yml diff --git a/src/main/resources/languages/th/resources.yml b/core/src/main/resources/languages/th/resources.yml similarity index 100% rename from src/main/resources/languages/th/resources.yml rename to core/src/main/resources/languages/th/resources.yml diff --git a/src/main/resources/languages/tl/categories.yml b/core/src/main/resources/languages/tl/categories.yml similarity index 100% rename from src/main/resources/languages/tl/categories.yml rename to core/src/main/resources/languages/tl/categories.yml diff --git a/src/main/resources/languages/tl/messages.yml b/core/src/main/resources/languages/tl/messages.yml similarity index 99% rename from src/main/resources/languages/tl/messages.yml rename to core/src/main/resources/languages/tl/messages.yml index 08d1463bbb..bdde78a0a2 100644 --- a/src/main/resources/languages/tl/messages.yml +++ b/core/src/main/resources/languages/tl/messages.yml @@ -88,9 +88,9 @@ guide: main: 'Gabay para sa Slimefun' settings: 'Mga Settings & Impormasyon' languages: 'Pumili ng gustong wika.' - credits: 'Ang mga tumulong sa Slimefun4' - wiki: 'Ang Slimefun4 Wiki' - addons: 'Ang mga Addons para sa Slimefun4' + credits: 'Ang mga tumulong sa Slimefun5' + wiki: 'Ang Slimefun5 Wiki' + addons: 'Ang mga Addons para sa Slimefun5' bugs: 'Mga Bug Reports' source: 'Ang Source Code' versions: 'Mga na-install na versions' diff --git a/src/main/resources/languages/tl/recipes.yml b/core/src/main/resources/languages/tl/recipes.yml similarity index 100% rename from src/main/resources/languages/tl/recipes.yml rename to core/src/main/resources/languages/tl/recipes.yml diff --git a/src/main/resources/languages/tl/researches.yml b/core/src/main/resources/languages/tl/researches.yml similarity index 100% rename from src/main/resources/languages/tl/researches.yml rename to core/src/main/resources/languages/tl/researches.yml diff --git a/src/main/resources/languages/tl/resources.yml b/core/src/main/resources/languages/tl/resources.yml similarity index 100% rename from src/main/resources/languages/tl/resources.yml rename to core/src/main/resources/languages/tl/resources.yml diff --git a/src/main/resources/languages/tr/categories.yml b/core/src/main/resources/languages/tr/categories.yml similarity index 100% rename from src/main/resources/languages/tr/categories.yml rename to core/src/main/resources/languages/tr/categories.yml diff --git a/src/main/resources/languages/tr/messages.yml b/core/src/main/resources/languages/tr/messages.yml similarity index 99% rename from src/main/resources/languages/tr/messages.yml rename to core/src/main/resources/languages/tr/messages.yml index eb3a9f2276..90813b03ca 100644 --- a/src/main/resources/languages/tr/messages.yml +++ b/core/src/main/resources/languages/tr/messages.yml @@ -100,9 +100,9 @@ guide: main: 'Slimefun Rehberi' settings: 'Ayarlar & Bilgi' languages: 'Tercih ettiğiniz dili seçin' - credits: 'Slimefun4 Katkıda Bulunanlar' - wiki: 'Slimefun4 Wiki' - addons: 'Slimefun4 için Eklentiler' + credits: 'Slimefun5 Katkıda Bulunanlar' + wiki: 'Slimefun5 Wiki' + addons: 'Slimefun5 için Eklentiler' bugs: 'Hata Raporları' source: 'Kaynak Kodu' versions: 'Yüklü sürümler' diff --git a/src/main/resources/languages/tr/recipes.yml b/core/src/main/resources/languages/tr/recipes.yml similarity index 100% rename from src/main/resources/languages/tr/recipes.yml rename to core/src/main/resources/languages/tr/recipes.yml diff --git a/src/main/resources/languages/tr/researches.yml b/core/src/main/resources/languages/tr/researches.yml similarity index 100% rename from src/main/resources/languages/tr/researches.yml rename to core/src/main/resources/languages/tr/researches.yml diff --git a/src/main/resources/languages/tr/resources.yml b/core/src/main/resources/languages/tr/resources.yml similarity index 100% rename from src/main/resources/languages/tr/resources.yml rename to core/src/main/resources/languages/tr/resources.yml diff --git a/src/main/resources/languages/translators.json b/core/src/main/resources/languages/translators.json similarity index 100% rename from src/main/resources/languages/translators.json rename to core/src/main/resources/languages/translators.json diff --git a/src/main/resources/languages/uk/categories.yml b/core/src/main/resources/languages/uk/categories.yml similarity index 100% rename from src/main/resources/languages/uk/categories.yml rename to core/src/main/resources/languages/uk/categories.yml diff --git a/src/main/resources/languages/uk/messages.yml b/core/src/main/resources/languages/uk/messages.yml similarity index 99% rename from src/main/resources/languages/uk/messages.yml rename to core/src/main/resources/languages/uk/messages.yml index 7546559141..48ce8eda4c 100644 --- a/src/main/resources/languages/uk/messages.yml +++ b/core/src/main/resources/languages/uk/messages.yml @@ -60,9 +60,9 @@ guide: main: 'Посібник Slimefun' settings: 'Налаштування та інформація' languages: 'Виберіть бажану мову' - credits: 'Автори Slimefun4' - wiki: 'Slimefun4 Вікі' - addons: 'Доповнення до Slimefun4' + credits: 'Автори Slimefun5' + wiki: 'Slimefun5 Вікі' + addons: 'Доповнення до Slimefun5' bugs: 'Звіти про помилки' source: 'Вихідний код' credits: diff --git a/src/main/resources/languages/uk/recipes.yml b/core/src/main/resources/languages/uk/recipes.yml similarity index 100% rename from src/main/resources/languages/uk/recipes.yml rename to core/src/main/resources/languages/uk/recipes.yml diff --git a/src/main/resources/languages/uk/researches.yml b/core/src/main/resources/languages/uk/researches.yml similarity index 100% rename from src/main/resources/languages/uk/researches.yml rename to core/src/main/resources/languages/uk/researches.yml diff --git a/src/main/resources/languages/uk/resources.yml b/core/src/main/resources/languages/uk/resources.yml similarity index 100% rename from src/main/resources/languages/uk/resources.yml rename to core/src/main/resources/languages/uk/resources.yml diff --git a/src/main/resources/languages/vi/categories.yml b/core/src/main/resources/languages/vi/categories.yml similarity index 100% rename from src/main/resources/languages/vi/categories.yml rename to core/src/main/resources/languages/vi/categories.yml diff --git a/src/main/resources/languages/vi/messages.yml b/core/src/main/resources/languages/vi/messages.yml similarity index 99% rename from src/main/resources/languages/vi/messages.yml rename to core/src/main/resources/languages/vi/messages.yml index 7fec92891b..e05d8cf078 100644 --- a/src/main/resources/languages/vi/messages.yml +++ b/core/src/main/resources/languages/vi/messages.yml @@ -82,9 +82,9 @@ guide: main: 'Hướng dẫn sử dụng Slimefun' settings: 'Cài đặt và thông tin' languages: 'Chọn ngôn ngữ ưa thích của bạn' - credits: 'Người đóng góp cho Slimefun4' - wiki: 'Tài liệu Slimefun4' - addons: 'Các bổ sung cho Slimefun4' + credits: 'Người đóng góp cho Slimefun5' + wiki: 'Tài liệu Slimefun5' + addons: 'Các bổ sung cho Slimefun5' bugs: 'Báo cáo lỗi' source: 'Mã nguồn' versions: 'Phiên bản đã cài' diff --git a/src/main/resources/languages/vi/recipes.yml b/core/src/main/resources/languages/vi/recipes.yml similarity index 100% rename from src/main/resources/languages/vi/recipes.yml rename to core/src/main/resources/languages/vi/recipes.yml diff --git a/src/main/resources/languages/vi/researches.yml b/core/src/main/resources/languages/vi/researches.yml similarity index 100% rename from src/main/resources/languages/vi/researches.yml rename to core/src/main/resources/languages/vi/researches.yml diff --git a/src/main/resources/languages/vi/resources.yml b/core/src/main/resources/languages/vi/resources.yml similarity index 100% rename from src/main/resources/languages/vi/resources.yml rename to core/src/main/resources/languages/vi/resources.yml diff --git a/src/main/resources/languages/zh-CN/categories.yml b/core/src/main/resources/languages/zh-CN/categories.yml similarity index 100% rename from src/main/resources/languages/zh-CN/categories.yml rename to core/src/main/resources/languages/zh-CN/categories.yml diff --git a/src/main/resources/languages/zh-CN/messages.yml b/core/src/main/resources/languages/zh-CN/messages.yml similarity index 99% rename from src/main/resources/languages/zh-CN/messages.yml rename to core/src/main/resources/languages/zh-CN/messages.yml index e79b887552..a4e6af0b01 100644 --- a/src/main/resources/languages/zh-CN/messages.yml +++ b/core/src/main/resources/languages/zh-CN/messages.yml @@ -123,9 +123,9 @@ guide: main: 'Slimefun 指南' settings: '设置 & 详情' languages: '选择你想要更改的语言' - credits: 'Slimefun4 贡献者' - wiki: 'Slimefun4 维基' - addons: 'Slimefun4 附属插件' + credits: 'Slimefun5 贡献者' + wiki: 'Slimefun5 维基' + addons: 'Slimefun5 附属插件' bugs: '问题反馈' source: '源代码' versions: '安装的版本' diff --git a/src/main/resources/languages/zh-CN/recipes.yml b/core/src/main/resources/languages/zh-CN/recipes.yml similarity index 100% rename from src/main/resources/languages/zh-CN/recipes.yml rename to core/src/main/resources/languages/zh-CN/recipes.yml diff --git a/src/main/resources/languages/zh-CN/researches.yml b/core/src/main/resources/languages/zh-CN/researches.yml similarity index 100% rename from src/main/resources/languages/zh-CN/researches.yml rename to core/src/main/resources/languages/zh-CN/researches.yml diff --git a/src/main/resources/languages/zh-CN/resources.yml b/core/src/main/resources/languages/zh-CN/resources.yml similarity index 100% rename from src/main/resources/languages/zh-CN/resources.yml rename to core/src/main/resources/languages/zh-CN/resources.yml diff --git a/src/main/resources/languages/zh-TW/categories.yml b/core/src/main/resources/languages/zh-TW/categories.yml similarity index 100% rename from src/main/resources/languages/zh-TW/categories.yml rename to core/src/main/resources/languages/zh-TW/categories.yml diff --git a/src/main/resources/languages/zh-TW/messages.yml b/core/src/main/resources/languages/zh-TW/messages.yml similarity index 99% rename from src/main/resources/languages/zh-TW/messages.yml rename to core/src/main/resources/languages/zh-TW/messages.yml index 548f26bce6..622ff36189 100644 --- a/src/main/resources/languages/zh-TW/messages.yml +++ b/core/src/main/resources/languages/zh-TW/messages.yml @@ -103,9 +103,9 @@ guide: main: 'Slimefun 指南' settings: '設置及資訊' languages: '請選擇您偏好的語言' - credits: 'Slimefun4 貢獻者' - wiki: 'Slimefun4 Wiki' - addons: 'Slimefun4的附加插件' + credits: 'Slimefun5 貢獻者' + wiki: 'Slimefun5 Wiki' + addons: 'Slimefun5的附加插件' bugs: '錯誤報告' source: '原始碼' versions: '安裝版本' diff --git a/src/main/resources/languages/zh-TW/recipes.yml b/core/src/main/resources/languages/zh-TW/recipes.yml similarity index 100% rename from src/main/resources/languages/zh-TW/recipes.yml rename to core/src/main/resources/languages/zh-TW/recipes.yml diff --git a/src/main/resources/languages/zh-TW/researches.yml b/core/src/main/resources/languages/zh-TW/researches.yml similarity index 100% rename from src/main/resources/languages/zh-TW/researches.yml rename to core/src/main/resources/languages/zh-TW/researches.yml diff --git a/src/main/resources/languages/zh-TW/resources.yml b/core/src/main/resources/languages/zh-TW/resources.yml similarity index 100% rename from src/main/resources/languages/zh-TW/resources.yml rename to core/src/main/resources/languages/zh-TW/resources.yml diff --git a/src/main/resources/languages/zh/categories.yml b/core/src/main/resources/languages/zh/categories.yml similarity index 100% rename from src/main/resources/languages/zh/categories.yml rename to core/src/main/resources/languages/zh/categories.yml diff --git a/src/main/resources/languages/zh/messages.yml b/core/src/main/resources/languages/zh/messages.yml similarity index 100% rename from src/main/resources/languages/zh/messages.yml rename to core/src/main/resources/languages/zh/messages.yml diff --git a/src/main/resources/languages/zh/recipes.yml b/core/src/main/resources/languages/zh/recipes.yml similarity index 100% rename from src/main/resources/languages/zh/recipes.yml rename to core/src/main/resources/languages/zh/recipes.yml diff --git a/src/main/resources/languages/zh/researches.yml b/core/src/main/resources/languages/zh/researches.yml similarity index 100% rename from src/main/resources/languages/zh/researches.yml rename to core/src/main/resources/languages/zh/researches.yml diff --git a/src/main/resources/languages/zh/resources.yml b/core/src/main/resources/languages/zh/resources.yml similarity index 100% rename from src/main/resources/languages/zh/resources.yml rename to core/src/main/resources/languages/zh/resources.yml diff --git a/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml similarity index 84% rename from src/main/resources/plugin.yml rename to core/src/main/resources/plugin.yml index 5e5a3adbe5..c2b1fc83cb 100644 --- a/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -1,15 +1,18 @@ # Name and version name: Slimefun -version: ${project.version} +version: ${version} # Project metadata -author: The Slimefun 4 Community +author: The Slimefun Community website: https://github.com/Slimefun description: Slimefun basically turns your entire Server into a FTB modpack without installing a single mod # Technical settings -main: io.github.thebusybiscuit.slimefun4.implementation.Slimefun -api-version: '1.16' +main: io.github.thebusybiscuit.slimefun5.implementation.Slimefun +# Java-8 universal jar: declare the lowest flattening-era API (1.13) so the plugin loads on every +# server from 1.13 up to the latest (servers reject an api-version newer than themselves, which is +# why 1.16 was rejected on 1.13.x). Pre-1.13 servers (1.8-1.12) ignore this field entirely. +api-version: '1.13' # (Soft) dependencies of Slimefun, we hook into these plugins. softdepend: diff --git a/src/main/resources/tags/auto_crafter_supported_storage_blocks.json b/core/src/main/resources/tags/auto_crafter_supported_storage_blocks.json similarity index 100% rename from src/main/resources/tags/auto_crafter_supported_storage_blocks.json rename to core/src/main/resources/tags/auto_crafter_supported_storage_blocks.json diff --git a/src/main/resources/tags/block_placer_ignored_materials.json b/core/src/main/resources/tags/block_placer_ignored_materials.json similarity index 100% rename from src/main/resources/tags/block_placer_ignored_materials.json rename to core/src/main/resources/tags/block_placer_ignored_materials.json diff --git a/src/main/resources/tags/cargo_supported_storage_blocks.json b/core/src/main/resources/tags/cargo_supported_storage_blocks.json similarity index 100% rename from src/main/resources/tags/cargo_supported_storage_blocks.json rename to core/src/main/resources/tags/cargo_supported_storage_blocks.json diff --git a/src/main/resources/tags/caveman_talisman_triggers.json b/core/src/main/resources/tags/caveman_talisman_triggers.json similarity index 100% rename from src/main/resources/tags/caveman_talisman_triggers.json rename to core/src/main/resources/tags/caveman_talisman_triggers.json diff --git a/src/main/resources/tags/climbing_pick_strong_surfaces.json b/core/src/main/resources/tags/climbing_pick_strong_surfaces.json similarity index 100% rename from src/main/resources/tags/climbing_pick_strong_surfaces.json rename to core/src/main/resources/tags/climbing_pick_strong_surfaces.json diff --git a/src/main/resources/tags/climbing_pick_surfaces.json b/core/src/main/resources/tags/climbing_pick_surfaces.json similarity index 100% rename from src/main/resources/tags/climbing_pick_surfaces.json rename to core/src/main/resources/tags/climbing_pick_surfaces.json diff --git a/src/main/resources/tags/climbing_pick_weak_surfaces.json b/core/src/main/resources/tags/climbing_pick_weak_surfaces.json similarity index 100% rename from src/main/resources/tags/climbing_pick_weak_surfaces.json rename to core/src/main/resources/tags/climbing_pick_weak_surfaces.json diff --git a/src/main/resources/tags/command_blocks.json b/core/src/main/resources/tags/command_blocks.json similarity index 100% rename from src/main/resources/tags/command_blocks.json rename to core/src/main/resources/tags/command_blocks.json diff --git a/src/main/resources/tags/concrete_powders.json b/core/src/main/resources/tags/concrete_powders.json similarity index 100% rename from src/main/resources/tags/concrete_powders.json rename to core/src/main/resources/tags/concrete_powders.json diff --git a/src/main/resources/tags/crop_growth_accelerator_blocks.json b/core/src/main/resources/tags/crop_growth_accelerator_blocks.json similarity index 100% rename from src/main/resources/tags/crop_growth_accelerator_blocks.json rename to core/src/main/resources/tags/crop_growth_accelerator_blocks.json diff --git a/src/main/resources/tags/deepslate_ores.json b/core/src/main/resources/tags/deepslate_ores.json similarity index 100% rename from src/main/resources/tags/deepslate_ores.json rename to core/src/main/resources/tags/deepslate_ores.json diff --git a/src/main/resources/tags/dirt_variants.json b/core/src/main/resources/tags/dirt_variants.json similarity index 100% rename from src/main/resources/tags/dirt_variants.json rename to core/src/main/resources/tags/dirt_variants.json diff --git a/src/main/resources/tags/enhanced_furnace_luck_materials.json b/core/src/main/resources/tags/enhanced_furnace_luck_materials.json similarity index 100% rename from src/main/resources/tags/enhanced_furnace_luck_materials.json rename to core/src/main/resources/tags/enhanced_furnace_luck_materials.json diff --git a/src/main/resources/tags/explosive_shovel_blocks.json b/core/src/main/resources/tags/explosive_shovel_blocks.json similarity index 100% rename from src/main/resources/tags/explosive_shovel_blocks.json rename to core/src/main/resources/tags/explosive_shovel_blocks.json diff --git a/src/main/resources/tags/farmer_talisman_triggers.json b/core/src/main/resources/tags/farmer_talisman_triggers.json similarity index 100% rename from src/main/resources/tags/farmer_talisman_triggers.json rename to core/src/main/resources/tags/farmer_talisman_triggers.json diff --git a/src/main/resources/tags/fluid_sensitive_materials.json b/core/src/main/resources/tags/fluid_sensitive_materials.json similarity index 100% rename from src/main/resources/tags/fluid_sensitive_materials.json rename to core/src/main/resources/tags/fluid_sensitive_materials.json diff --git a/src/main/resources/tags/fungus_soil.json b/core/src/main/resources/tags/fungus_soil.json similarity index 100% rename from src/main/resources/tags/fungus_soil.json rename to core/src/main/resources/tags/fungus_soil.json diff --git a/src/main/resources/tags/glass.json b/core/src/main/resources/tags/glass.json similarity index 100% rename from src/main/resources/tags/glass.json rename to core/src/main/resources/tags/glass.json diff --git a/src/main/resources/tags/glass_blocks.json b/core/src/main/resources/tags/glass_blocks.json similarity index 100% rename from src/main/resources/tags/glass_blocks.json rename to core/src/main/resources/tags/glass_blocks.json diff --git a/src/main/resources/tags/glass_panes.json b/core/src/main/resources/tags/glass_panes.json similarity index 100% rename from src/main/resources/tags/glass_panes.json rename to core/src/main/resources/tags/glass_panes.json diff --git a/src/main/resources/tags/gravity_affected_blocks.json b/core/src/main/resources/tags/gravity_affected_blocks.json similarity index 100% rename from src/main/resources/tags/gravity_affected_blocks.json rename to core/src/main/resources/tags/gravity_affected_blocks.json diff --git a/src/main/resources/tags/ice_variants.json b/core/src/main/resources/tags/ice_variants.json similarity index 100% rename from src/main/resources/tags/ice_variants.json rename to core/src/main/resources/tags/ice_variants.json diff --git a/src/main/resources/tags/industrial_miner_ores.json b/core/src/main/resources/tags/industrial_miner_ores.json similarity index 100% rename from src/main/resources/tags/industrial_miner_ores.json rename to core/src/main/resources/tags/industrial_miner_ores.json diff --git a/src/main/resources/tags/leather_armor.json b/core/src/main/resources/tags/leather_armor.json similarity index 100% rename from src/main/resources/tags/leather_armor.json rename to core/src/main/resources/tags/leather_armor.json diff --git a/src/main/resources/tags/mangrove_base_blocks.json b/core/src/main/resources/tags/mangrove_base_blocks.json similarity index 100% rename from src/main/resources/tags/mangrove_base_blocks.json rename to core/src/main/resources/tags/mangrove_base_blocks.json diff --git a/src/main/resources/tags/miner_talisman_triggers.json b/core/src/main/resources/tags/miner_talisman_triggers.json similarity index 100% rename from src/main/resources/tags/miner_talisman_triggers.json rename to core/src/main/resources/tags/miner_talisman_triggers.json diff --git a/src/main/resources/tags/mushrooms.json b/core/src/main/resources/tags/mushrooms.json similarity index 100% rename from src/main/resources/tags/mushrooms.json rename to core/src/main/resources/tags/mushrooms.json diff --git a/src/main/resources/tags/nether_ores.json b/core/src/main/resources/tags/nether_ores.json similarity index 100% rename from src/main/resources/tags/nether_ores.json rename to core/src/main/resources/tags/nether_ores.json diff --git a/src/main/resources/tags/ores.json b/core/src/main/resources/tags/ores.json similarity index 100% rename from src/main/resources/tags/ores.json rename to core/src/main/resources/tags/ores.json diff --git a/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json b/core/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json similarity index 100% rename from src/main/resources/tags/pickaxe_of_the_seeker_blocks.json rename to core/src/main/resources/tags/pickaxe_of_the_seeker_blocks.json diff --git a/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json b/core/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json similarity index 100% rename from src/main/resources/tags/pickaxe_of_vein_mining_blocks.json rename to core/src/main/resources/tags/pickaxe_of_vein_mining_blocks.json diff --git a/src/main/resources/tags/pressure_plates.json b/core/src/main/resources/tags/pressure_plates.json similarity index 100% rename from src/main/resources/tags/pressure_plates.json rename to core/src/main/resources/tags/pressure_plates.json diff --git a/src/main/resources/tags/raw_metals.json b/core/src/main/resources/tags/raw_metals.json similarity index 100% rename from src/main/resources/tags/raw_metals.json rename to core/src/main/resources/tags/raw_metals.json diff --git a/src/main/resources/tags/sensitive_materials.json b/core/src/main/resources/tags/sensitive_materials.json similarity index 100% rename from src/main/resources/tags/sensitive_materials.json rename to core/src/main/resources/tags/sensitive_materials.json diff --git a/src/main/resources/tags/shulker_boxes.json b/core/src/main/resources/tags/shulker_boxes.json similarity index 100% rename from src/main/resources/tags/shulker_boxes.json rename to core/src/main/resources/tags/shulker_boxes.json diff --git a/src/main/resources/tags/smelters_pickaxe_blocks.json b/core/src/main/resources/tags/smelters_pickaxe_blocks.json similarity index 100% rename from src/main/resources/tags/smelters_pickaxe_blocks.json rename to core/src/main/resources/tags/smelters_pickaxe_blocks.json diff --git a/src/main/resources/tags/spawn_eggs.json b/core/src/main/resources/tags/spawn_eggs.json similarity index 100% rename from src/main/resources/tags/spawn_eggs.json rename to core/src/main/resources/tags/spawn_eggs.json diff --git a/src/main/resources/tags/stone_ores.json b/core/src/main/resources/tags/stone_ores.json similarity index 100% rename from src/main/resources/tags/stone_ores.json rename to core/src/main/resources/tags/stone_ores.json diff --git a/src/main/resources/tags/stone_variants.json b/core/src/main/resources/tags/stone_variants.json similarity index 100% rename from src/main/resources/tags/stone_variants.json rename to core/src/main/resources/tags/stone_variants.json diff --git a/src/main/resources/tags/tall_flowers.json b/core/src/main/resources/tags/tall_flowers.json similarity index 100% rename from src/main/resources/tags/tall_flowers.json rename to core/src/main/resources/tags/tall_flowers.json diff --git a/src/main/resources/tags/terracotta.json b/core/src/main/resources/tags/terracotta.json similarity index 100% rename from src/main/resources/tags/terracotta.json rename to core/src/main/resources/tags/terracotta.json diff --git a/src/main/resources/tags/tile_entities.json b/core/src/main/resources/tags/tile_entities.json similarity index 100% rename from src/main/resources/tags/tile_entities.json rename to core/src/main/resources/tags/tile_entities.json diff --git a/src/main/resources/tags/torches.json b/core/src/main/resources/tags/torches.json similarity index 100% rename from src/main/resources/tags/torches.json rename to core/src/main/resources/tags/torches.json diff --git a/src/main/resources/tags/unbreakable_materials.json b/core/src/main/resources/tags/unbreakable_materials.json similarity index 100% rename from src/main/resources/tags/unbreakable_materials.json rename to core/src/main/resources/tags/unbreakable_materials.json diff --git a/src/main/resources/tags/wool_carpets.json b/core/src/main/resources/tags/wool_carpets.json similarity index 100% rename from src/main/resources/tags/wool_carpets.json rename to core/src/main/resources/tags/wool_carpets.json diff --git a/src/main/resources/wiki.json b/core/src/main/resources/wiki.json similarity index 100% rename from src/main/resources/wiki.json rename to core/src/main/resources/wiki.json diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/TestPluginClass.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/TestPluginClass.java similarity index 92% rename from src/test/java/io/github/thebusybiscuit/slimefun4/TestPluginClass.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/TestPluginClass.java index 1d22dd98ed..e5065fa778 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/TestPluginClass.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/TestPluginClass.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4; +package io.github.thebusybiscuit.slimefun5; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; @@ -6,10 +6,10 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestPluginClass { @@ -81,3 +81,4 @@ void testListenersNotNull() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunBlockBreakEvent.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunBlockBreakEvent.java similarity index 81% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunBlockBreakEvent.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunBlockBreakEvent.java index 9eb9225213..8ac9bcb182 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunBlockBreakEvent.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunBlockBreakEvent.java @@ -1,13 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.api.events; - -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.block.BlockMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +package io.github.thebusybiscuit.slimefun5.api.events; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.block.BlockMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BlockListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Location; import org.bukkit.Material; @@ -64,7 +67,7 @@ void testEventIsFired() { BlockStorage.addBlockInfo(block, "id", "FOOD_COMPOSTER"); server.getPluginManager().callEvent(new BlockBreakEvent(block, player)); - server.getPluginManager().assertEventFired(SlimefunBlockBreakEvent.class, e -> true); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockBreakEvent.class, e -> true)); } @Test @@ -81,14 +84,14 @@ void testGetters() { BlockStorage.addBlockInfo(block, "id", "FOOD_COMPOSTER"); server.getPluginManager().callEvent(new BlockBreakEvent(block, player)); - server.getPluginManager().assertEventFired(SlimefunBlockBreakEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockBreakEvent.class, e -> { Assertions.assertEquals(block, e.getBlockBroken()); Assertions.assertEquals(slimefunItem, e.getSlimefunItem()); Assertions.assertEquals(itemStack, e.getHeldItem()); Assertions.assertEquals(player, e.getPlayer()); Assertions.assertFalse(e.isCancelled()); return true; - }); + })); } @Test @@ -113,11 +116,11 @@ public void onBlockBreak(SlimefunBlockBreakEvent event) { BlockBreakEvent blockBreakEvent = new BlockBreakEvent(block, player); server.getPluginManager().callEvent(blockBreakEvent); - server.getPluginManager().assertEventFired(SlimefunBlockBreakEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockBreakEvent.class, e -> { Assertions.assertTrue(e.isCancelled()); Assertions.assertTrue(blockBreakEvent.isCancelled()); return true; - }); + })); } @Test @@ -135,8 +138,9 @@ void testBlockBreaksGetQueuedForDeletion() { BlockBreakEvent blockBreakEvent = new BlockBreakEvent(block, player); server.getPluginManager().callEvent(blockBreakEvent); - server.getPluginManager().assertEventFired(SlimefunBlockBreakEvent.class, e -> true); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockBreakEvent.class, e -> true)); Assertions.assertTrue(Slimefun.getTickerTask().isDeletedSoon(block.getLocation())); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunBlockPlaceEvent.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunBlockPlaceEvent.java similarity index 84% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunBlockPlaceEvent.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunBlockPlaceEvent.java index c33db57184..4b2f19b8e2 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunBlockPlaceEvent.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunBlockPlaceEvent.java @@ -1,13 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.api.events; - -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.block.BlockMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +package io.github.thebusybiscuit.slimefun5.api.events; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.block.BlockMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.BlockListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; import me.mrCookieSlime.Slimefun.api.BlockStorage; import org.bukkit.Location; import org.bukkit.Material; @@ -74,7 +77,7 @@ void testEventIsFired() { ); server.getPluginManager().callEvent(blockPlaceEvent); - server.getPluginManager().assertEventFired(SlimefunBlockPlaceEvent.class, e -> true); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockPlaceEvent.class, e -> true)); } @Test @@ -97,14 +100,14 @@ void testGetters() { ); server.getPluginManager().callEvent(blockPlaceEvent); - server.getPluginManager().assertEventFired(SlimefunBlockPlaceEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockPlaceEvent.class, e -> { Assertions.assertEquals(block, e.getBlockPlaced()); Assertions.assertEquals(slimefunItem, e.getSlimefunItem()); Assertions.assertEquals(itemStack, e.getItemStack()); Assertions.assertEquals(player, e.getPlayer()); Assertions.assertFalse(e.isCancelled()); return true; - }); + })); } @Test @@ -134,11 +137,11 @@ public void onBlockPlace(SlimefunBlockPlaceEvent event) { ); server.getPluginManager().callEvent(blockPlaceEvent); - server.getPluginManager().assertEventFired(SlimefunBlockPlaceEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockPlaceEvent.class, e -> { Assertions.assertTrue(e.isCancelled()); Assertions.assertTrue(blockPlaceEvent.isCancelled()); return true; - }); + })); } @Test @@ -162,14 +165,14 @@ void testBlockPlacementBeforeFullDeletion() { ); server.getPluginManager().callEvent(firstBlockPlaceEvent); - server.getPluginManager().assertEventFired(SlimefunBlockPlaceEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockPlaceEvent.class, e -> { Assertions.assertFalse(e.isCancelled()); return true; - }); + })); // Break block server.getPluginManager().callEvent(new BlockBreakEvent(firstBlock, player)); - server.getPluginManager().assertEventFired(SlimefunBlockBreakEvent.class, e -> true); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockBreakEvent.class, e -> true)); // Assert that the block is not fully deleted Assertions.assertTrue(Slimefun.getTickerTask().isDeletedSoon(firstBlock.getLocation())); @@ -185,3 +188,4 @@ void testBlockPlacementBeforeFullDeletion() { Assertions.assertTrue(secondBlockPlaceEvent.isCancelled()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunRegistryFinalizedEvent.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunRegistryFinalizedEvent.java similarity index 61% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunRegistryFinalizedEvent.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunRegistryFinalizedEvent.java index bef63828c9..38ea492e8e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestSlimefunRegistryFinalizedEvent.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestSlimefunRegistryFinalizedEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.events; +package io.github.thebusybiscuit.slimefun5.api.events; import org.junit.jupiter.api.Assertions; @@ -7,10 +7,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.setup.PostSetup; class TestSlimefunRegistryFinalizedEvent { @@ -35,8 +38,9 @@ void testEventIsFired() { Assertions.assertDoesNotThrow(() -> PostSetup.loadItems()); // Make sure post setup sent the event - server.getPluginManager().assertEventFired(SlimefunItemRegistryFinalizedEvent.class, ignored -> true); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunItemRegistryFinalizedEvent.class, ignored -> true)); server.getPluginManager().clearEvents(); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestTalismanActivateEvent.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestTalismanActivateEvent.java similarity index 73% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestTalismanActivateEvent.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestTalismanActivateEvent.java index 40cfc61fe5..0236a9958a 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/events/TestTalismanActivateEvent.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/events/TestTalismanActivateEvent.java @@ -1,12 +1,16 @@ -package io.github.thebusybiscuit.slimefun4.api.events; - -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener; +package io.github.thebusybiscuit.slimefun5.api.events; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.not; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.talismans.Talisman; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.TalismanListener; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -71,27 +75,21 @@ void activateAnvilTalisman(boolean enderVariant, boolean inEnderChest) { void testEventIsFired() { // Assert the talisman activates in the inventory activateAnvilTalisman(false, false); - server.getPluginManager().assertEventFired(TalismanActivateEvent.class, ignored -> true); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(TalismanActivateEvent.class, ignored -> true)); server.getPluginManager().clearEvents(); // Assert the talisman activates in the ender chest activateAnvilTalisman(true, true); - server.getPluginManager().assertEventFired(TalismanActivateEvent.class, ignored -> true); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(TalismanActivateEvent.class, ignored -> true)); server.getPluginManager().clearEvents(); // Assert the normal talisman does not activate in the ender chest activateAnvilTalisman(false, true); - Assertions.assertThrows( - AssertionError.class, - () -> server.getPluginManager().assertEventFired(TalismanActivateEvent.class, ignored -> true) - ); + assertThat(server.getPluginManager(), not(hasFiredFilteredEvent(TalismanActivateEvent.class, ignored -> true))); // Assert the ender talisman does not activate in the inventory activateAnvilTalisman(true, false); - Assertions.assertThrows( - AssertionError.class, - () -> server.getPluginManager().assertEventFired(TalismanActivateEvent.class, ignored -> true) - ); + assertThat(server.getPluginManager(), not(hasFiredFilteredEvent(TalismanActivateEvent.class, ignored -> true))); } @Test @@ -99,22 +97,22 @@ void testEventIsFired() { void testEventFields() { // Assert the talisman activates in the inventory activateAnvilTalisman(false, false); - server.getPluginManager().assertEventFired(TalismanActivateEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(TalismanActivateEvent.class, event -> { Assertions.assertEquals(talisman, event.getTalisman()); Assertions.assertEquals(talisman.getItem(), event.getTalismanItem()); Assertions.assertEquals(player, event.getPlayer()); return true; - }); + })); server.getPluginManager().clearEvents(); // Assert the talisman activates in the ender chest activateAnvilTalisman(true, true); - server.getPluginManager().assertEventFired(TalismanActivateEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(TalismanActivateEvent.class, event -> { Assertions.assertEquals(enderTalisman, event.getTalisman()); Assertions.assertEquals(enderTalisman.getItem(), event.getTalismanItem()); Assertions.assertEquals(player, event.getPlayer()); return true; - }); + })); server.getPluginManager().clearEvents(); } @@ -130,18 +128,18 @@ public void onTalismanActivate(TalismanActivateEvent event) { // Assert the talisman activates in the inventory activateAnvilTalisman(false, false); - server.getPluginManager().assertEventFired(TalismanActivateEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(TalismanActivateEvent.class, event -> { Assertions.assertTrue(event.isCancelled()); return true; - }); + })); server.getPluginManager().clearEvents(); // Assert the talisman activates in the ender chest activateAnvilTalisman(true, true); - server.getPluginManager().assertEventFired(TalismanActivateEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(TalismanActivateEvent.class, event -> { Assertions.assertTrue(event.isCancelled()); return true; - }); + })); server.getPluginManager().clearEvents(); } @@ -157,18 +155,19 @@ public void onTalismanActivate(TalismanActivateEvent event) { // Assert the talisman activates in the inventory activateAnvilTalisman(false, false); - server.getPluginManager().assertEventFired(TalismanActivateEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(TalismanActivateEvent.class, event -> { Assertions.assertTrue(event.preventsConsumption()); return true; - }); + })); server.getPluginManager().clearEvents(); // Assert the talisman activates in the ender chest activateAnvilTalisman(true, true); - server.getPluginManager().assertEventFired(TalismanActivateEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(TalismanActivateEvent.class, event -> { Assertions.assertTrue(event.preventsConsumption()); return true; - }); + })); server.getPluginManager().clearEvents(); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/geo/TestResourceRegistration.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/geo/TestResourceRegistration.java similarity index 93% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/geo/TestResourceRegistration.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/geo/TestResourceRegistration.java index 9fba77c29f..07f036296c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/geo/TestResourceRegistration.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/geo/TestResourceRegistration.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.geo; +package io.github.thebusybiscuit.slimefun5.api.geo; import java.util.Optional; @@ -18,12 +18,12 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.resources.GEOResourcesSetup; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; @TestMethodOrder(value = OrderAnnotation.class) class TestResourceRegistration { @@ -121,3 +121,4 @@ void testSaltResource() { Assertions.assertTrue(resource.getDefaultSupply(Environment.NORMAL, Biome.SWAMP) > 10); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/gps/TestWaypoints.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/gps/TestWaypoints.java similarity index 87% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/gps/TestWaypoints.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/gps/TestWaypoints.java index 3b769c44a0..161348cf28 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/gps/TestWaypoints.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/gps/TestWaypoints.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.gps; +package io.github.thebusybiscuit.slimefun5.api.gps; import java.io.File; import java.io.IOException; @@ -10,14 +10,17 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.utils.FileUtils; +import io.github.thebusybiscuit.slimefun5.api.events.WaypointCreateEvent; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.utils.FileUtils; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestWaypoints { @@ -114,7 +117,7 @@ void testWaypointEvent() throws InterruptedException { TestUtilities.awaitProfile(player); network.addWaypoint(player, "Hello world", player.getLocation()); - server.getPluginManager().assertEventFired(WaypointCreateEvent.class, event -> event.getPlayer() == player); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(WaypointCreateEvent.class, event -> event.getPlayer() == player)); } @Test @@ -145,3 +148,4 @@ void testIsDeathpoint() throws InterruptedException { Assertions.assertTrue(deathpoint.isDeathpoint()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestDoubleRangeSetting.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestDoubleRangeSetting.java similarity index 89% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestDoubleRangeSetting.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestDoubleRangeSetting.java index d13d0db64b..5b92588f10 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestDoubleRangeSetting.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestDoubleRangeSetting.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import org.bukkit.Material; import org.junit.jupiter.api.AfterAll; @@ -8,11 +8,11 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestDoubleRangeSetting { @@ -76,3 +76,4 @@ void testAllowedValue() { Assertions.assertEquals(0.75, setting.getValue()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestEnumSetting.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestEnumSetting.java similarity index 88% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestEnumSetting.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestEnumSetting.java index 46df470c91..65ee1ad1a8 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestEnumSetting.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestEnumSetting.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import org.bukkit.Material; import org.junit.jupiter.api.AfterAll; @@ -8,11 +8,11 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestEnumSetting { @@ -67,3 +67,4 @@ void testAllowedValue() { Assertions.assertEquals(Material.EMERALD, setting.getAsEnumConstant()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestIntRangeSetting.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestIntRangeSetting.java similarity index 89% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestIntRangeSetting.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestIntRangeSetting.java index cfb12eb0fc..cdaa91340e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestIntRangeSetting.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestIntRangeSetting.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import org.bukkit.Material; import org.junit.jupiter.api.AfterAll; @@ -8,11 +8,11 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestIntRangeSetting { @@ -76,3 +76,4 @@ void testAllowedValue() { Assertions.assertEquals(42, setting.getValue()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestItemSettings.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestItemSettings.java similarity index 90% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestItemSettings.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestItemSettings.java index 0e043ed7f2..f8506c4242 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestItemSettings.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestItemSettings.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import java.util.Optional; @@ -10,12 +10,12 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestItemSettings { @@ -93,3 +93,4 @@ void testAlreadyExistingItemSetting() { Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemSetting(setting)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestMaterialTagSetting.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestMaterialTagSetting.java similarity index 89% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestMaterialTagSetting.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestMaterialTagSetting.java index a62928efec..245014e876 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/items/settings/TestMaterialTagSetting.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/items/settings/TestMaterialTagSetting.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.items.settings; +package io.github.thebusybiscuit.slimefun5.api.items.settings; import java.util.Arrays; import java.util.HashSet; @@ -14,11 +14,11 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestMaterialTagSetting { @@ -76,3 +76,4 @@ void testAllowedValue() { Assertions.assertIterableEquals(materials, setting.getValue()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestAsyncProfileLoadEvent.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestAsyncProfileLoadEvent.java similarity index 74% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestAsyncProfileLoadEvent.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestAsyncProfileLoadEvent.java index 17ea900f19..243e15cd20 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestAsyncProfileLoadEvent.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestAsyncProfileLoadEvent.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.profiles; +package io.github.thebusybiscuit.slimefun5.api.profiles; import org.bukkit.OfflinePlayer; import org.bukkit.event.Event; @@ -8,15 +8,18 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.events.AsyncProfileLoadEvent; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.mocks.MockProfile; +import io.github.thebusybiscuit.slimefun5.api.events.AsyncProfileLoadEvent; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.mocks.MockProfile; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.OfflinePlayerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.OfflinePlayerMock; class TestAsyncProfileLoadEvent { @@ -41,7 +44,7 @@ void testEventFired() throws InterruptedException { OfflinePlayer player = new OfflinePlayerMock("EventFire"); TestUtilities.awaitProfile(player); - server.getPluginManager().assertEventFired(AsyncProfileLoadEvent.class, Event::isAsynchronous); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(AsyncProfileLoadEvent.class, Event::isAsynchronous)); } @Test @@ -52,7 +55,7 @@ void testEventGetter() throws InterruptedException { OfflinePlayer player = new OfflinePlayerMock("GetProfile"); PlayerProfile profile = TestUtilities.awaitProfile(player); - server.getPluginManager().assertEventFired(AsyncProfileLoadEvent.class, e -> e.getProfile().equals(profile)); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(AsyncProfileLoadEvent.class, e -> e.getProfile().equals(profile))); } @Test @@ -93,3 +96,4 @@ void testProfileMismatch() throws InterruptedException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestGuideHistory.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestGuideHistory.java similarity index 90% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestGuideHistory.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestGuideHistory.java index 214cca3c0c..a1f0491471 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestGuideHistory.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestGuideHistory.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.profiles; +package io.github.thebusybiscuit.slimefun5.api.profiles; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -11,15 +11,15 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.core.guide.GuideHistory; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestGuideHistory { @@ -135,3 +135,4 @@ void testItemGroup() throws InterruptedException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestPlayerBackpacks.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestPlayerBackpacks.java similarity index 89% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestPlayerBackpacks.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestPlayerBackpacks.java index 90d475d479..ca56bfdb7e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestPlayerBackpacks.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestPlayerBackpacks.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.profiles; +package io.github.thebusybiscuit.slimefun5.api.profiles; import java.util.Optional; @@ -9,13 +9,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestPlayerBackpacks { @@ -99,3 +99,4 @@ void testGetBackpackById() throws InterruptedException { Assertions.assertFalse(profile.getBackpack(500).isPresent()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestPlayerProfile.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestPlayerProfile.java similarity index 90% rename from src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestPlayerProfile.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestPlayerProfile.java index 61c49f0c32..8f8b079903 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/api/profiles/TestPlayerProfile.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/api/profiles/TestPlayerProfile.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.api.profiles; +package io.github.thebusybiscuit.slimefun5.api.profiles; import java.util.Iterator; import java.util.Optional; @@ -11,14 +11,14 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.HashedArmorpiece; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.OfflinePlayerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.OfflinePlayerMock; class TestPlayerProfile { @@ -139,3 +139,4 @@ void testHashCode() throws InterruptedException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestBackpackCommand.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestBackpackCommand.java similarity index 70% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestBackpackCommand.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestBackpackCommand.java index 8443fdd0f5..dd214729f1 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestBackpackCommand.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestBackpackCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands; +package io.github.thebusybiscuit.slimefun5.core.commands; import java.util.List; @@ -14,15 +14,18 @@ import org.junit.jupiter.params.provider.ValueSource; import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.command.CommandResultSucceedMatcher.hasSucceeded; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestBackpackCommand { @@ -61,7 +64,7 @@ void testValidBackpack() throws InterruptedException { PlayerProfile profile = TestUtilities.awaitProfile(player); PlayerBackpack backpack = profile.createBackpack(54); - server.execute("slimefun", player, "backpack", player.getName(), String.valueOf(backpack.getId())).assertSucceeded(); + assertThat(server.execute("slimefun", player, "backpack", player.getName(), String.valueOf(backpack.getId())), hasSucceeded()); Assertions.assertTrue(hasBackpack(player, backpack.getId())); } @@ -74,10 +77,11 @@ void testNonExistentBackpacks(String id) throws InterruptedException { player.setOp(true); TestUtilities.awaitProfile(player); - server.execute("slimefun", player, "backpack", player.getName(), id).assertSucceeded(); + assertThat(server.execute("slimefun", player, "backpack", player.getName(), id), hasSucceeded()); if (CommonPatterns.NUMERIC.matcher(id).matches()) { Assertions.assertFalse(hasBackpack(player, Integer.parseInt(id))); } } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestChargeCommand.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestChargeCommand.java similarity index 77% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestChargeCommand.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestChargeCommand.java index 6a10937092..cd1a5570e0 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestChargeCommand.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestChargeCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands; +package io.github.thebusybiscuit.slimefun5.core.commands; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -9,17 +9,17 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.utils.LoreBuilder; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestChargeCommand { @@ -72,4 +72,4 @@ public float getMaxItemCharge(ItemStack item) { } } -} \ No newline at end of file +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestDebugFishCommand.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestDebugFishCommand.java similarity index 62% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestDebugFishCommand.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestDebugFishCommand.java index e91cd45e14..89d237b590 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestDebugFishCommand.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestDebugFishCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands; +package io.github.thebusybiscuit.slimefun5.core.commands; import org.bukkit.entity.Player; import org.junit.jupiter.api.AfterAll; @@ -8,12 +8,15 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.command.CommandResultSucceedMatcher.hasSucceeded; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestDebugFishCommand { @@ -36,8 +39,9 @@ public static void unload() { void testCommand(boolean op) { Player player = server.addPlayer(); player.setOp(op); - server.execute("slimefun", player, "debug_fish").assertSucceeded(); + assertThat(server.execute("slimefun", player, "debug_fish"), hasSucceeded()); Assertions.assertEquals(op, SlimefunUtils.containsSimilarItem(player.getInventory(), SlimefunItems.DEBUG_FISH.item(), true)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestGuideCommand.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestGuideCommand.java similarity index 64% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestGuideCommand.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestGuideCommand.java index 57560503a7..89d8b05ca3 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestGuideCommand.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestGuideCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands; +package io.github.thebusybiscuit.slimefun5.core.commands; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -9,13 +9,16 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.command.CommandResultSucceedMatcher.hasSucceeded; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestGuideCommand { @@ -39,8 +42,9 @@ void testCommand(boolean op) { Player player = server.addPlayer(); player.setOp(op); boolean hasPermission = player.hasPermission("slimefun.command.guide"); - server.execute("slimefun", player, "guide").assertSucceeded(); + assertThat(server.execute("slimefun", player, "guide"), hasSucceeded()); ItemStack guide = SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE); Assertions.assertEquals(hasPermission, SlimefunUtils.containsSimilarItem(player.getInventory(), guide, true)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestResearchCommand.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestResearchCommand.java similarity index 69% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestResearchCommand.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestResearchCommand.java index 00fdecdb9a..3539d2a42c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/commands/TestResearchCommand.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/commands/TestResearchCommand.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.commands; +package io.github.thebusybiscuit.slimefun5.core.commands; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; @@ -8,13 +8,16 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.command.CommandResultSucceedMatcher.hasSucceeded; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestResearchCommand { @@ -46,7 +49,7 @@ void testResearchAll() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); - server.executeConsole("slimefun", "research", player.getName(), "all").assertSucceeded(); + assertThat(server.executeConsole("slimefun", "research", player.getName(), "all"), hasSucceeded()); Assertions.assertTrue(profile.hasUnlocked(research)); Assertions.assertTrue(profile.hasUnlocked(research2)); @@ -59,7 +62,7 @@ void testResearchSpecific() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); - server.executeConsole("slimefun", "research", player.getName(), research.getKey().toString()).assertSucceeded(); + assertThat(server.executeConsole("slimefun", "research", player.getName(), research.getKey().toString()), hasSucceeded()); Assertions.assertTrue(profile.hasUnlocked(research)); Assertions.assertFalse(profile.hasUnlocked(research2)); @@ -72,14 +75,15 @@ void testResearchReset() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); - server.executeConsole("slimefun", "research", player.getName(), "all").assertSucceeded(); + assertThat(server.executeConsole("slimefun", "research", player.getName(), "all"), hasSucceeded()); Assertions.assertTrue(profile.hasUnlocked(research)); Assertions.assertTrue(profile.hasUnlocked(research2)); - server.executeConsole("slimefun", "research", player.getName(), "reset").assertSucceeded(); + assertThat(server.executeConsole("slimefun", "research", player.getName(), "reset"), hasSucceeded()); Assertions.assertFalse(profile.hasUnlocked(research)); Assertions.assertFalse(profile.hasUnlocked(research2)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/debug/TestDebugLogging.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/debug/TestDebugLogging.java similarity index 95% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/debug/TestDebugLogging.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/debug/TestDebugLogging.java index cc7caf76ca..49980842b7 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/debug/TestDebugLogging.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/debug/TestDebugLogging.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.debug; +package io.github.thebusybiscuit.slimefun5.core.debug; import java.text.MessageFormat; import java.util.logging.Handler; @@ -12,9 +12,9 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestDebugLogging { @@ -134,3 +134,4 @@ void testMessageAwkwardPattern() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/guide/TestGuideOpening.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/guide/TestGuideOpening.java similarity index 91% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/guide/TestGuideOpening.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/guide/TestGuideOpening.java index b7a9a20d1c..0bef0fb870 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/guide/TestGuideOpening.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/guide/TestGuideOpening.java @@ -1,11 +1,11 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun5.core.guide; import java.util.function.Consumer; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.guide.SurvivalSlimefunGuide; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -19,14 +19,14 @@ import org.mockito.Mockito; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestGuideOpening { @@ -143,3 +143,4 @@ void testGoBack() throws InterruptedException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/TestMultiBlocks.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/TestMultiBlocks.java similarity index 95% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/TestMultiBlocks.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/TestMultiBlocks.java index 93fb5ef75f..2e544b54cd 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/TestMultiBlocks.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/multiblocks/TestMultiBlocks.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.multiblocks; +package io.github.thebusybiscuit.slimefun5.core.multiblocks; import org.bukkit.Material; import org.bukkit.block.BlockFace; @@ -9,11 +9,11 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestMultiBlocks { @@ -120,3 +120,4 @@ void testNotEqual() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/networks/TestNetworkManager.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/networks/TestNetworkManager.java similarity index 94% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/networks/TestNetworkManager.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/networks/TestNetworkManager.java index 4ac8db287e..9202ebc958 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/networks/TestNetworkManager.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/networks/TestNetworkManager.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.networks; +package io.github.thebusybiscuit.slimefun5.core.networks; import java.util.HashMap; import java.util.List; @@ -16,13 +16,13 @@ import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mockito; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent; -import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; -import io.github.thebusybiscuit.slimefun4.test.mocks.MockNetwork; +import io.github.thebusybiscuit.slimefun5.api.network.Network; +import io.github.thebusybiscuit.slimefun5.api.network.NetworkComponent; +import io.github.thebusybiscuit.slimefun5.core.networks.cargo.CargoNet; +import io.github.thebusybiscuit.slimefun5.test.mocks.MockNetwork; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestNetworkManager { @@ -189,3 +189,4 @@ void testNullLocations() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestProfileResearches.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestProfileResearches.java similarity index 88% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestProfileResearches.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestProfileResearches.java index c6072275eb..5868572089 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestProfileResearches.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestProfileResearches.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.researching; +package io.github.thebusybiscuit.slimefun5.core.researching; import java.util.Arrays; @@ -10,13 +10,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestProfileResearches { @@ -103,3 +103,4 @@ void testGetResearches() throws InterruptedException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearchUnlocking.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestResearchUnlocking.java similarity index 76% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearchUnlocking.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestResearchUnlocking.java index 7d376cc111..8abb106951 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearchUnlocking.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestResearchUnlocking.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.researching; +package io.github.thebusybiscuit.slimefun5.core.researching; import java.util.Optional; import java.util.concurrent.CountDownLatch; @@ -14,13 +14,16 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.events.ResearchUnlockEvent; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestResearchUnlocking { @@ -63,12 +66,12 @@ void testUnlock(boolean instant) throws InterruptedException { Player p = awaitUnlock(player, research, instant); Optional profile = PlayerProfile.find(p); - server.getPluginManager().assertEventFired(ResearchUnlockEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(ResearchUnlockEvent.class, event -> { Assertions.assertEquals(p, event.getPlayer()); Assertions.assertEquals(research, event.getResearch()); Assertions.assertFalse(event.isCancelled()); return true; - }); + })); Assertions.assertEquals(player, p); Assertions.assertTrue(profile.isPresent()); @@ -76,3 +79,4 @@ void testUnlock(boolean instant) throws InterruptedException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearches.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestResearches.java similarity index 89% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearches.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestResearches.java index 21bb2b2f3e..93f7f5ba17 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/researching/TestResearches.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/researching/TestResearches.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.researching; +package io.github.thebusybiscuit.slimefun5.core.researching; import java.util.Optional; @@ -14,16 +14,19 @@ import org.mockito.Mockito; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerPreResearchEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerPreResearchEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideImplementation; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestResearches { @@ -203,13 +206,14 @@ void testPreCanUnlockResearchEvent() throws InterruptedException { research.unlockFromGuide(guide, player, profile, sfItem, sfItem.getItemGroup(), 0); - server.getPluginManager().assertEventFired(PlayerPreResearchEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerPreResearchEvent.class, event -> { Assertions.assertEquals(player, event.getPlayer()); Assertions.assertEquals(research, event.getResearch()); Assertions.assertEquals(sfItem, event.getSlimefunItem()); Assertions.assertFalse(event.isCancelled()); return true; - }); + })); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestBlockDataService.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestBlockDataService.java similarity index 90% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestBlockDataService.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestBlockDataService.java index 909f050f26..a340b4a6f0 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestBlockDataService.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestBlockDataService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -8,9 +8,9 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestBlockDataService { @@ -52,3 +52,4 @@ void testTileEntities() { Assertions.assertTrue(service.isTileEntity(Material.PLAYER_WALL_HEAD)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestCustomTextureService.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestCustomTextureService.java similarity index 89% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestCustomTextureService.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestCustomTextureService.java index 919de0d374..6a383498d0 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestCustomTextureService.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestCustomTextureService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.util.Arrays; @@ -11,11 +11,11 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestCustomTextureService { @@ -76,3 +76,4 @@ void testSetTexture() { Assertions.assertEquals(300, stack.getItemMeta().getCustomModelData()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestItemDataService.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestItemDataService.java similarity index 92% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestItemDataService.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestItemDataService.java index ec323ff6f4..6c4f038c1d 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestItemDataService.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestItemDataService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.util.Optional; @@ -12,9 +12,9 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestItemDataService { @@ -70,3 +70,4 @@ void testSetDataItemMeta() { Assertions.assertEquals("Hello World", data2.get()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestPermissionsService.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestPermissionsService.java similarity index 93% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestPermissionsService.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestPermissionsService.java index 0c0bf143e3..271ad4556f 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestPermissionsService.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestPermissionsService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.util.Arrays; import java.util.Optional; @@ -16,12 +16,12 @@ import org.junit.jupiter.params.provider.ValueSource; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestPermissionsService { @@ -128,3 +128,4 @@ void testHasPermissionSet() { Assertions.assertTrue(service.hasPermission(player, item)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestRecipeService.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestRecipeService.java similarity index 94% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestRecipeService.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestRecipeService.java index bc30dbf583..c04fe4aed3 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestRecipeService.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestRecipeService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; @@ -19,10 +19,10 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.recipes.RecipeSnapshot; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestRecipeService { @@ -46,7 +46,8 @@ void testRecipe() { MinecraftRecipeService service = new MinecraftRecipeService(plugin); NamespacedKey key = new NamespacedKey(plugin, "furnace_recipe_test"); - ItemStack result = new ItemStack(Material.EMERALD_BLOCK); + // Use DRAGON_EGG as it has no pre-existing vanilla recipe in MockBukkit + ItemStack result = new ItemStack(Material.DRAGON_EGG); FurnaceRecipe recipe = new FurnaceRecipe(key, result, new MaterialChoice(Material.DIAMOND), 1, 2); server.addRecipe(recipe); @@ -170,3 +171,4 @@ void testSubscriptions() { Assertions.assertNotNull(reference.get()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestUpdaterService.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestUpdaterService.java similarity index 90% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestUpdaterService.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestUpdaterService.java index 4de8e01e62..eec23bf3d1 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/TestUpdaterService.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/TestUpdaterService.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services; +package io.github.thebusybiscuit.slimefun5.core.services; import java.io.File; @@ -8,10 +8,10 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.SlimefunBranch; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestUpdaterService { @@ -68,3 +68,4 @@ void testUnknownBuilds() { Assertions.assertEquals(-1, service.getBuildNumber()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/AbstractLocaleRegexChecker.java similarity index 97% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/AbstractLocaleRegexChecker.java index df8668f285..600258cb72 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/AbstractLocaleRegexChecker.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/AbstractLocaleRegexChecker.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.localization; +package io.github.thebusybiscuit.slimefun5.core.services.localization; import java.io.BufferedReader; import java.io.IOException; @@ -24,7 +24,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.provider.Arguments; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class AbstractLocaleRegexChecker { @@ -110,3 +110,4 @@ void assertNoRegexMatch(String location, String value) { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/TestColorCodes.java similarity index 96% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/TestColorCodes.java index 88371ac0ee..bf2ff32e1d 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestColorCodes.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/TestColorCodes.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.localization; +package io.github.thebusybiscuit.slimefun5.core.services.localization; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.FileConfiguration; @@ -45,3 +45,4 @@ void testSpelling(LanguagePreset lang, LanguageFile file) throws IOException, In } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestSlimefunSpelling.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/TestSlimefunSpelling.java similarity index 94% rename from src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestSlimefunSpelling.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/TestSlimefunSpelling.java index dd8b62be3a..bc2cf4da85 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/core/services/localization/TestSlimefunSpelling.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/core/services/localization/TestSlimefunSpelling.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.services.localization; +package io.github.thebusybiscuit.slimefun5.core.services.localization; import java.io.IOException; import java.util.regex.Pattern; @@ -38,3 +38,4 @@ void testSpelling(LanguagePreset lang, LanguageFile file) throws IOException, In } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestDamageableItem.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestDamageableItem.java similarity index 88% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestDamageableItem.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestDamageableItem.java index 7a97e33cf3..25106701e4 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestDamageableItem.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestDamageableItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; import javax.annotation.Nullable; @@ -14,15 +14,15 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.mocks.MockDamageable; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.mocks.MockDamageable; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEnchantment; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestDamageableItem { @@ -101,3 +101,4 @@ void testDamageableItemCaresUnbreaking() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestRadioactiveItem.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestRadioactiveItem.java similarity index 72% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestRadioactiveItem.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestRadioactiveItem.java index 6c7853da2d..7c2e9a8120 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestRadioactiveItem.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestRadioactiveItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -9,14 +9,14 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactivity; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestRadioactiveItem { @@ -45,3 +45,4 @@ void testWikiPages(Radioactivity radioactivity) { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestSlimefunItem.java similarity index 92% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestSlimefunItem.java index 421a4248f3..55a879b846 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/TestSlimefunItem.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/TestSlimefunItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items; +package io.github.thebusybiscuit.slimefun5.implementation.items; import java.util.Optional; @@ -11,14 +11,14 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.exceptions.UnregisteredItemException; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.exceptions.UnregisteredItemException; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestSlimefunItem { @@ -50,7 +50,7 @@ void testWikiPages() { Optional wiki = item.getWikipage(); Assertions.assertTrue(wiki.isPresent()); - Assertions.assertEquals("https://github.com/Slimefun/Slimefun4/wiki/Test", wiki.get()); + Assertions.assertEquals("https://github.com/Slimefun5/Slimefun5/wiki/Test", wiki.get()); } @Test @@ -165,3 +165,4 @@ void testHashCode() { Assertions.assertNotEquals(item2.hashCode(), differentItem.hashCode()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAbstractRecipe.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/TestAbstractRecipe.java similarity index 94% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAbstractRecipe.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/TestAbstractRecipe.java index 2fa377c86e..4b79b786e0 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAbstractRecipe.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/TestAbstractRecipe.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; import java.util.Arrays; import java.util.HashSet; @@ -19,9 +19,9 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestAbstractRecipe { @@ -88,3 +88,4 @@ void testInvalidRecipes() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAutoCrafter.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/TestAutoCrafter.java similarity index 93% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAutoCrafter.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/TestAutoCrafter.java index 0158b7cb86..4473981e2b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/autocrafters/TestAutoCrafter.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/autocrafters/TestAutoCrafter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters; +package io.github.thebusybiscuit.slimefun5.implementation.items.autocrafters; import javax.annotation.Nonnull; @@ -14,16 +14,16 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.inventory.ChestInventoryMock; -import be.seeseemelk.mockbukkit.inventory.InventoryMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.inventory.ChestInventoryMock; +import org.mockbukkit.mockbukkit.inventory.InventoryMock; class TestAutoCrafter { @@ -207,3 +207,4 @@ private AbstractAutoCrafter getVanillaAutoCrafter() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/TestEnderBackpack.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/TestEnderBackpack.java similarity index 76% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/TestEnderBackpack.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/TestEnderBackpack.java index 62b22112a1..d5053e4517 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/TestEnderBackpack.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/backpacks/TestEnderBackpack.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks; +package io.github.thebusybiscuit.slimefun5.implementation.items.backpacks; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -9,14 +9,14 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.presets.SlimefunItemTest; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.presets.SlimefunItemTest; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestEnderBackpack implements SlimefunItemTest { @@ -55,3 +55,4 @@ void testRightClickBehaviour() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestDietCookie.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestDietCookie.java similarity index 63% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestDietCookie.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestDietCookie.java index 693e5f03cf..7122be2a52 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestDietCookie.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestDietCookie.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -9,16 +9,19 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.presets.SlimefunItemTest; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.presets.SlimefunItemTest; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.sound.SoundReceiverSoundHeardMatcher.hasHeard; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; class TestDietCookie implements SlimefunItemTest { @@ -52,8 +55,9 @@ void testConsumptionBehaviour() { simulateConsumption(player, cookie); - player.assertSoundHeard(SoundEffect.DIET_COOKIE_CONSUME_SOUND.getDefaultSoundId()); + assertThat(player, hasHeard(SoundEffect.DIET_COOKIE_CONSUME_SOUND.getDefaultSoundId())); Assertions.assertTrue(player.hasPotionEffect(PotionEffectType.LEVITATION)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestMeatJerky.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestMeatJerky.java similarity index 73% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestMeatJerky.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestMeatJerky.java index ea78037705..96db660d62 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestMeatJerky.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestMeatJerky.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -8,15 +8,15 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.presets.SlimefunItemTest; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.presets.SlimefunItemTest; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; class TestMeatJerky implements SlimefunItemTest { @@ -56,3 +56,4 @@ void testConsumptionBehaviour() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestMonsterJerky.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestMonsterJerky.java similarity index 75% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestMonsterJerky.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestMonsterJerky.java index ed279f4e93..d95b43e78c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/TestMonsterJerky.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/food/TestMonsterJerky.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; +package io.github.thebusybiscuit.slimefun5.implementation.items.food; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -9,15 +9,15 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.presets.SlimefunItemTest; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.presets.SlimefunItemTest; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; class TestMonsterJerky implements SlimefunItemTest { @@ -57,3 +57,4 @@ void testConsumptionBehaviour() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestClimbingPick.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestClimbingPick.java similarity index 84% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestClimbingPick.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestClimbingPick.java index 9a43bc12f5..98f781fac4 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestClimbingPick.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestClimbingPick.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import java.util.stream.Stream; @@ -18,20 +18,23 @@ import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; -import io.github.thebusybiscuit.slimefun4.api.events.ClimbingPickLaunchEvent; -import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.presets.SlimefunItemTest; -import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedEnchantment; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; - -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.block.BlockMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; +import io.github.thebusybiscuit.slimefun5.api.events.ClimbingPickLaunchEvent; +import io.github.thebusybiscuit.slimefun5.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.presets.SlimefunItemTest; +import io.github.thebusybiscuit.slimefun5.utils.compatibility.VersionedEnchantment; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.block.BlockMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; class TestClimbingPick implements SlimefunItemTest { @@ -139,7 +142,7 @@ void testItemUse(BlockFace face) { if (shouldFireEvent) { Assertions.assertTrue(pick.getClimbingSpeed(block.getType()) > 0); Assertions.assertTrue(player.getVelocity().length() > 0); - server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class, e -> e.getPlayer() == player && e.getPick() == pick); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(ClimbingPickLaunchEvent.class, e -> e.getPlayer() == player && e.getPick() == pick)); } else { Assertions.assertEquals(0, player.getVelocity().length()); } @@ -168,3 +171,4 @@ private ItemStack getPickWithEfficiency(@Nonnull ClimbingPick pick, int level) { return item; } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestPortableDustbin.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestPortableDustbin.java similarity index 77% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestPortableDustbin.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestPortableDustbin.java index 8b9d710a37..6ed3d70026 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestPortableDustbin.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestPortableDustbin.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -10,14 +10,14 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.presets.SlimefunItemTest; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.presets.SlimefunItemTest; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestPortableDustbin implements SlimefunItemTest { @@ -57,3 +57,4 @@ void testRightClickBehaviour() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestTapeMeasure.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestTapeMeasure.java similarity index 84% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestTapeMeasure.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestTapeMeasure.java index 6a05e5c34e..d68d550c78 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TestTapeMeasure.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/items/tools/TestTapeMeasure.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; +package io.github.thebusybiscuit.slimefun5.implementation.items.tools; import java.util.Optional; import java.util.OptionalDouble; @@ -15,17 +15,20 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.presets.SlimefunItemTest; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.presets.SlimefunItemTest; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.WorldMock; -import be.seeseemelk.mockbukkit.block.BlockMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.sound.SoundReceiverSoundHeardMatcher.hasHeard; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.world.WorldMock; +import org.mockbukkit.mockbukkit.block.BlockMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; class TestTapeMeasure implements SlimefunItemTest { @@ -108,7 +111,7 @@ void testMeasuringFeedback() { player.setSneaking(false); simulateRightClickBlock(player, tm, item, block2, BlockFace.UP); - player.assertSoundHeard(Sound.ITEM_BOOK_PUT); + assertThat(player, hasHeard(Sound.ITEM_BOOK_PUT)); } @Test @@ -146,3 +149,4 @@ void testOtherWorld() { Assertions.assertFalse(tm.getAnchor(player, item).isPresent()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MockBeeProtectionSuit.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MockBeeProtectionSuit.java similarity index 63% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MockBeeProtectionSuit.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MockBeeProtectionSuit.java index bea038257c..da9cc13cc2 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MockBeeProtectionSuit.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/MockBeeProtectionSuit.java @@ -1,15 +1,15 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectiveArmor; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; class MockBeeProtectionSuit extends SlimefunArmorPiece implements ProtectiveArmor { @@ -33,3 +33,4 @@ public NamespacedKey getArmorSetId() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestAnvilListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestAnvilListener.java similarity index 84% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestAnvilListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestAnvilListener.java index 52fc8fad5e..c3ddf58ae9 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestAnvilListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestAnvilListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,14 +17,14 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.AnvilListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.AnvilListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestAnvilListener { @@ -79,3 +79,4 @@ void testAnvilWithVanillaItem() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBackpackListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBackpackListener.java similarity index 85% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBackpackListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBackpackListener.java index f8e1b299a0..b5953ef1c0 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBackpackListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBackpackListener.java @@ -1,20 +1,20 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.ItemEntityMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.ItemMock; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.mocks.InventoryViewWrapper; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.github.thebusybiscuit.slimefun5.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.SlimefunBackpack; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.mocks.InventoryViewWrapper; +import io.github.thebusybiscuit.slimefun5.utils.tags.SlimefunTag; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -127,7 +127,7 @@ void testBackpackDropNormalItem() throws InterruptedException { Player player = server.addPlayer(); openMockBackpack(player, "DROP_NORMAL_ITEM_BACKPACK_TEST", 27); - Item item = new ItemEntityMock(server, UUID.randomUUID(), new ItemStack(Material.SUGAR_CANE)); + Item item = new ItemMock(server, UUID.randomUUID(), new ItemStack(Material.SUGAR_CANE)); PlayerDropItemEvent event = new PlayerDropItemEvent(player, item); listener.onItemDrop(event); @@ -136,10 +136,12 @@ void testBackpackDropNormalItem() throws InterruptedException { private boolean isAllowed(String id, ItemStack item) throws InterruptedException { Player player = server.addPlayer(); - Inventory inv = openMockBackpack(player, id, 9).getInventory(); + openMockBackpack(player, id, 9); + // Use the view's top inventory so getCurrentItem() sees the item + Inventory topInv = player.getOpenInventory().getTopInventory(); int slot = 7; - inv.setItem(slot, item); + topInv.setItem(slot, item); InventoryClickEvent event = new InventoryClickEvent(player.getOpenInventory(), SlotType.CONTAINER, slot, ClickType.LEFT, InventoryAction.PICKUP_ONE); listener.onClick(event); return !event.isCancelled(); @@ -175,3 +177,4 @@ void testHotbarKey(Material type) throws InterruptedException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBeeListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBeeListener.java similarity index 64% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBeeListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBeeListener.java index fbc563ea6f..99f3359ae6 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBeeListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBeeListener.java @@ -1,10 +1,18 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import java.util.EnumMap; + +import com.google.common.base.Function; +import com.google.common.base.Functions; +import com.google.common.collect.ImmutableMap; import org.bukkit.Material; +import org.bukkit.damage.DamageSource; import org.bukkit.entity.Bee; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -13,15 +21,15 @@ import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mockito; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.BeeListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.BeeListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestBeeListener { @@ -41,6 +49,7 @@ public static void unload() { MockBukkit.unmock(); } + @SuppressWarnings("deprecation") @ParameterizedTest @DisplayName("Test Bee damage protection") @ValueSource(booleans = { true, false }) @@ -62,7 +71,11 @@ void testBeeDamage(boolean hasArmor) throws InterruptedException { double damage = 7.5; Bee bee = Mockito.mock(Bee.class); - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(bee, player, DamageCause.ENTITY_ATTACK, damage); + DamageSource source = Mockito.mock(DamageSource.class); + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(bee, player, DamageCause.ENTITY_ATTACK, source, + new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)), + new EnumMap>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))), + false); listener.onDamage(event); if (hasArmor) { @@ -73,3 +86,4 @@ void testBeeDamage(boolean hasArmor) throws InterruptedException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBrewingStandListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBrewingStandListener.java similarity index 85% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBrewingStandListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBrewingStandListener.java index 660656cd07..941032fe29 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestBrewingStandListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestBrewingStandListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.block.BrewingStand; @@ -19,14 +19,14 @@ import org.mockito.Mockito; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.BrewingStandListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.BrewingStandListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestBrewingStandListener { @@ -83,3 +83,4 @@ void testBrewingWithVanillaItem() { Assertions.assertEquals(Result.ALLOW, event.getResult()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCargoNodeListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCargoNodeListener.java similarity index 87% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCargoNodeListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCargoNodeListener.java index 721ab21ea2..38bcd54304 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCargoNodeListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCargoNodeListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Location; import org.bukkit.Material; @@ -16,16 +16,16 @@ import org.junit.jupiter.params.ParameterizedTest; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoInputNode; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.providers.SlimefunItemsSource; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.cargo.CargoInputNode; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.providers.SlimefunItemsSource; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestCargoNodeListener { @@ -113,3 +113,4 @@ void testNonCargoNode() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCartographyTableListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCartographyTableListener.java similarity index 83% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCartographyTableListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCartographyTableListener.java index b872c45341..b576c1bbd5 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCartographyTableListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCartographyTableListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,14 +17,14 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CartographyTableListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.CartographyTableListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestCartographyTableListener { @@ -73,3 +73,4 @@ void testCartographyTableWithVanillaItem() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCauldronListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCauldronListener.java similarity index 87% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCauldronListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCauldronListener.java index c3072d162e..8a9c6a1e15 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCauldronListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCauldronListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.block.Block; @@ -16,15 +16,15 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CauldronListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.CauldronListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.block.BlockMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.block.BlockMock; class TestCauldronListener { @@ -105,3 +105,4 @@ void testCauldronWithVanillaLeatherArmor() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCoolerListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCoolerListener.java similarity index 71% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCoolerListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCoolerListener.java index 2793b76e11..db73b09d50 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCoolerListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCoolerListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Color; import org.bukkit.Material; @@ -15,18 +15,21 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.CoolerFeedPlayerEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; -import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun5.api.events.CoolerFeedPlayerEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerBackpack; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.backpacks.Cooler; +import io.github.thebusybiscuit.slimefun5.implementation.items.food.Juice; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestCoolerListener { @@ -78,10 +81,11 @@ void testCoolerUsage() throws InterruptedException { new BackpackListener().setBackpackId(player, personalCooler, 1, backpack.getId()); player.getInventory().setItem(7, personalCooler); - FoodLevelChangeEvent event = new FoodLevelChangeEvent(player, 16); + FoodLevelChangeEvent event = new FoodLevelChangeEvent(player, 16, null); listener.onHungerLoss(event); Assertions.assertTrue(player.hasPotionEffect(PotionEffectType.HEALTH_BOOST)); - server.getPluginManager().assertEventFired(CoolerFeedPlayerEvent.class, e -> e.getPlayer() == player && e.getCooler() == cooler); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(CoolerFeedPlayerEvent.class, e -> e.getPlayer() == player && e.getCooler() == cooler)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCraftingTableListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCraftingTableListener.java similarity index 87% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCraftingTableListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCraftingTableListener.java index e78d3f00fd..6d508a7c88 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestCraftingTableListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestCraftingTableListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.apache.commons.lang.mutable.MutableObject; import org.bukkit.Material; @@ -22,14 +22,14 @@ import org.mockito.Mockito; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CraftingTableListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.CraftingTableListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestCraftingTableListener { @@ -54,6 +54,8 @@ private CraftItemEvent mockCraftingEvent(ItemStack item) { Player player = server.addPlayer(); CraftingInventory inv = Mockito.mock(CraftingInventory.class); + Mockito.when(inv.getType()).thenReturn(org.bukkit.event.inventory.InventoryType.CRAFTING); + Mockito.when(inv.getSize()).thenReturn(10); Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { item, null, null, null, null, null, null, null, null }); InventoryView view = player.openInventory(inv); @@ -67,6 +69,8 @@ private PrepareItemCraftEvent mockPreCraftingEvent(ItemStack item) { Player player = server.addPlayer(); CraftingInventory inv = Mockito.mock(CraftingInventory.class); + Mockito.when(inv.getType()).thenReturn(org.bukkit.event.inventory.InventoryType.CRAFTING); + Mockito.when(inv.getSize()).thenReturn(10); MutableObject result = new MutableObject(new ItemStack(Material.EMERALD)); Mockito.doAnswer(invocation -> { @@ -148,3 +152,4 @@ void testPreCraftEventWithVanillaItem() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestDeathpointListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestDeathpointListener.java similarity index 57% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestDeathpointListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestDeathpointListener.java index c47d93a9d7..c81baafadf 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestDeathpointListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestDeathpointListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.entity.Player; import org.junit.jupiter.api.AfterAll; @@ -7,13 +7,17 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.events.WaypointCreateEvent; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.not; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestDeathpointListener { @@ -39,7 +43,7 @@ void testNoTransmitter() throws InterruptedException { TestUtilities.awaitProfile(player); player.setHealth(0); - Assertions.assertThrows(AssertionError.class, () -> server.getPluginManager().assertEventFired(WaypointCreateEvent.class, event -> event.getPlayer() == player && event.isDeathpoint())); + assertThat(server.getPluginManager(), not(hasFiredFilteredEvent(WaypointCreateEvent.class, event -> event.getPlayer() == player && event.isDeathpoint()))); } @Test @@ -50,7 +54,8 @@ void testTransmitter() throws InterruptedException { player.getInventory().setItem(8, SlimefunItems.GPS_EMERGENCY_TRANSMITTER.item()); player.setHealth(0); - server.getPluginManager().assertEventFired(WaypointCreateEvent.class, event -> event.getPlayer() == player && event.isDeathpoint()); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(WaypointCreateEvent.class, event -> event.getPlayer() == player && event.isDeathpoint())); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestFireworksListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestFireworksListener.java similarity index 53% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestFireworksListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestFireworksListener.java index bcea6c1817..f41028a93d 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestFireworksListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestFireworksListener.java @@ -1,22 +1,32 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import java.util.EnumMap; + +import com.google.common.base.Function; +import com.google.common.base.Functions; +import com.google.common.collect.ImmutableMap; import org.bukkit.Color; +import org.bukkit.damage.DamageSource; import org.bukkit.entity.Firework; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.FireworksListener; -import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.FireworksListener; +import io.github.thebusybiscuit.slimefun5.utils.FireworkUtils; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockito.Mockito; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestFireworksListener { @@ -33,15 +43,21 @@ public static void unload() { MockBukkit.unmock(); } + @SuppressWarnings("deprecation") @Test @DisplayName("Test if Fireworks from Research cause no damage") void testFireworkDamage() { Player player = server.addPlayer(); Firework firework = FireworkUtils.createFirework(player.getLocation(), Color.BLUE); - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(firework, player, DamageCause.ENTITY_EXPLOSION, 6.0); + DamageSource source = Mockito.mock(DamageSource.class); + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(firework, player, DamageCause.ENTITY_EXPLOSION, source, + new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 6.0)), + new EnumMap>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))), + false); server.getPluginManager().callEvent(event); Assertions.assertTrue(event.isCancelled()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestGrindstoneListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestGrindstoneListener.java similarity index 83% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestGrindstoneListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestGrindstoneListener.java index fa62fca496..b3e3ce6992 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestGrindstoneListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestGrindstoneListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -19,16 +19,16 @@ import org.junit.jupiter.params.provider.EnumSource; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.GrindstoneListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestGrindstoneListener { @@ -90,3 +90,4 @@ void testGrindStoneWithSlimefunGuide(SlimefunGuideMode layout) { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestIronGolemListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestIronGolemListener.java similarity index 88% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestIronGolemListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestIronGolemListener.java index 2877ee683b..1a5eb0ff7d 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestIronGolemListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestIronGolemListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -15,14 +15,14 @@ import org.mockito.Mockito; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.IronGolemListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.IronGolemListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestIronGolemListener { @@ -103,3 +103,4 @@ void testWithVanillaIron() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestItemPickupListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestItemPickupListener.java similarity index 82% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestItemPickupListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestItemPickupListener.java index b5f35bccfa..f66923fa06 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestItemPickupListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestItemPickupListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; @@ -17,14 +17,14 @@ import org.junit.jupiter.params.provider.ValueSource; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.altar.AncientPedestal; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.ItemEntityMock; -import be.seeseemelk.mockbukkit.inventory.HopperInventoryMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.ItemMock; +import org.mockbukkit.mockbukkit.inventory.HopperInventoryMock; class TestItemPickupListener { @@ -48,7 +48,7 @@ public static void unload() { @ValueSource(booleans = { true, false }) void testNoPickupFlagForEntities(boolean flag) { Player player = server.addPlayer(); - Item item = new ItemEntityMock(server, UUID.randomUUID(), new ItemStack(Material.COMPASS)); + Item item = new ItemMock(server, UUID.randomUUID(), new ItemStack(Material.COMPASS)); if (flag) { SlimefunUtils.markAsNoPickup(item, "Unit Test"); @@ -64,7 +64,7 @@ void testNoPickupFlagForEntities(boolean flag) { @ValueSource(booleans = { true, false }) void testNoPickupFlagForInventories(boolean flag) { Inventory inventory = new HopperInventoryMock(null); - Item item = new ItemEntityMock(server, UUID.randomUUID(), new ItemStack(Material.COMPASS)); + Item item = new ItemMock(server, UUID.randomUUID(), new ItemStack(Material.COMPASS)); if (flag) { SlimefunUtils.markAsNoPickup(item, "Unit Test"); @@ -89,7 +89,7 @@ void testAltarProbeForEntities(boolean flag) { } AtomicBoolean removed = new AtomicBoolean(false); - Item item = new ItemEntityMock(server, UUID.randomUUID(), stack) { + Item item = new ItemMock(server, UUID.randomUUID(), stack) { @Override public void remove() { @@ -117,7 +117,7 @@ void testAltarProbeForInventories(boolean flag) { } AtomicBoolean removed = new AtomicBoolean(false); - Item item = new ItemEntityMock(server, UUID.randomUUID(), stack) { + Item item = new ItemMock(server, UUID.randomUUID(), stack) { @Override public void remove() { @@ -133,3 +133,4 @@ public void remove() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestMultiblockListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestMultiblockListener.java similarity index 80% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestMultiblockListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestMultiblockListener.java index e0420d1645..616bcb8753 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestMultiblockListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestMultiblockListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.World; @@ -16,14 +16,17 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.events.MultiBlockInteractEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.multiblocks.MultiBlock; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestMultiblockListener { @@ -81,12 +84,13 @@ void testMultiblock() { Assertions.assertEquals(Result.DENY, event.useInteractedBlock()); - server.getPluginManager().assertEventFired(MultiBlockInteractEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(MultiBlockInteractEvent.class, e -> { Assertions.assertEquals(player, e.getPlayer()); Assertions.assertEquals(self, e.getClickedBlock()); Assertions.assertEquals(BlockFace.NORTH, e.getClickedFace()); Assertions.assertEquals(multiblock, e.getMultiBlock()); return true; - }); + })); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestNetworkListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestNetworkListener.java similarity index 86% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestNetworkListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestNetworkListener.java index b6ef3148d6..90179ae5c2 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestNetworkListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestNetworkListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Location; import org.bukkit.Material; @@ -14,12 +14,12 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.network.Network; +import io.github.thebusybiscuit.slimefun5.core.networks.NetworkManager; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestNetworkListener { @@ -71,3 +71,4 @@ void testBlockPlace() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPiglinListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestPiglinListener.java similarity index 86% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPiglinListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestPiglinListener.java index 2c912148cf..dcf7dbb22b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPiglinListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestPiglinListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.UUID; @@ -20,14 +20,14 @@ import org.mockito.Mockito; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.PiglinListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.entity.PiglinListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.ItemEntityMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.ItemMock; class TestPiglinListener { @@ -51,7 +51,7 @@ private EntityPickupItemEvent createPickupEvent(ItemStack item) { Piglin piglin = Mockito.mock(Piglin.class); Mockito.when(piglin.getType()).thenReturn(EntityType.PIGLIN); - Item itemEntity = new ItemEntityMock(server, UUID.randomUUID(), item); + Item itemEntity = new ItemMock(server, UUID.randomUUID(), item); return new EntityPickupItemEvent(piglin, itemEntity, 1); } @@ -109,3 +109,4 @@ void testPiglinInteractWithSlimefunItem(EquipmentSlot hand) { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPlayerProfileListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestPlayerProfileListener.java similarity index 68% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPlayerProfileListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestPlayerProfileListener.java index 0ee300a138..a58bea1426 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestPlayerProfileListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestPlayerProfileListener.java @@ -1,4 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; + +import net.kyori.adventure.text.Component; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerKickEvent; @@ -9,12 +11,12 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestPlayerProfileListener { @@ -39,7 +41,7 @@ public static void unload() { void testPlayerLeave() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); - PlayerQuitEvent event = new PlayerQuitEvent(player, "bye"); + PlayerQuitEvent event = new PlayerQuitEvent(player, Component.text("bye"), PlayerQuitEvent.QuitReason.DISCONNECTED); listener.onDisconnect(event); Assertions.assertTrue(profile.isMarkedForDeletion()); @@ -49,7 +51,7 @@ void testPlayerLeave() throws InterruptedException { @DisplayName("Test PlayerProfile being unloaded when Player leaves") void testUnloadedPlayerLeave() { Player player = server.addPlayer(); - PlayerQuitEvent event = new PlayerQuitEvent(player, "bye"); + PlayerQuitEvent event = new PlayerQuitEvent(player, Component.text("bye"), PlayerQuitEvent.QuitReason.DISCONNECTED); listener.onDisconnect(event); Assertions.assertFalse(PlayerProfile.find(player).isPresent()); @@ -60,7 +62,7 @@ void testUnloadedPlayerLeave() { void testPlayerKick() throws InterruptedException { Player player = server.addPlayer(); PlayerProfile profile = TestUtilities.awaitProfile(player); - PlayerKickEvent event = new PlayerKickEvent(player, "You're not welcome anymore", "bye"); + PlayerKickEvent event = new PlayerKickEvent(player, Component.text("You're not welcome anymore"), Component.text("bye"), PlayerKickEvent.Cause.PLUGIN); listener.onKick(event); Assertions.assertTrue(profile.isMarkedForDeletion()); @@ -70,10 +72,11 @@ void testPlayerKick() throws InterruptedException { @DisplayName("Test PlayerProfile being unloaded when Player is kicked") void testUnloadedPlayerKick() { Player player = server.addPlayer(); - PlayerKickEvent event = new PlayerKickEvent(player, "You're not welcome anymore", "bye"); + PlayerKickEvent event = new PlayerKickEvent(player, Component.text("You're not welcome anymore"), Component.text("bye"), PlayerKickEvent.Cause.PLUGIN); listener.onKick(event); Assertions.assertFalse(PlayerProfile.find(player).isPresent()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSlimefunGuideListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSlimefunGuideListener.java similarity index 79% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSlimefunGuideListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSlimefunGuideListener.java index 6b58f849b7..6b8b63b881 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSlimefunGuideListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSlimefunGuideListener.java @@ -1,7 +1,9 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import java.util.stream.Stream; +import net.kyori.adventure.text.Component; + import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; @@ -13,13 +15,13 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; class TestSlimefunGuideListener { @@ -48,7 +50,7 @@ void testFirstJoin(boolean hasPlayedBefore, boolean giveSlimefunGuide) { server.getPlayerList().setLastSeen(player.getUniqueId(), System.currentTimeMillis()); } - PlayerJoinEvent event = new PlayerJoinEvent(player, "CanIHazGuide has joined and wants sum guide"); + PlayerJoinEvent event = new PlayerJoinEvent(player, Component.text("CanIHazGuide has joined and wants sum guide")); listener.onJoin(event); ItemStack guide = SlimefunGuide.getItem(SlimefunGuide.getDefaultMode()); @@ -71,3 +73,4 @@ private static Stream cartesianBooleans() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSlimefunItemInteractListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSlimefunItemInteractListener.java similarity index 78% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSlimefunItemInteractListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSlimefunItemInteractListener.java index cc33e3750a..9705c05638 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSlimefunItemInteractListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSlimefunItemInteractListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.World; import org.bukkit.block.Block; @@ -17,22 +17,26 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockBreakEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricFurnace; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.WindStaff; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.events.SlimefunBlockBreakEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.EnergyConnector; +import io.github.thebusybiscuit.slimefun5.implementation.items.electric.machines.ElectricFurnace; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.staves.WindStaff; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.not; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; class TestSlimefunItemInteractListener { @@ -100,17 +104,17 @@ void testCannotOpenInvOfBrokenBlock() { ); server.getPluginManager().callEvent(playerInteractEvent); - server.getPluginManager().assertEventFired(PlayerInteractEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerInteractEvent.class, e -> { // We cancel the event on inventory open Assertions.assertSame(e.useInteractedBlock(), Result.DENY); return true; - }); + })); // Assert our right click event fired and the block usage was not denied - server.getPluginManager().assertEventFired(PlayerRightClickEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerRightClickEvent.class, e -> { Assertions.assertNotSame(e.useBlock(), Result.DENY); return true; - }); + })); // Assert we do have an inventory which would be opened // TODO: Create an event for open inventory so this isn't guess work @@ -123,10 +127,10 @@ void testCannotOpenInvOfBrokenBlock() { // Break the block BlockBreakEvent blockBreakEvent = new BlockBreakEvent(block, player); server.getPluginManager().callEvent(blockBreakEvent); - server.getPluginManager().assertEventFired(SlimefunBlockBreakEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockBreakEvent.class, e -> { Assertions.assertEquals(electricFurnace.getId(), e.getSlimefunItem().getId()); return true; - }); + })); // Assert the block is queued for removal Assertions.assertTrue(Slimefun.getTickerTask().isDeletedSoon(block.getLocation())); @@ -143,17 +147,14 @@ void testCannotOpenInvOfBrokenBlock() { ); server.getPluginManager().callEvent(secondPlayerInteractEvent); - server.getPluginManager().assertEventFired(PlayerInteractEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerInteractEvent.class, e -> { // We cancelled the event due to the block being removed Assertions.assertSame(e.useInteractedBlock(), Result.DENY); return true; - }); + })); // Assert our right click event was not fired due to the block being broken - Assertions.assertThrows( - AssertionError.class, - () -> server.getPluginManager().assertEventFired(PlayerRightClickEvent.class, e -> true) - ); + assertThat(server.getPluginManager(), not(hasFiredFilteredEvent(PlayerRightClickEvent.class, e -> true))); } @Test @@ -171,17 +172,17 @@ void testRightClickItem() { ); server.getPluginManager().callEvent(playerInteractEvent); - server.getPluginManager().assertEventFired(PlayerInteractEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerInteractEvent.class, e -> { // Assert our interaction was not cancelled Assertions.assertNotSame(e.useItemInHand(), Result.DENY); return true; - }); + })); // Assert our right click event fired and the item usage was not denied - server.getPluginManager().assertEventFired(PlayerRightClickEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerRightClickEvent.class, e -> { Assertions.assertNotSame(e.useItem(), Result.DENY); return true; - }); + })); // Assert our food level is now 18 Assertions.assertEquals(18, player.getFoodLevel()); @@ -204,19 +205,20 @@ void testRightClickInteractableBlock() { ); server.getPluginManager().callEvent(playerInteractEvent); - server.getPluginManager().assertEventFired(PlayerInteractEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerInteractEvent.class, e -> { // Allow interaction of the block Assertions.assertSame(e.useInteractedBlock(), Result.ALLOW); return true; - }); + })); // Assert our right click event fired and the block usage was not denied - server.getPluginManager().assertEventFired(PlayerRightClickEvent.class, e -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerRightClickEvent.class, e -> { Assertions.assertNotSame(e.useBlock(), Result.DENY); return true; - }); + })); // Assert the message our energy connector sends Assertions.assertEquals(ChatColors.color("&7Connected: " + "&4\u2718"), player.nextMessage()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSmithingTableListener.java similarity index 93% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSmithingTableListener.java index 4c02f5864b..f09b3fc677 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSmithingTableListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSmithingTableListener.java @@ -1,7 +1,7 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; import org.apache.commons.lang3.mutable.MutableObject; import org.bukkit.Material; @@ -23,11 +23,11 @@ import org.mockito.Mockito; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.SmithingTableListener; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.listeners.crafting.SmithingTableListener; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; class TestSmithingTableListener { @@ -70,6 +70,8 @@ private SmithItemEvent mockSmithingEvent(ItemStack tool, ItemStack material) { Player player = server.addPlayer(); SmithingInventory inv = Mockito.mock(SmithingInventory.class); + Mockito.when(inv.getType()).thenReturn(org.bukkit.event.inventory.InventoryType.SMITHING); + Mockito.when(inv.getSize()).thenReturn(4); // MinecraftVersion#isAtLeast always returns true during unit test, so we use the 1.20 layout here. Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { new ItemStack(Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE), tool, material, null }); @@ -84,6 +86,8 @@ private PrepareSmithingEvent mockPrepareSmithingEvent(ItemStack tool, ItemStack Player player = server.addPlayer(); SmithingInventory inv = Mockito.mock(SmithingInventory.class); + Mockito.when(inv.getType()).thenReturn(org.bukkit.event.inventory.InventoryType.SMITHING); + Mockito.when(inv.getSize()).thenReturn(4); MutableObject result = new MutableObject<>(new ItemStack(Material.NETHERITE_PICKAXE)); Mockito.doAnswer(invocation -> { @@ -245,3 +249,4 @@ void testPrepareCanBeUsedInWorkbenchTrue() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSoulboundListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSoulboundListener.java similarity index 73% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSoulboundListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSoulboundListener.java index cfe65281ed..54488bfe45 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestSoulboundListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestSoulboundListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.event.entity.EntityDeathEvent; @@ -11,16 +11,19 @@ import org.junit.jupiter.params.provider.ValueSource; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.magical.SoulboundItem; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.utils.SlimefunUtils; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.entity.PlayerMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.entity.PlayerMock; class TestSoulboundListener { @@ -49,9 +52,9 @@ void testItemDrop(boolean soulbound) { player.getInventory().setItem(6, item); player.setHealth(0); - server.getPluginManager().assertEventFired(EntityDeathEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(EntityDeathEvent.class, event -> { return soulbound != event.getDrops().contains(item); - }); + })); } @ParameterizedTest @@ -71,10 +74,10 @@ void testItemDropIfItemDisabled(boolean enabled) { player.getInventory().setItem(0, item.item()); player.setHealth(0); - server.getPluginManager().assertEventFired(EntityDeathEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(EntityDeathEvent.class, event -> { // If the item is enabled, we don't want it to drop. return enabled == !event.getDrops().contains(item.item()); - }); + })); Slimefun.getRegistry().getEnabledSlimefunItems().remove(soulboundItem); } @@ -89,10 +92,11 @@ void testItemRecover(boolean soulbound) { player.setHealth(0); player.respawn(); - server.getPluginManager().assertEventFired(PlayerRespawnEvent.class, event -> { + assertThat(server.getPluginManager(), hasFiredFilteredEvent(PlayerRespawnEvent.class, event -> { ItemStack stack = player.getInventory().getItem(6); return SlimefunUtils.isItemSimilar(stack, item, true) == soulbound; - }); + })); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestVillagerTradingListener.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestVillagerTradingListener.java similarity index 82% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestVillagerTradingListener.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestVillagerTradingListener.java index 4dc145ba9c..0ae7d09760 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TestVillagerTradingListener.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/listeners/TestVillagerTradingListener.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.listeners; +package io.github.thebusybiscuit.slimefun5.implementation.listeners; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -18,17 +18,17 @@ import org.mockito.Mockito; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.misc.SyntheticEmerald; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; - -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.misc.SyntheticEmerald; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestVillagerTradingListener { @@ -95,3 +95,4 @@ void testTradingWithSyntheticEmerald() { Assertions.assertEquals(Result.ALLOW, event.getResult()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestItemGroups.java similarity index 91% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestItemGroups.java index bdaa4a1d25..b7c6c8f4bf 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemGroups.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestItemGroups.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.registration; +package io.github.thebusybiscuit.slimefun5.implementation.registration; import java.time.LocalDate; import java.time.Month; @@ -14,21 +14,21 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; - -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.groups.FlexItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.groups.LockedItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.groups.SeasonalItemGroup; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestItemGroups { @@ -233,3 +233,4 @@ public boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode layo Assertions.assertThrows(UnsupportedOperationException.class, () -> group.getItems()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemHandlers.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestItemHandlers.java similarity index 83% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemHandlers.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestItemHandlers.java index 945c1082aa..c52553f30f 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestItemHandlers.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestItemHandlers.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.registration; +package io.github.thebusybiscuit.slimefun5.implementation.registration; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; @@ -11,15 +11,15 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.mocks.MockItemHandler; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IncompatibleItemHandlerException; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.BowShootHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.mocks.MockItemHandler; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestItemHandlers { @@ -82,3 +82,4 @@ void testBowShootHandler() { Assertions.assertFalse(exception2.isPresent()); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRechargeableItems.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestRechargeableItems.java similarity index 90% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRechargeableItems.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestRechargeableItems.java index 9dbde56faf..1d6d8370d2 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRechargeableItems.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestRechargeableItems.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.registration; +package io.github.thebusybiscuit.slimefun5.implementation.registration; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; @@ -9,16 +9,16 @@ import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Rechargeable; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.utils.LoreBuilder; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestRechargeableItems { @@ -140,3 +140,4 @@ public float getMaxItemCharge(ItemStack item) { } } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRegistration.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestRegistration.java similarity index 88% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRegistration.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestRegistration.java index 8364ca3409..6c305d9b15 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestRegistration.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestRegistration.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.registration; +package io.github.thebusybiscuit.slimefun5.implementation.registration; import java.io.BufferedReader; import java.io.IOException; @@ -22,17 +22,17 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemState; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; -import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; -import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemState; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.groups.FlexItemGroup; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.setup.PostSetup; +import io.github.thebusybiscuit.slimefun5.implementation.setup.ResearchSetup; +import io.github.thebusybiscuit.slimefun5.implementation.setup.SlimefunItemSetup; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; @TestMethodOrder(value = OrderAnnotation.class) class TestRegistration { @@ -148,3 +148,4 @@ void testForEmptyResearches(@Nonnull Research research) throws IOException { return Slimefun.getRegistry().getResearches().stream().map(Arguments::of); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestSlimefunItemRegistration.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestSlimefunItemRegistration.java similarity index 90% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestSlimefunItemRegistration.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestSlimefunItemRegistration.java index 577bbd0318..dd319312b5 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/registration/TestSlimefunItemRegistration.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/registration/TestSlimefunItemRegistration.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.registration; +package io.github.thebusybiscuit.slimefun5.implementation.registration; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -9,15 +9,15 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.exceptions.IdConflictException; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemState; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.api.exceptions.IdConflictException; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.ItemState; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestSlimefunItemRegistration { @@ -138,3 +138,4 @@ void testHiddenItem() { Assertions.assertFalse(itemGroup.contains(item)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TestArmorTask.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/TestArmorTask.java similarity index 85% rename from src/test/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TestArmorTask.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/TestArmorTask.java index 2d53c865fa..d1d024b140 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TestArmorTask.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/implementation/tasks/TestArmorTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.tasks; +package io.github.thebusybiscuit.slimefun5.implementation.tasks; import java.util.Arrays; import java.util.Locale; @@ -18,18 +18,18 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.RadioactiveItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.test.mocks.MockHazmatSuit; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Radioactivity; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.RadioactiveItem; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.test.mocks.MockHazmatSuit; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; class TestArmorTask { @@ -116,3 +116,4 @@ private static Stream cartesianBooleans() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/storage/backend/TestLegacyBackend.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/storage/backend/TestLegacyBackend.java similarity index 96% rename from src/test/java/io/github/thebusybiscuit/slimefun4/storage/backend/TestLegacyBackend.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/storage/backend/TestLegacyBackend.java index 6fa492b7a0..4d1a097d9b 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/storage/backend/TestLegacyBackend.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/storage/backend/TestLegacyBackend.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.storage.backend; +package io.github.thebusybiscuit.slimefun5.storage.backend; import java.io.File; import java.io.IOException; @@ -22,16 +22,16 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.storage.backend.legacy.LegacyStorage; -import io.github.thebusybiscuit.slimefun4.storage.data.PlayerData; -import io.github.thebusybiscuit.slimefun4.test.TestUtilities; -import io.github.thebusybiscuit.slimefun4.utils.FileUtils; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import io.github.thebusybiscuit.slimefun5.api.gps.Waypoint; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.researches.Research; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.storage.backend.legacy.LegacyStorage; +import io.github.thebusybiscuit.slimefun5.storage.data.PlayerData; +import io.github.thebusybiscuit.slimefun5.test.TestUtilities; +import io.github.thebusybiscuit.slimefun5.utils.FileUtils; class TestLegacyBackend { @@ -426,3 +426,4 @@ private static void setupResearches() { } } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/TestUtilities.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/TestUtilities.java similarity index 81% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/TestUtilities.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/TestUtilities.java index a46d933d54..e12ad5c347 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/TestUtilities.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/TestUtilities.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test; +package io.github.thebusybiscuit.slimefun5.test; import static org.mockito.Mockito.when; @@ -26,17 +26,20 @@ import org.junit.jupiter.api.Assertions; import org.mockito.Mockito; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.block.BlockMock; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.block.BlockMock; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventFilterMatcher.hasFiredFilteredEvent; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.SlimefunBlockPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.test.mocks.MockSlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.events.SlimefunBlockPlaceEvent; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.items.VanillaItem; +import io.github.thebusybiscuit.slimefun5.test.mocks.MockSlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; public final class TestUtilities { @@ -117,8 +120,9 @@ public static Block placeSlimefunBlock(ServerMock server, ItemStack item, World ); server.getPluginManager().callEvent(blockPlaceEvent); - server.getPluginManager().assertEventFired(SlimefunBlockPlaceEvent.class, e -> true); + assertThat(server.getPluginManager(), hasFiredFilteredEvent(SlimefunBlockPlaceEvent.class, e -> true)); return block; } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/InventoryViewWrapper.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/InventoryViewWrapper.java similarity index 85% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/InventoryViewWrapper.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/InventoryViewWrapper.java index 0b49c5ed0b..4adb0ddd21 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/InventoryViewWrapper.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/InventoryViewWrapper.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.test.mocks; +package io.github.thebusybiscuit.slimefun5.test.mocks; -import be.seeseemelk.mockbukkit.inventory.InventoryViewMock; +import org.mockbukkit.mockbukkit.inventory.InventoryViewMock; import org.bukkit.entity.HumanEntity; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; @@ -25,21 +25,19 @@ public class InventoryViewWrapper extends InventoryViewMock { private InventoryViewWrapper(HumanEntity player, - String name, Inventory top, Inventory bottom, InventoryType type) { - super(player, name, top, bottom, type); + super(player, top, bottom, type); } @Nonnull public static InventoryViewWrapper wrap(@Nonnull InventoryView inventoryView) { HumanEntity player = inventoryView.getPlayer(); - String name = inventoryView.getTitle(); Inventory top = inventoryView.getTopInventory(); Inventory bottom = inventoryView.getBottomInventory(); InventoryType inventoryType = inventoryView.getType(); - return new InventoryViewWrapper(player, name, top, bottom, inventoryType); + return new InventoryViewWrapper(player, top, bottom, inventoryType); } @Override @@ -57,3 +55,4 @@ public void setItem(int slot, @Nullable ItemStack item) { } } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockDamageable.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockDamageable.java similarity index 69% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockDamageable.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockDamageable.java index 9f52e8ffe0..0b020d881e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockDamageable.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockDamageable.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test.mocks; +package io.github.thebusybiscuit.slimefun5.test.mocks; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -7,11 +7,11 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.DamageableItem; public class MockDamageable extends SlimefunItem implements DamageableItem { @@ -33,3 +33,4 @@ public void damageItem(@Nonnull Player p, @Nullable ItemStack item) { DamageableItem.super.damageItem(p, item); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockHazmatSuit.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockHazmatSuit.java similarity index 66% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockHazmatSuit.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockHazmatSuit.java index 93501cbc81..3601b3c031 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockHazmatSuit.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockHazmatSuit.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test.mocks; +package io.github.thebusybiscuit.slimefun5.test.mocks; import javax.annotation.ParametersAreNonnullByDefault; @@ -6,12 +6,12 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun5.core.attributes.ProtectiveArmor; +import io.github.thebusybiscuit.slimefun5.implementation.items.armor.SlimefunArmorPiece; public class MockHazmatSuit extends SlimefunArmorPiece implements ProtectiveArmor { @@ -36,3 +36,4 @@ public NamespacedKey getArmorSetId() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockItemHandler.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockItemHandler.java similarity index 58% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockItemHandler.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockItemHandler.java index fef1189327..6be319c4b8 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockItemHandler.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockItemHandler.java @@ -1,6 +1,6 @@ -package io.github.thebusybiscuit.slimefun4.test.mocks; +package io.github.thebusybiscuit.slimefun5.test.mocks; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun5.api.items.ItemHandler; public class MockItemHandler implements ItemHandler { @@ -10,3 +10,4 @@ public Class getIdentifier() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockNetwork.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockNetwork.java similarity index 79% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockNetwork.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockNetwork.java index 7a47b92c3c..0271ff733e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockNetwork.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockNetwork.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test.mocks; +package io.github.thebusybiscuit.slimefun5.test.mocks; import java.util.Map; @@ -6,9 +6,9 @@ import org.bukkit.Location; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent; -import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; +import io.github.thebusybiscuit.slimefun5.api.network.Network; +import io.github.thebusybiscuit.slimefun5.api.network.NetworkComponent; +import io.github.thebusybiscuit.slimefun5.core.networks.NetworkManager; public class MockNetwork extends Network { @@ -41,4 +41,4 @@ public void onClassificationChange(Location l, NetworkComponent from, NetworkCom // Do nothing } -} \ No newline at end of file +} diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockProfile.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockProfile.java similarity index 69% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockProfile.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockProfile.java index 9a7837d00a..5430f9b017 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockProfile.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockProfile.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test.mocks; +package io.github.thebusybiscuit.slimefun5.test.mocks; import java.util.HashMap; import java.util.Set; @@ -7,8 +7,8 @@ import org.bukkit.OfflinePlayer; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.storage.data.PlayerData; +import io.github.thebusybiscuit.slimefun5.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun5.storage.data.PlayerData; public class MockProfile extends PlayerProfile { @@ -20,3 +20,4 @@ public MockProfile(@Nonnull OfflinePlayer p, @Nonnull PlayerData data) { super(p, data); } } + diff --git a/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockSlimefunItem.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockSlimefunItem.java new file mode 100644 index 0000000000..970172d82f --- /dev/null +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/mocks/MockSlimefunItem.java @@ -0,0 +1,17 @@ +package io.github.thebusybiscuit.slimefun5.test.mocks; + +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; + +public class MockSlimefunItem extends SlimefunItem { + + public MockSlimefunItem(ItemGroup itemGroup, ItemStack item, String id) { + super(itemGroup, new SlimefunItemStack(id, item), RecipeType.NULL, new ItemStack[9]); + } + +} + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/presets/SlimefunItemTest.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/presets/SlimefunItemTest.java similarity index 82% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/presets/SlimefunItemTest.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/presets/SlimefunItemTest.java index 36218a9506..5163d7c059 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/presets/SlimefunItemTest.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/presets/SlimefunItemTest.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test.presets; +package io.github.thebusybiscuit.slimefun5.test.presets; import javax.annotation.ParametersAreNonnullByDefault; @@ -10,13 +10,13 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.events.PlayerRightClickEvent; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemConsumptionHandler; +import io.github.thebusybiscuit.slimefun5.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.block.BlockMock; +import org.mockbukkit.mockbukkit.block.BlockMock; /** * This is a convenient interface for us to use in unit test classes @@ -59,8 +59,9 @@ default void simulateRightClickBlock(Player player, T item, ItemStack heldItem, @ParametersAreNonnullByDefault default void simulateConsumption(Player player, T item) { - PlayerItemConsumeEvent event = new PlayerItemConsumeEvent(player, item.getItem().clone()); + PlayerItemConsumeEvent event = new PlayerItemConsumeEvent(player, item.getItem().clone(), EquipmentSlot.HAND); item.callItemHandler(ItemConsumptionHandler.class, handler -> handler.onConsume(event, player, event.getItem())); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/NamespacedKeyProvider.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/NamespacedKeyProvider.java similarity index 94% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/NamespacedKeyProvider.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/NamespacedKeyProvider.java index de79406900..e629dd04ae 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/NamespacedKeyProvider.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/NamespacedKeyProvider.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test.providers; +package io.github.thebusybiscuit.slimefun5.test.providers; import java.util.Arrays; import java.util.stream.Stream; @@ -30,3 +30,4 @@ public Stream provideArguments(ExtensionContext context) th return Arrays.stream(keys).map(key -> new NamespacedKey(plugin, key)).map(Arguments::of); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/NamespacedKeySource.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/NamespacedKeySource.java similarity index 88% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/NamespacedKeySource.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/NamespacedKeySource.java index 6fc55ef25b..63c20ee283 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/NamespacedKeySource.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/NamespacedKeySource.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test.providers; +package io.github.thebusybiscuit.slimefun5.test.providers; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -19,3 +19,4 @@ String[] keys(); } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/SlimefunItemsProvider.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/SlimefunItemsProvider.java similarity index 84% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/SlimefunItemsProvider.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/SlimefunItemsProvider.java index 3b084dcf3a..e525de98d4 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/SlimefunItemsProvider.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/SlimefunItemsProvider.java @@ -1,18 +1,18 @@ -package io.github.thebusybiscuit.slimefun4.test.providers; +package io.github.thebusybiscuit.slimefun5.test.providers; import java.lang.reflect.Field; import java.util.Arrays; import java.util.stream.Stream; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; import org.bukkit.inventory.ItemStack; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.ArgumentsProvider; import org.junit.jupiter.params.support.AnnotationConsumer; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun5.implementation.SlimefunItems; public class SlimefunItemsProvider implements ArgumentsProvider, AnnotationConsumer { @@ -41,3 +41,4 @@ private ItemStack getAsItemStack(String fieldName) { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/SlimefunItemsSource.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/SlimefunItemsSource.java similarity index 88% rename from src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/SlimefunItemsSource.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/SlimefunItemsSource.java index 5df89dc5e8..09831f8516 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/providers/SlimefunItemsSource.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/test/providers/SlimefunItemsSource.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.test.providers; +package io.github.thebusybiscuit.slimefun5.test.providers; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -17,3 +17,4 @@ String[] items(); } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestChargeUtils.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestChargeUtils.java similarity index 95% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestChargeUtils.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestChargeUtils.java index 1f91b38415..df4166a925 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestChargeUtils.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestChargeUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.Collections; @@ -13,9 +13,9 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestChargeUtils { @@ -89,3 +89,4 @@ void testGetCharge() { Assertions.assertThrows(IllegalArgumentException.class, () -> ChargeUtils.getCharge(null)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestChatUtils.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestChatUtils.java similarity index 96% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestChatUtils.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestChatUtils.java index 794b02e4b5..46c85a00a2 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestChatUtils.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestChatUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import org.bukkit.ChatColor; import org.junit.jupiter.api.Assertions; @@ -44,3 +44,4 @@ void testPluralization() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestFireworkUtils.java similarity index 91% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestFireworkUtils.java index a32183d663..559bcb3f66 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestFireworkUtils.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestFireworkUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.List; import java.util.stream.Stream; @@ -17,8 +17,8 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.WorldMock; +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.world.WorldMock; class TestFireworkUtils { @@ -55,3 +55,4 @@ private static Stream getColors() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestHeadTextures.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestHeadTextures.java similarity index 92% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestHeadTextures.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestHeadTextures.java index 162b951d6c..3a380134dd 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestHeadTextures.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestHeadTextures.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.HashSet; import java.util.Set; @@ -24,3 +24,4 @@ void testForDuplicates() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestInfiniteBlockGenerators.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestInfiniteBlockGenerators.java similarity index 89% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestInfiniteBlockGenerators.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestInfiniteBlockGenerators.java index 5d0d2fec68..3e29dcc0da 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestInfiniteBlockGenerators.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestInfiniteBlockGenerators.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.Arrays; import java.util.stream.Stream; @@ -18,11 +18,14 @@ import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; -import be.seeseemelk.mockbukkit.ServerMock; -import be.seeseemelk.mockbukkit.WorldMock; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockbukkit.mockbukkit.matcher.plugin.PluginManagerFiredEventClassMatcher.hasFiredEventInstance; + +import org.mockbukkit.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.ServerMock; +import org.mockbukkit.mockbukkit.world.WorldMock; class TestInfiniteBlockGenerators { @@ -70,7 +73,7 @@ void testValidCobblestoneGenerator(BlockFace water, BlockFace lava) { Assertions.assertTrue(generator.test(block)); Assertions.assertNotNull(generator.callEvent(block)); - server.getPluginManager().assertEventFired(BlockFormEvent.class); + assertThat(server.getPluginManager(), hasFiredEventInstance(BlockFormEvent.class)); server.getPluginManager().clearEvents(); Assertions.assertEquals(generator, InfiniteBlockGenerator.findAt(block)); @@ -112,7 +115,7 @@ void testValidBasaltGenerator(BlockFace ice, BlockFace lava) { Assertions.assertTrue(generator.test(block)); Assertions.assertNotNull(generator.callEvent(block)); - server.getPluginManager().assertEventFired(BlockFormEvent.class); + assertThat(server.getPluginManager(), hasFiredEventInstance(BlockFormEvent.class)); server.getPluginManager().clearEvents(); Assertions.assertEquals(generator, InfiniteBlockGenerator.findAt(block)); @@ -153,7 +156,7 @@ void testValidStoneGenerator(BlockFace water) { Assertions.assertTrue(generator.test(block)); Assertions.assertNotNull(generator.callEvent(block)); - server.getPluginManager().assertEventFired(BlockFormEvent.class); + assertThat(server.getPluginManager(), hasFiredEventInstance(BlockFormEvent.class)); server.getPluginManager().clearEvents(); Assertions.assertEquals(generator, InfiniteBlockGenerator.findAt(block)); @@ -165,3 +168,4 @@ private static Stream provideFaces() { return stream.flatMap(a -> Arrays.stream(faces).filter(b -> a != b).map(b -> Arguments.of(a, b))); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestItemStackWrapper.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestItemStackWrapper.java similarity index 96% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestItemStackWrapper.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestItemStackWrapper.java index 76aaa5b944..09d07f3866 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestItemStackWrapper.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestItemStackWrapper.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.Arrays; import java.util.List; @@ -14,10 +14,10 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.itemstack.ItemStackWrapper; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestItemStackWrapper { @@ -139,3 +139,4 @@ private void assertWrapped(@Nullable ItemStack expected, @Nullable ItemStack act } } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestLoreComparison.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestLoreComparison.java similarity index 95% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestLoreComparison.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestLoreComparison.java index 7441f22502..afa315c9d1 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestLoreComparison.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestLoreComparison.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.util.Arrays; import java.util.List; @@ -10,9 +10,9 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestLoreComparison { @@ -110,3 +110,4 @@ void testIgnoredElementsNotEqualLists() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestMinecraftVersion.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestMinecraftVersion.java similarity index 75% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestMinecraftVersion.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestMinecraftVersion.java index 74a2622cce..dcbb138494 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestMinecraftVersion.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestMinecraftVersion.java @@ -1,10 +1,10 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; class TestMinecraftVersion { @@ -14,10 +14,12 @@ void testMatches() { Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_16.isMinecraftVersion(16, -1)); Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_17.isMinecraftVersion(17, -1)); Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20_5.isMinecraftVersion(20, 5)); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21_4.isMinecraftVersion(21, 4)); Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_17.isMinecraftVersion(16, -1)); Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_16.isMinecraftVersion(0, -1)); Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_20_5.isMinecraftVersion(20, 4)); + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_21_4.isMinecraftVersion(21, 3)); } @Test @@ -29,6 +31,17 @@ void testMatchesMinor() { Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20.isMinecraftVersion(20, 4)); Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20_5.isMinecraftVersion(20, 6)); + // 1.21.x covers 1.21.0 through 1.21.3 + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21.isMinecraftVersion(21, 0)); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21.isMinecraftVersion(21, 3)); + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_21.isMinecraftVersion(21, 4)); + + // 1.21.4+ covers 1.21.4 and above + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21_4.isMinecraftVersion(21, 4)); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21_4.isMinecraftVersion(21, 5)); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21_4.isMinecraftVersion(21, 11)); + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_21_4.isMinecraftVersion(21, 3)); + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_20.isMinecraftVersion(20, 5)); Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_16.isMinecraftVersion(17, 1)); Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_20_5.isMinecraftVersion(20, 4)); @@ -42,8 +55,11 @@ void testAtLeast() { Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_17.isAtLeast(MinecraftVersion.MINECRAFT_1_17)); Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20.isAtLeast(MinecraftVersion.MINECRAFT_1_20)); Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20_5.isAtLeast(MinecraftVersion.MINECRAFT_1_20)); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21_4.isAtLeast(MinecraftVersion.MINECRAFT_1_21)); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21_4.isAtLeast(MinecraftVersion.MINECRAFT_1_21_4)); Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_17.isAtLeast(MinecraftVersion.MINECRAFT_1_18)); + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_21.isAtLeast(MinecraftVersion.MINECRAFT_1_21_4)); } @Test @@ -82,6 +98,11 @@ void testIsBeforeMinor() { Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_20_5.isBefore(20, 4)); Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_20_5.isBefore(20, 5)); Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_20_5.isBefore(20, 6)); + + // 1.21.4+ version boundary tests + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_21_4.isBefore(21, 3)); + Assertions.assertFalse(MinecraftVersion.MINECRAFT_1_21_4.isBefore(21, 4)); + Assertions.assertTrue(MinecraftVersion.MINECRAFT_1_21_4.isBefore(21, 5)); } @Test @@ -101,3 +122,4 @@ void testLowestSupportedVersion() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestNumberUtils.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestNumberUtils.java similarity index 99% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestNumberUtils.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestNumberUtils.java index cb6d40a236..ff1c5a34da 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestNumberUtils.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestNumberUtils.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.time.LocalDateTime; @@ -117,3 +117,4 @@ void testLimitedAddition() { Assertions.assertEquals(-1000, NumberUtils.limitedAddition(-2, -999, -1000, 1000)); } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestSoulboundItem.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestSoulboundItem.java similarity index 86% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestSoulboundItem.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestSoulboundItem.java index 391fd6c2e0..aa3a56fe86 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestSoulboundItem.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestSoulboundItem.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -10,14 +10,14 @@ import org.junit.jupiter.api.Test; import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun5.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun5.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun5.core.attributes.Soulbound; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestSoulboundItem { @@ -98,3 +98,4 @@ public SoulboundMock(ItemGroup itemGroup) { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestWikiResource.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestWikiResource.java similarity index 96% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestWikiResource.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestWikiResource.java index 1f28718950..aaff0375fb 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/TestWikiResource.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/TestWikiResource.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils; +package io.github.thebusybiscuit.slimefun5.utils; import java.io.BufferedReader; import java.io.IOException; @@ -37,3 +37,4 @@ void testWikiJson() throws IOException { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMap.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMap.java similarity index 94% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMap.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMap.java index 756c5044cf..f7501d90f9 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMap.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMap.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.biomes; +package io.github.thebusybiscuit.slimefun5.utils.biomes; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -13,10 +13,10 @@ import com.google.gson.JsonElement; -import io.github.thebusybiscuit.slimefun4.api.exceptions.BiomeMapException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.exceptions.BiomeMapException; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestBiomeMap { @@ -113,3 +113,4 @@ void testManualBiomeMap() { } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapCompatibility.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMapCompatibility.java similarity index 90% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapCompatibility.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMapCompatibility.java index d7ffca7d79..afa8fcff0d 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapCompatibility.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMapCompatibility.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.biomes; +package io.github.thebusybiscuit.slimefun5.utils.biomes; import java.io.BufferedReader; import java.io.IOException; @@ -25,11 +25,11 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.JsonUtils; +import io.github.thebusybiscuit.slimefun5.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.utils.JsonUtils; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; /** * This test checks if biome maps work across multiple versions of Minecraft. @@ -107,7 +107,8 @@ void testCompatibilities(String name, MinecraftVersion version) { MinecraftVersion.MINECRAFT_1_18, MinecraftVersion.MINECRAFT_1_19, MinecraftVersion.MINECRAFT_1_20, - MinecraftVersion.MINECRAFT_1_21 + MinecraftVersion.MINECRAFT_1_21, + MinecraftVersion.MINECRAFT_1_21_4 }); testCases.put("oil_v1.16", new MinecraftVersion[] { @@ -119,7 +120,8 @@ void testCompatibilities(String name, MinecraftVersion version) { MinecraftVersion.MINECRAFT_1_18, MinecraftVersion.MINECRAFT_1_19, MinecraftVersion.MINECRAFT_1_20, - MinecraftVersion.MINECRAFT_1_21 + MinecraftVersion.MINECRAFT_1_21, + MinecraftVersion.MINECRAFT_1_21_4 }); testCases.put("salt_v1.16", new MinecraftVersion[] { @@ -131,7 +133,8 @@ void testCompatibilities(String name, MinecraftVersion version) { MinecraftVersion.MINECRAFT_1_18, MinecraftVersion.MINECRAFT_1_19, MinecraftVersion.MINECRAFT_1_20, - MinecraftVersion.MINECRAFT_1_21 + MinecraftVersion.MINECRAFT_1_21, + MinecraftVersion.MINECRAFT_1_21_4 }); testCases.put("uranium_v1.16", new MinecraftVersion[] { @@ -146,7 +149,8 @@ void testCompatibilities(String name, MinecraftVersion version) { MinecraftVersion.MINECRAFT_1_18, MinecraftVersion.MINECRAFT_1_19, MinecraftVersion.MINECRAFT_1_20, - MinecraftVersion.MINECRAFT_1_21 + MinecraftVersion.MINECRAFT_1_21, + MinecraftVersion.MINECRAFT_1_21_4 }); // @formatter:on @@ -185,3 +189,4 @@ private void checkBiomes(JsonArray biomes, JsonArray allBiomes, MinecraftVersion } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapParser.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMapParser.java similarity index 95% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapParser.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMapParser.java index 0aa6bf9c81..62ecef8312 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/biomes/TestBiomeMapParser.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/biomes/TestBiomeMapParser.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.biomes; +package io.github.thebusybiscuit.slimefun5.utils.biomes; import javax.annotation.ParametersAreNonnullByDefault; @@ -14,10 +14,10 @@ import com.google.gson.JsonElement; -import io.github.thebusybiscuit.slimefun4.api.exceptions.BiomeMapException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.exceptions.BiomeMapException; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestBiomeMapParser { @@ -133,3 +133,4 @@ private void assertMisconfiguration(BiomeDataConverter function, String j } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/tags/TestSlimefunTags.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/tags/TestSlimefunTags.java similarity index 95% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/tags/TestSlimefunTags.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/tags/TestSlimefunTags.java index 0e9fe8e3f6..2dad3bf82e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/tags/TestSlimefunTags.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/tags/TestSlimefunTags.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.tags; +package io.github.thebusybiscuit.slimefun5.utils.tags; import java.util.HashSet; import java.util.Set; @@ -16,10 +16,10 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestSlimefunTags { @@ -157,3 +157,4 @@ private boolean isCyclic(Set visiting, Set visited, Sl } } + diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/tags/TestTagParser.java b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/tags/TestTagParser.java similarity index 93% rename from src/test/java/io/github/thebusybiscuit/slimefun4/utils/tags/TestTagParser.java rename to core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/tags/TestTagParser.java index 68f3748715..0e86a5181a 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/utils/tags/TestTagParser.java +++ b/core/src/test/java/io/github/thebusybiscuit/slimefun5/utils/tags/TestTagParser.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.utils.tags; +package io.github.thebusybiscuit.slimefun5.utils.tags; import javax.annotation.Nonnull; @@ -9,10 +9,10 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun5.api.exceptions.TagMisconfigurationException; +import io.github.thebusybiscuit.slimefun5.implementation.Slimefun; -import be.seeseemelk.mockbukkit.MockBukkit; +import org.mockbukkit.mockbukkit.MockBukkit; class TestTagParser { @@ -104,3 +104,4 @@ private void assertMisconfiguration(@Nonnull String json) { } } + diff --git a/src/test/resources/biomes/1.14.x.json b/core/src/test/resources/biomes/1.14.x.json similarity index 86% rename from src/test/resources/biomes/1.14.x.json rename to core/src/test/resources/biomes/1.14.x.json index 8ee6093581..0469824124 100644 --- a/src/test/resources/biomes/1.14.x.json +++ b/core/src/test/resources/biomes/1.14.x.json @@ -16,23 +16,23 @@ "minecraft:mushroom_fields", "minecraft:mushroom_field_shore", "minecraft:beach", - "minecraft:desert_hills", - "minecraft:wooded_hills", - "minecraft:taiga_hills", + , + , + , "minecraft:mountain_edge", "minecraft:jungle", - "minecraft:jungle_hills", + , "minecraft:jungle_edge", "minecraft:deep_ocean", "minecraft:stone_shore", "minecraft:snowy_beach", "minecraft:birch_forest", - "minecraft:birch_forest_hills", + , "minecraft:dark_forest", "minecraft:snowy_taiga", - "minecraft:snowy_taiga_hills", + , "minecraft:giant_tree_taiga", - "minecraft:giant_tree_taiga_hills", + , "minecraft:wooded_mountains", "minecraft:savanna", "minecraft:savanna_plateau", @@ -56,13 +56,13 @@ "minecraft:gravelly_mountains", "minecraft:flower_forest", "minecraft:taiga_mountains", - "minecraft:swamp_hills", + , "minecraft:ice_spikes", "minecraft:modified_jungle", "minecraft:modified_jungle_edge", "minecraft:tall_birch_forest", - "minecraft:tall_birch_hills", - "minecraft:dark_forest_hills", + , + , "minecraft:snowy_taiga_mountains", "minecraft:giant_spruce_taiga", "minecraft:giant_spruce_taiga_hills", diff --git a/src/test/resources/biomes/1.15.x.json b/core/src/test/resources/biomes/1.15.x.json similarity index 86% rename from src/test/resources/biomes/1.15.x.json rename to core/src/test/resources/biomes/1.15.x.json index 8ee6093581..0469824124 100644 --- a/src/test/resources/biomes/1.15.x.json +++ b/core/src/test/resources/biomes/1.15.x.json @@ -16,23 +16,23 @@ "minecraft:mushroom_fields", "minecraft:mushroom_field_shore", "minecraft:beach", - "minecraft:desert_hills", - "minecraft:wooded_hills", - "minecraft:taiga_hills", + , + , + , "minecraft:mountain_edge", "minecraft:jungle", - "minecraft:jungle_hills", + , "minecraft:jungle_edge", "minecraft:deep_ocean", "minecraft:stone_shore", "minecraft:snowy_beach", "minecraft:birch_forest", - "minecraft:birch_forest_hills", + , "minecraft:dark_forest", "minecraft:snowy_taiga", - "minecraft:snowy_taiga_hills", + , "minecraft:giant_tree_taiga", - "minecraft:giant_tree_taiga_hills", + , "minecraft:wooded_mountains", "minecraft:savanna", "minecraft:savanna_plateau", @@ -56,13 +56,13 @@ "minecraft:gravelly_mountains", "minecraft:flower_forest", "minecraft:taiga_mountains", - "minecraft:swamp_hills", + , "minecraft:ice_spikes", "minecraft:modified_jungle", "minecraft:modified_jungle_edge", "minecraft:tall_birch_forest", - "minecraft:tall_birch_hills", - "minecraft:dark_forest_hills", + , + , "minecraft:snowy_taiga_mountains", "minecraft:giant_spruce_taiga", "minecraft:giant_spruce_taiga_hills", diff --git a/src/test/resources/biomes/1.16.x.json b/core/src/test/resources/biomes/1.16.x.json similarity index 86% rename from src/test/resources/biomes/1.16.x.json rename to core/src/test/resources/biomes/1.16.x.json index 5a9050dafe..ba3df741c2 100644 --- a/src/test/resources/biomes/1.16.x.json +++ b/core/src/test/resources/biomes/1.16.x.json @@ -16,23 +16,23 @@ "minecraft:mushroom_fields", "minecraft:mushroom_field_shore", "minecraft:beach", - "minecraft:desert_hills", - "minecraft:wooded_hills", - "minecraft:taiga_hills", + , + , + , "minecraft:mountain_edge", "minecraft:jungle", - "minecraft:jungle_hills", + , "minecraft:jungle_edge", "minecraft:deep_ocean", "minecraft:stone_shore", "minecraft:snowy_beach", "minecraft:birch_forest", - "minecraft:birch_forest_hills", + , "minecraft:dark_forest", "minecraft:snowy_taiga", - "minecraft:snowy_taiga_hills", + , "minecraft:giant_tree_taiga", - "minecraft:giant_tree_taiga_hills", + , "minecraft:wooded_mountains", "minecraft:savanna", "minecraft:savanna_plateau", @@ -56,13 +56,13 @@ "minecraft:gravelly_mountains", "minecraft:flower_forest", "minecraft:taiga_mountains", - "minecraft:swamp_hills", + , "minecraft:ice_spikes", "minecraft:modified_jungle", "minecraft:modified_jungle_edge", "minecraft:tall_birch_forest", - "minecraft:tall_birch_hills", - "minecraft:dark_forest_hills", + , + , "minecraft:snowy_taiga_mountains", "minecraft:giant_spruce_taiga", "minecraft:giant_spruce_taiga_hills", diff --git a/src/test/resources/biomes/1.17.x.json b/core/src/test/resources/biomes/1.17.x.json similarity index 87% rename from src/test/resources/biomes/1.17.x.json rename to core/src/test/resources/biomes/1.17.x.json index 8797f76d58..6bac163e06 100644 --- a/src/test/resources/biomes/1.17.x.json +++ b/core/src/test/resources/biomes/1.17.x.json @@ -16,23 +16,23 @@ "minecraft:mushroom_fields", "minecraft:mushroom_field_shore", "minecraft:beach", - "minecraft:desert_hills", - "minecraft:wooded_hills", - "minecraft:taiga_hills", + , + , + , "minecraft:mountain_edge", "minecraft:jungle", - "minecraft:jungle_hills", + , "minecraft:jungle_edge", "minecraft:deep_ocean", "minecraft:stone_shore", "minecraft:snowy_beach", "minecraft:birch_forest", - "minecraft:birch_forest_hills", + , "minecraft:dark_forest", "minecraft:snowy_taiga", - "minecraft:snowy_taiga_hills", + , "minecraft:giant_tree_taiga", - "minecraft:giant_tree_taiga_hills", + , "minecraft:wooded_mountains", "minecraft:savanna", "minecraft:savanna_plateau", @@ -56,13 +56,13 @@ "minecraft:gravelly_mountains", "minecraft:flower_forest", "minecraft:taiga_mountains", - "minecraft:swamp_hills", + , "minecraft:ice_spikes", "minecraft:modified_jungle", "minecraft:modified_jungle_edge", "minecraft:tall_birch_forest", - "minecraft:tall_birch_hills", - "minecraft:dark_forest_hills", + , + , "minecraft:snowy_taiga_mountains", "minecraft:giant_spruce_taiga", "minecraft:giant_spruce_taiga_hills", diff --git a/src/test/resources/biomes/1.18.x.json b/core/src/test/resources/biomes/1.18.x.json similarity index 100% rename from src/test/resources/biomes/1.18.x.json rename to core/src/test/resources/biomes/1.18.x.json diff --git a/src/test/resources/biomes/1.19.x.json b/core/src/test/resources/biomes/1.19.x.json similarity index 100% rename from src/test/resources/biomes/1.19.x.json rename to core/src/test/resources/biomes/1.19.x.json diff --git a/src/test/resources/biomes/1.20.5+.json b/core/src/test/resources/biomes/1.20.5+.json similarity index 100% rename from src/test/resources/biomes/1.20.5+.json rename to core/src/test/resources/biomes/1.20.5+.json diff --git a/src/test/resources/biomes/1.20.x.json b/core/src/test/resources/biomes/1.20.x.json similarity index 100% rename from src/test/resources/biomes/1.20.x.json rename to core/src/test/resources/biomes/1.20.x.json diff --git a/core/src/test/resources/biomes/1.21.4+.json b/core/src/test/resources/biomes/1.21.4+.json new file mode 100644 index 0000000000..643e7e18ea --- /dev/null +++ b/core/src/test/resources/biomes/1.21.4+.json @@ -0,0 +1,68 @@ +[ + "minecraft:badlands", + "minecraft:bamboo_jungle", + "minecraft:basalt_deltas", + "minecraft:beach", + "minecraft:birch_forest", + "minecraft:cherry_grove", + "minecraft:cold_ocean", + "minecraft:crimson_forest", + "minecraft:custom", + "minecraft:dark_forest", + "minecraft:deep_cold_ocean", + "minecraft:deep_dark", + "minecraft:deep_frozen_ocean", + "minecraft:deep_lukewarm_ocean", + "minecraft:deep_ocean", + "minecraft:desert", + "minecraft:dripstone_caves", + "minecraft:end_barrens", + "minecraft:end_highlands", + "minecraft:end_midlands", + "minecraft:eroded_badlands", + "minecraft:flower_forest", + "minecraft:forest", + "minecraft:frozen_ocean", + "minecraft:frozen_peaks", + "minecraft:frozen_river", + "minecraft:grove", + "minecraft:ice_spikes", + "minecraft:jagged_peaks", + "minecraft:jungle", + "minecraft:lukewarm_ocean", + "minecraft:lush_caves", + "minecraft:mangrove_swamp", + "minecraft:meadow", + "minecraft:mushroom_fields", + "minecraft:nether_wastes", + "minecraft:ocean", + "minecraft:old_growth_birch_forest", + "minecraft:old_growth_pine_taiga", + "minecraft:old_growth_spruce_taiga", + "minecraft:pale_garden", + "minecraft:plains", + "minecraft:river", + "minecraft:savanna", + "minecraft:savanna_plateau", + "minecraft:small_end_islands", + "minecraft:snowy_beach", + "minecraft:snowy_plains", + "minecraft:snowy_slopes", + "minecraft:snowy_taiga", + "minecraft:soul_sand_valley", + "minecraft:sparse_jungle", + "minecraft:stony_peaks", + "minecraft:stony_shore", + "minecraft:sunflower_plains", + "minecraft:swamp", + "minecraft:taiga", + "minecraft:the_end", + "minecraft:the_void", + "minecraft:warm_ocean", + "minecraft:warped_forest", + "minecraft:windswept_forest", + "minecraft:windswept_gravelly_hills", + "minecraft:windswept_hills", + "minecraft:windswept_savanna", + "minecraft:wooded_badlands" +] diff --git a/src/test/resources/biomes/1.21.x.json b/core/src/test/resources/biomes/1.21.x.json similarity index 100% rename from src/test/resources/biomes/1.21.x.json rename to core/src/test/resources/biomes/1.21.x.json diff --git a/core/src/test/resources/biomes/1.26.x.json b/core/src/test/resources/biomes/1.26.x.json new file mode 100644 index 0000000000..643e7e18ea --- /dev/null +++ b/core/src/test/resources/biomes/1.26.x.json @@ -0,0 +1,68 @@ +[ + "minecraft:badlands", + "minecraft:bamboo_jungle", + "minecraft:basalt_deltas", + "minecraft:beach", + "minecraft:birch_forest", + "minecraft:cherry_grove", + "minecraft:cold_ocean", + "minecraft:crimson_forest", + "minecraft:custom", + "minecraft:dark_forest", + "minecraft:deep_cold_ocean", + "minecraft:deep_dark", + "minecraft:deep_frozen_ocean", + "minecraft:deep_lukewarm_ocean", + "minecraft:deep_ocean", + "minecraft:desert", + "minecraft:dripstone_caves", + "minecraft:end_barrens", + "minecraft:end_highlands", + "minecraft:end_midlands", + "minecraft:eroded_badlands", + "minecraft:flower_forest", + "minecraft:forest", + "minecraft:frozen_ocean", + "minecraft:frozen_peaks", + "minecraft:frozen_river", + "minecraft:grove", + "minecraft:ice_spikes", + "minecraft:jagged_peaks", + "minecraft:jungle", + "minecraft:lukewarm_ocean", + "minecraft:lush_caves", + "minecraft:mangrove_swamp", + "minecraft:meadow", + "minecraft:mushroom_fields", + "minecraft:nether_wastes", + "minecraft:ocean", + "minecraft:old_growth_birch_forest", + "minecraft:old_growth_pine_taiga", + "minecraft:old_growth_spruce_taiga", + "minecraft:pale_garden", + "minecraft:plains", + "minecraft:river", + "minecraft:savanna", + "minecraft:savanna_plateau", + "minecraft:small_end_islands", + "minecraft:snowy_beach", + "minecraft:snowy_plains", + "minecraft:snowy_slopes", + "minecraft:snowy_taiga", + "minecraft:soul_sand_valley", + "minecraft:sparse_jungle", + "minecraft:stony_peaks", + "minecraft:stony_shore", + "minecraft:sunflower_plains", + "minecraft:swamp", + "minecraft:taiga", + "minecraft:the_end", + "minecraft:the_void", + "minecraft:warm_ocean", + "minecraft:warped_forest", + "minecraft:windswept_forest", + "minecraft:windswept_gravelly_hills", + "minecraft:windswept_hills", + "minecraft:windswept_savanna", + "minecraft:wooded_badlands" +] diff --git a/docs/adr/0001-storage-layer.md b/docs/adr/0001-storage-layer.md index 0809ed04a2..fa00afae8a 100644 --- a/docs/adr/0001-storage-layer.md +++ b/docs/adr/0001-storage-layer.md @@ -35,7 +35,7 @@ We want to create a new storage layer abstraction and implementations which will be backwards-compatible but open up new ways of storing data within Slimefun. The end end goal is we can quickly and easily support new storage backends (such as binary storage, SQL, etc.) for things like -[PlayerProfile](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java), [BlockStorage](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java), etc. +[PlayerProfile](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerProfile.java), [BlockStorage](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java), etc. We also want to be generally more efficient in the way we save and load data. Today, we load way more than is required. @@ -56,13 +56,13 @@ as possible. There is a new interface called [`Storage`](TBD) which is what all storage backends will implement. This will have methods for loading and saving things like -[`PlayerProfile`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java) and [`BlockStorage`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java). +[`PlayerProfile`](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerProfile.java) and [`BlockStorage`](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java). Then, backends will implement these (e.g. [`LegacyStorageBackend`](TBD) (today's YAML situation)) in order to support these functions. Not all storage backends are required support each data type. -e.g. SQL may not support [`BlockStorage`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java). +e.g. SQL may not support [`BlockStorage`](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java). ## Addons @@ -86,29 +86,29 @@ Phases do not (and very likely will not) be done within a single PR. They will a The current plan looks like this: -* Phase 1 - Implement legacy data backend for [`PlayerProfile`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java). +* Phase 1 - Implement legacy data backend for [`PlayerProfile`](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerProfile.java). * We want to load player data using the new storage layer with the current data system. * We'll want to monitor for any possible issues and generally refine how this system should look -* Phase 2 - Implement new experimental binary backend for [`PlayerProfile`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java). +* Phase 2 - Implement new experimental binary backend for [`PlayerProfile`](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerProfile.java). * Create a new backend for binary storage * Implement in an experimental capacity and allow users to opt-in * Provide a warning that this is **experimental** and there will be bugs. * Implement new metric for storage backend being used -* Phase 3 - Mark the new backend as stable for [`PlayerProfile`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java). +* Phase 3 - Mark the new backend as stable for [`PlayerProfile`](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/io/github/thebusybiscuit/slimefun5/api/player/PlayerProfile.java). * Mark it as stable and remove the warnings once we're sure things are working correctly * Create a migration path for users currently using "legacy". * Enable by default for new servers -* Phase 4 - Move [`BlockStorage`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java) to new storage layer. +* Phase 4 - Move [`BlockStorage`](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java) to new storage layer. * The big one! We're gonna tackle adding this to BlockStorage. This will probably be a large change and we'll want to be as careful as possible here. * Implement `legacy` and `binary` as experimental storage backends for BlockStorage and allow users to opt-in * Provide a warning that this is **experimental** and there will be bugs. -* Phase 5 - Mark the new storage layer as stable for [`BlockStorage`](https://github.com/Slimefun/Slimefun4/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java). +* Phase 5 - Mark the new storage layer as stable for [`BlockStorage`](https://github.com/Slimefun5/Slimefun5/blob/bbfb9734b9f549d7e82291eff041f9b666a61b63/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java). * Mark it as stable and remove the warnings once we're sure things are working correctly * Ensure migration path works here too. @@ -121,7 +121,7 @@ The current plan looks like this: ## State of work * Phase 1: In progress - * https://github.com/Slimefun/Slimefun4/pull/4065 + * https://github.com/Slimefun5/Slimefun5/pull/4065 * Phase 2: Not started * Phase 3: Not started * Phase 4: Not started diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000000..b1476011a6 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,6 @@ +paperApiVersion=26.1.2.build.+ +shadowVersion=9.3.2 +githubGradleVersion=1.8.3 +runPaperVersion=3.0.2 + +slimefunAddons=Slimefun5/ExtraGear,Slimefun5/LuckyBlocks,Slimefun5/ChestTerminal,Slimefun5/SlimefunAdvancements,Slimefun5/ExoticGarden,Slimefun5/MissileWarfare,Slimefun5/LiteXpansion,Slimefun5/FluffyMachines,Slimefun5/InfinityExpansion,Slimefun5/DynaTech,Slimefun5/SensibleToolbox,Slimefun5/Galactifun,Slimefun5/SlimeTinker diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..a4b76b9530 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..37f78a6af8 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000000..f3b75f3b0d --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# 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. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + 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 +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# 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"' + +# 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 -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000000..9d21a21834 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/nms/v1_21_R1/build.gradle.kts b/nms/v1_21_R1/build.gradle.kts new file mode 100644 index 0000000000..6a932935b4 --- /dev/null +++ b/nms/v1_21_R1/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + java +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + +repositories { + mavenCentral() + maven("https://repo.papermc.io/repository/maven-public/") +} + +dependencies { + compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT") + implementation(project(":compat-api")) +} diff --git a/nms/v1_21_R1/src/main/java/io/github/thebusybiscuit/slimefun5/nms/v1_21_R1/SlimefunNMSImpl.java b/nms/v1_21_R1/src/main/java/io/github/thebusybiscuit/slimefun5/nms/v1_21_R1/SlimefunNMSImpl.java new file mode 100644 index 0000000000..184990cfd5 --- /dev/null +++ b/nms/v1_21_R1/src/main/java/io/github/thebusybiscuit/slimefun5/nms/v1_21_R1/SlimefunNMSImpl.java @@ -0,0 +1,56 @@ +package io.github.thebusybiscuit.slimefun5.nms.v1_21_R1; + +import io.github.thebusybiscuit.slimefun5.compat.SlimefunNMS; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; + +public class SlimefunNMSImpl implements SlimefunNMS { + + private NamespacedKey getKey(String key) { + // NamespacedKey must be lowercase + return new NamespacedKey("slimefun", key.toLowerCase()); + } + + @Override + public String getNBTString(ItemStack item, String key) { + if (item == null || !item.hasItemMeta()) { + return null; + } + ItemMeta meta = item.getItemMeta(); + if (meta == null) { + return null; + } + PersistentDataContainer pdc = meta.getPersistentDataContainer(); + return pdc.get(getKey(key), PersistentDataType.STRING); + } + + @Override + public ItemStack setNBTString(ItemStack item, String key, String value) { + if (item == null || item.getType().isAir()) { + return item; + } + ItemMeta meta = item.getItemMeta(); + if (meta == null) { + return item; + } + PersistentDataContainer pdc = meta.getPersistentDataContainer(); + pdc.set(getKey(key), PersistentDataType.STRING, value); + item.setItemMeta(meta); + return item; + } + + @Override + public void setBlockTypeFast(Block block, Material material) { + block.setType(material, false); + } + + @Override + public void breakBlockFast(Block block) { + block.setType(Material.AIR, false); + } +} diff --git a/nms/v1_8_R3/build.gradle.kts b/nms/v1_8_R3/build.gradle.kts new file mode 100644 index 0000000000..09d8a11763 --- /dev/null +++ b/nms/v1_8_R3/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + java +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + +repositories { + mavenCentral() + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") + maven("https://oss.sonatype.org/content/repositories/snapshots/") + maven("https://repo.codemc.io/repository/nms/") + maven("https://repo.dmulloy2.net/repository/public/") +} + +dependencies { + compileOnly("org.spigotmc:spigot:1.8.8-R0.1-SNAPSHOT") + implementation(project(":compat-api")) +} diff --git a/nms/v1_8_R3/src/main/java/io/github/thebusybiscuit/slimefun5/nms/v1_8_R3/SlimefunNMSImpl.java b/nms/v1_8_R3/src/main/java/io/github/thebusybiscuit/slimefun5/nms/v1_8_R3/SlimefunNMSImpl.java new file mode 100644 index 0000000000..c797ca69ee --- /dev/null +++ b/nms/v1_8_R3/src/main/java/io/github/thebusybiscuit/slimefun5/nms/v1_8_R3/SlimefunNMSImpl.java @@ -0,0 +1,54 @@ +package io.github.thebusybiscuit.slimefun5.nms.v1_8_R3; + +import io.github.thebusybiscuit.slimefun5.compat.SlimefunNMS; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.IBlockData; +import net.minecraft.server.v1_8_R3.ItemStack; +import net.minecraft.server.v1_8_R3.NBTTagCompound; +import net.minecraft.server.v1_8_R3.WorldServer; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; + +public class SlimefunNMSImpl implements SlimefunNMS { + + @Override + public String getNBTString(org.bukkit.inventory.ItemStack item, String key) { + if (item == null || item.getType() == Material.AIR) return null; + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + if (nmsItem != null && nmsItem.hasTag()) { + NBTTagCompound tag = nmsItem.getTag(); + if (tag.hasKey(key)) { + return tag.getString(key); + } + } + return null; + } + + @Override + public org.bukkit.inventory.ItemStack setNBTString(org.bukkit.inventory.ItemStack item, String key, String value) { + if (item == null || item.getType() == Material.AIR) return item; + ItemStack nmsItem = CraftItemStack.asNMSCopy(item); + if (nmsItem == null) return item; + NBTTagCompound tag = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound(); + tag.setString(key, value); + nmsItem.setTag(tag); + return CraftItemStack.asBukkitCopy(nmsItem); + } + + @Override + public void setBlockTypeFast(Block block, Material material) { + WorldServer world = ((CraftWorld) block.getWorld()).getHandle(); + BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ()); + net.minecraft.server.v1_8_R3.Block nmsBlock = CraftMagicNumbers.getBlock(material); + IBlockData data = nmsBlock.getBlockData(); + world.setTypeAndData(pos, data, 2); // 2 = update client, no physics + } + + @Override + public void breakBlockFast(Block block) { + setBlockTypeFast(block, Material.AIR); + } +} diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 65280d4459..0000000000 --- a/pom.xml +++ /dev/null @@ -1,540 +0,0 @@ - - - - 4.0.0 - com.github.slimefun - Slimefun - - - - 4.9-UNOFFICIAL - 2013 - jar - - - Slimefun is a Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items and recipes to your Minecraft Server. - https://github.com/Slimefun/Slimefun4 - - - - UTF-8 - - - 16 - 16 - - 21 - 21 - - - 1.21.1 - https://hub.spigotmc.org/javadocs/spigot/ - - - Slimefun_Slimefun4 - slimefun - https://sonarcloud.io - DEBUG - target/site/jacoco/jacoco.xml - - - - - GitHub Issues - https://github.com/Slimefun/Slimefun4/issues - - - - - - GNU General Public License v3.0 - https://github.com/Slimefun/Slimefun4/blob/master/LICENSE - repo - - - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots - - - - paper-repo - https://repo.papermc.io/repository/maven-public/ - - - - jitpack.io - https://jitpack.io - - - - worldedit-repo - https://maven.enginehub.org/repo/ - - - - placeholderapi-repo - https://repo.extendedclip.com/content/repositories/placeholderapi - - - - mcmmo-repo - https://nexus.neetgames.com/repository/maven-public - - - - walshy-public - https://repo.walshy.dev/public - - - - codemc-repo - https://repo.codemc.io/repository/maven-public/ - - - - - - ${project.basedir}/src/main/java - - - ${project.basedir}/src/test/java - - - clean package - - - ${project.name} v${project.version} - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - - - - - **/package-info.java - - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - - attach-sources - - jar - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.5.2 - - - org.junit.jupiter:junit-jupiter - false - - - - - - org.sonarsource.scanner.maven - sonar-maven-plugin - 5.0.0.4389 - - - - - org.jacoco - jacoco-maven-plugin - 0.8.12 - - - - prepare - - - prepare-agent - - - - - report - test - - - report - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.6.0 - - - - - - io.github.bakedlibs.dough - io.github.thebusybiscuit.slimefun4.libraries.dough - - - io.papermc.lib - io.github.thebusybiscuit.slimefun4.libraries.paperlib - - - org.apache.commons.lang - io.github.thebusybiscuit.slimefun4.libraries.commons.lang - - - - - - - *:* - - META-INF/* - - - - - - - - package - - shade - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.11.2 - - - ${project.basedir} - javadocs - - Slimefun4 - Javadocs - Slimefun4 - Javadocs - false - -html5 - - - - ${paper.javadocs} - - - - - - Slimefun4 - API - io.github.thebusybiscuit.slimefun4.api* - - - Slimefun4 - Core packages - io.github.thebusybiscuit.slimefun4.core* - - - Slimefun4 - Implementations - io.github.thebusybiscuit.slimefun4.implementation* - - - Slimefun4 - Integrations with other - plugins - io.github.thebusybiscuit.slimefun4.integrations* - - - Slimefun4 - Common utility packages - io.github.thebusybiscuit.slimefun4.utils* - - - Slimefun4 - Items - io.github.thebusybiscuit.slimefun4.implementation.items* - - - Slimefun4 - Multiblocks - io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks* - - - Slimefun4 - Electrical Machines - io.github.thebusybiscuit.slimefun4.implementation.items.electric* - - - Slimefun4 - Old packages - me.mrCookieSlime.Slimefun* - - - - - - - - - - - ${basedir}/src/main/resources - true - - - plugin.yml - config.yml - item-models.yml - - wiki.json - languages/translators.json - - tags/*.json - biome-maps/*.json - - languages/**/*.yml - - - - - - ${basedir} - false - - - LICENSE - - - - - - - - - org.junit - junit-bom - 5.11.4 - pom - import - - - - - - - - com.google.code.findbugs - jsr305 - 3.0.2 - provided - - - - - - com.github.Slimefun.dough - dough-api - cb22e71335 - compile - - - com.github.Slimefun.dough - dough-api - cb22e71335 - compile - - - io.papermc - paperlib - 1.0.8 - compile - - - - - io.papermc.paper - paper-api - ${paper.version}-R0.1-SNAPSHOT - provided - - - - - org.junit.jupiter - junit-jupiter - test - - - org.mockito - mockito-core - 5.15.2 - test - - - org.slf4j - slf4j-simple - 2.0.16 - test - - - - com.github.seeseemelk - MockBukkit-v1.21 - 3.133.2 - test - - - - - - org.jetbrains - annotations - - - - - - - com.sk89q.worldedit - worldedit-core - 7.3.9 - provided - - - - - * - * - - - - - com.sk89q.worldedit - worldedit-bukkit - 7.3.9 - provided - - - - - * - * - - - - - com.gmail.nossr50.mcMMO - mcMMO - 2.2.029 - provided - - - - - * - * - - - - - me.clip - placeholderapi - 2.11.6 - provided - - - - - * - * - - - - - me.minebuilders - clearlag-core - 3.1.6 - provided - - - - - * - * - - - - - com.github.LoneDev6 - itemsadder-api - 3.6.1 - provided - - - - - * - * - - - - - net.imprex - orebfuscator-api - 5.4.0 - provided - - - - - * - * - - - - - - commons-lang - commons-lang - 2.6 - compile - - - com.mojang - authlib - 6.0.52 - provided - - - - * - * - - - - - diff --git a/scripts/run-headless.ps1 b/scripts/run-headless.ps1 new file mode 100644 index 0000000000..79ee3dcf56 --- /dev/null +++ b/scripts/run-headless.ps1 @@ -0,0 +1,100 @@ +#requires -Version 5.1 +<# + Non-interactive launcher for the Slimefun universal-jar dev server. + + Boots the server for a chosen MC version (optionally with addons), captures ALL output to a log + file, waits until the server has finished starting (Paper's "Done (" line) plus a grace period so + Slimefun's post-start item-loading and addon enable errors are captured, then force-stops the whole + process tree and exits. This lets the boot be run head-less (e.g. from CI/automation) and the log + inspected afterward, instead of the interactive run.ps1 which holds the console open forever. + + Runs gradle with --no-daemon so the forked Paper server is a descendant of this process and the + recursive tree-kill reliably stops it (a plain daemon run leaves the server orphaned). + + Usage: + ./run-headless.ps1 -McVersion 1.8.8 -AllAddons + ./run-headless.ps1 -McVersion 26.1.2 -Addons "Slimefun5/InfinityExpansion@feature/java8-universal-jar" + ./run-headless.ps1 -McVersion 1.20.6 # core only +#> +param( + [string]$McVersion = "26.1.2", + [string]$Addons = "", # "Owner/Repo@branch,..." (empty = core only, unless -AllAddons) + [switch]$AllAddons, # build all known addons @ feature/java8-universal-jar + [switch]$LocalAddons, # build the addons-src working copies as-is (skip git reset) + [int]$ReadyTimeoutSec = 600, # max wait for the server to finish starting + [int]$GraceSec = 30, # extra capture after startup for post-start tasks/addon loading + [string]$LogFile = "" +) + +$ErrorActionPreference = "Stop" +$projectRoot = Split-Path -Parent $PSScriptRoot +Set-Location $projectRoot + +if ($AllAddons -and -not $Addons) { + $branch = "feature/java8-universal-jar" + $repos = @( + "Slimefun5/InfinityLib", "Slimefun5/InfinityExpansion", "Slimefun5/Networks", "Slimefun5/ExoticGarden", + "Slimefun5/DynaTech", "Slimefun5/Galactifun", "Slimefun5/SlimeTinker", "Slimefun5/FluffyMachines", + "Slimefun5/LiteXpansion", "Slimefun5/SensibleToolbox", "Slimefun5/ChestTerminal", "Slimefun5/ExtraGear", + "Slimefun5/LuckyBlocks", "Slimefun5/MissileWarfare", "Slimefun5/SlimefunAdvancements" + ) + $Addons = ($repos | ForEach-Object { "$_@$branch" }) -join ',' +} + +if (-not $LogFile) { $LogFile = Join-Path $projectRoot "build/headless-$McVersion.log" } +$errFile = "$LogFile.err" +New-Item -ItemType Directory -Force -Path (Split-Path -Parent $LogFile) | Out-Null +Remove-Item $LogFile, $errFile -ErrorAction SilentlyContinue + +$argList = "runServer -PmcVersion=$McVersion --no-daemon " +$argList += if ($Addons) { "-Paddons=$Addons" } else { "-PskipAddons" } +if ($LocalAddons) { $argList += " -PlocalAddons" } + +Write-Host "[headless] MC $McVersion | addons=$(if ($Addons) { $Addons } else { '(none)' })" +Write-Host "[headless] log: $LogFile" + +$proc = Start-Process -FilePath "$projectRoot\gradlew.bat" -ArgumentList $argList ` + -WorkingDirectory $projectRoot -RedirectStandardOutput $LogFile -RedirectStandardError $errFile ` + -PassThru -WindowStyle Hidden + +function Stop-Tree([int]$processId) { + Get-CimInstance Win32_Process -Filter "ParentProcessId=$processId" -ErrorAction SilentlyContinue | + ForEach-Object { Stop-Tree $_.ProcessId } + Stop-Process -Id $processId -Force -ErrorAction SilentlyContinue +} + +$deadline = (Get-Date).AddSeconds($ReadyTimeoutSec) +$ready = $false +while (-not $proc.HasExited -and (Get-Date) -lt $deadline) { + if ((Test-Path $LogFile) -and (Select-String -Path $LogFile -Pattern 'Done \(' -Quiet -ErrorAction SilentlyContinue)) { + $ready = $true + break + } + Start-Sleep -Seconds 2 +} + +if ($ready) { + Write-Host "[headless] server started; capturing for ${GraceSec}s then stopping..." + Start-Sleep -Seconds $GraceSec +} elseif ($proc.HasExited) { + Write-Host "[headless] process exited before startup (build/boot failure) - see log" +} else { + Write-Host "[headless] timed out after ${ReadyTimeoutSec}s waiting for startup - stopping" +} + +# Always sweep, even when the gradle process self-exited (a failed build still leaves the forked +# Paper server, the runServer wrapper JVM, and gradle daemons alive - those orphans hold plugin jars +# open and break the next run's copy step). +if (-not $proc.HasExited) { Stop-Tree $proc.Id } +$rootPattern = [regex]::Escape($projectRoot) +Get-CimInstance Win32_Process -Filter "Name='java.exe'" -ErrorAction SilentlyContinue | + Where-Object { + $_.CommandLine -and ( + $_.CommandLine -match 'paperclip|patched_|paper-' -or # forked Paper server + $_.CommandLine -match 'GradleWrapperMain.*runServer' -or # the runServer wrapper JVM + ($_.CommandLine -match 'GradleDaemon' -and $_.CommandLine -match $rootPattern) # daemon for THIS project + ) + } | + ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue } + +Write-Host "HEADLESS_DONE ready=$ready exited=$($proc.HasExited) log=$LogFile" diff --git a/scripts/run.ps1 b/scripts/run.ps1 new file mode 100644 index 0000000000..eac5ce5fe4 --- /dev/null +++ b/scripts/run.ps1 @@ -0,0 +1,290 @@ +#requires -Version 5.1 +<# + Interactive launcher for the Slimefun universal-jar dev server (Windows / PowerShell). + + Why a separate script instead of an in-build menu: Gradle runs in a background daemon with no + attached console, so an interactive prompt inside build.gradle.kts has no keyboard to read and + silently falls back to its defaults. Running the menus here - in your own terminal - gives full + keyboard access, and we then invoke gradlew with the chosen flags. Building the flags + programmatically also avoids PowerShell 5.1 splitting "-PmcVersion=1.8.8" at the dot. + + The previous selection is remembered in build/.last-run.json, so pressing Enter through the + menus immediately re-runs the last configuration. + + Usage: ./run.ps1 +#> + +$ErrorActionPreference = "Stop" +$projectRoot = Split-Path -Parent $PSScriptRoot +Set-Location $projectRoot + +$stateFile = Join-Path $projectRoot "build/.last-run.json" + +$versions = @( + "1.8.8", "1.9.4", "1.10.2", "1.11.2", "1.12.2", "1.13.2", "1.14.4", "1.15.2", + "1.16.5", "1.17.1", "1.18.2", "1.19.4", "1.20.6", "1.21.11", "26.1.2" +) + +# Format: Owner/Repo. Build order matters: InfinityLib first, then InfinityExpansion (Networks depends on it), then Networks. +$availableAddons = @( + "Slimefun5/InfinityLib", "Slimefun5/InfinityExpansion", "Slimefun5/Networks", "Slimefun5/ExoticGarden", + "Slimefun5/DynaTech", "Slimefun5/Galactifun", "Slimefun5/SlimeTinker", "Slimefun5/FluffyMachines", + "Slimefun5/LiteXpansion", "Slimefun5/SensibleToolbox", "Slimefun5/ChestTerminal", "Slimefun5/ExtraGear", + "Slimefun5/LuckyBlocks", "Slimefun5/MissileWarfare", "Slimefun5/SlimefunAdvancements" +) + +function Resolve-AllBranches($repos) { + Write-Host "Resolving addon branches from GitHub..." -ForegroundColor DarkGray + + $work = { + param($r) + $out = & git ls-remote --symref "https://github.com/$r.git" 2>$null + if ($LASTEXITCODE -ne 0 -or -not $out) { return $null } + $default = $null + $branches = @() + foreach ($line in $out) { + if ($line -match '^ref:\s+refs/heads/(\S+)\s+HEAD') { $default = $matches[1] } + elseif ($line -match 'refs/heads/(\S+)$') { $branches += $matches[1] } + } + return @{ Default = $default; Branches = @($branches) } + } + + $pool = [RunspaceFactory]::CreateRunspacePool(1, [Math]::Min(16, $repos.Count)) + $pool.Open() + + $tasks = foreach ($repo in $repos) { + $ps = [PowerShell]::Create() + $ps.RunspacePool = $pool + $null = $ps.AddScript($work).AddArgument($repo) + [PSCustomObject]@{ Repo = $repo; PS = $ps; Handle = $ps.BeginInvoke() } + } + + $map = @{} + foreach ($task in $tasks) { + $result = $task.PS.EndInvoke($task.Handle) + $map[$task.Repo] = if ($result.Count -gt 0) { $result[0] } else { $null } + $task.PS.Dispose() + } + + $pool.Close() + $pool.Dispose() + return $map +} + +function Load-State { + if (Test-Path $stateFile) { + try { return Get-Content $stateFile -Raw | ConvertFrom-Json } catch { return $null } + } + return $null +} + +function Save-State($version, $selections) { + New-Item -ItemType Directory -Force -Path (Split-Path -Parent $stateFile) | Out-Null + [PSCustomObject]@{ version = $version; selections = $selections } | + ConvertTo-Json -Depth 4 | Set-Content -Path $stateFile -Encoding UTF8 +} + +function Write-Frame($lines) { + [Console]::SetCursorPosition(0, 0) + $width = [Console]::WindowWidth - 1 + if ($width -lt 1) { $width = 79 } + for ($i = 0; $i -lt $lines.Count; $i++) { + $text = $lines[$i].Text + if ($text.Length -gt $width) { $text = $text.Substring(0, $width) } + $text = $text.PadRight($width) + if ($i -lt $lines.Count - 1) { + Write-Host $text -ForegroundColor $lines[$i].Color + } else { + Write-Host $text -ForegroundColor $lines[$i].Color -NoNewline + } + } +} + +function Read-MenuKey { + return $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown").VirtualKeyCode +} + +function New-Row($text, $color) { return @{ Text = $text; Color = $color } } + +function Select-Version($startIndex) { + $index = $startIndex + [Console]::Clear() + while ($true) { + $lines = @( + (New-Row "=========================================" "Cyan"), + (New-Row " Slimefun5 - Select Server Version " "Cyan"), + (New-Row "=========================================" "Cyan"), + (New-Row "[W]/[S] or [Up]/[Down] to move, [Enter] to select." "DarkGray"), + (New-Row "" "Gray") + ) + for ($i = 0; $i -lt $versions.Length; $i++) { + if ($i -eq $index) { $lines += New-Row " > $($versions[$i])" "Green" } + else { $lines += New-Row " $($versions[$i])" "Gray" } + } + Write-Frame $lines + switch (Read-MenuKey) { + { $_ -in 38, 87 } { $index--; if ($index -lt 0) { $index = $versions.Length - 1 } } + { $_ -in 40, 83 } { $index++; if ($index -ge $versions.Length) { $index = 0 } } + 13 { return $index } + } + } +} + +function Select-Branch($addon, $current) { + $info = $script:branchMap[$addon] + + # Repo unreachable, or resolved with zero branches: nothing to pick. Show why and go back. + if ($null -eq $info -or @($info.Branches).Count -eq 0) { + $reason = if ($null -eq $info) { "could not be reached on GitHub" } else { "is empty (no branches)" } + [Console]::Clear() + Write-Frame @( + (New-Row "=========================================" "Cyan"), + (New-Row " Branch for $addon" "Cyan"), + (New-Row "=========================================" "Cyan"), + (New-Row "" "Gray"), + (New-Row " This repository $reason." "Yellow"), + (New-Row "" "Gray"), + (New-Row " Press [Enter] to go back." "DarkGray") + ) + while ((Read-MenuKey) -ne 13) {} + return $current + } + + # Live branches from GitHub, plus a manual-entry escape hatch. + $choices = @($info.Branches) + @("Custom...") + $index = [Math]::Max(0, [Array]::IndexOf($choices, $current)) + [Console]::Clear() + while ($true) { + $lines = @( + (New-Row "=========================================" "Cyan"), + (New-Row " Branch for $addon" "Cyan"), + (New-Row "=========================================" "Cyan"), + (New-Row "[W]/[S] or [Up]/[Down] to move, [Enter] to select." "DarkGray"), + (New-Row "" "Gray") + ) + for ($i = 0; $i -lt $choices.Length; $i++) { + if ($i -eq $index) { $lines += New-Row " > $($choices[$i])" "Green" } + else { $lines += New-Row " $($choices[$i])" "Gray" } + } + Write-Frame $lines + switch (Read-MenuKey) { + { $_ -in 38, 87 } { $index--; if ($index -lt 0) { $index = $choices.Length - 1 } } + { $_ -in 40, 83 } { $index++; if ($index -ge $choices.Length) { $index = 0 } } + 13 { + $choice = $choices[$index] + if ($choice -eq "Custom...") { + [Console]::Clear() + $custom = Read-Host "Enter branch name for $addon" + if ([string]::IsNullOrWhiteSpace($custom)) { return $current } + return $custom.Trim() + } + return $choice + } + } + } +} + +function Select-Addons($lastSelections) { + $count = $availableAddons.Length + $doneIndex = $count + $selected = New-Object bool[] $count + $branches = New-Object string[] $count + for ($i = 0; $i -lt $count; $i++) { + $previous = $lastSelections | Where-Object { $_.repo -eq $availableAddons[$i] } | Select-Object -First 1 + if ($previous) { + $selected[$i] = $true + $branches[$i] = $previous.branch + } else { + # No hardcoded default: use the repo's resolved HEAD, else its first branch, else blank. + $info = $script:branchMap[$availableAddons[$i]] + if ($info -and $info.Default) { $branches[$i] = $info.Default } + elseif ($info -and @($info.Branches).Count -gt 0) { $branches[$i] = @($info.Branches)[0] } + else { $branches[$i] = "" } + } + } + $index = 0 + [Console]::Clear() + while ($true) { + $lines = @( + (New-Row "=========================================" "Cyan"), + (New-Row " Slimefun5 - Select Addons to Build " "Cyan"), + (New-Row "=========================================" "Cyan"), + (New-Row "[Space] toggle, [Enter] pick its branch, [Enter] on Done to launch." "DarkGray"), + (New-Row "Select none to run the core only." "DarkGray"), + (New-Row "" "Gray") + ) + for ($i = 0; $i -lt $count; $i++) { + $info = $script:branchMap[$availableAddons[$i]] + $mark = if ($selected[$i]) { "[x]" } else { "[ ]" } + if ($null -eq $info) { + $status = " " + } elseif (@($info.Branches).Count -eq 0) { + $status = " " + } elseif ($selected[$i]) { + $status = " ($($branches[$i]))" + } else { + $status = "" + } + $text = "$mark $($availableAddons[$i])$status" + if ($i -eq $index) { $lines += New-Row " > $text" "Green" } + else { $lines += New-Row " $text" "Gray" } + } + $doneText = "Done - launch server" + if ($index -eq $doneIndex) { $lines += New-Row " > $doneText" "Yellow" } + else { $lines += New-Row " $doneText" "Yellow" } + + Write-Frame $lines + switch (Read-MenuKey) { + { $_ -in 38, 87 } { $index--; if ($index -lt 0) { $index = $doneIndex } } + { $_ -in 40, 83 } { $index++; if ($index -gt $doneIndex) { $index = 0 } } + 32 { if ($index -lt $count) { $selected[$index] = -not $selected[$index] } } + 13 { + if ($index -eq $doneIndex) { + $chosen = @() + for ($i = 0; $i -lt $count; $i++) { + if ($selected[$i]) { + $chosen += [PSCustomObject]@{ repo = $availableAddons[$i]; branch = $branches[$i] } + } + } + return ,$chosen + } else { + $selected[$index] = $true + $branches[$index] = Select-Branch $availableAddons[$index] $branches[$index] + [Console]::Clear() + } + } + } + } +} + +$state = Load-State +$lastVersion = if ($state) { $state.version } else { $versions[-1] } +$lastSelections = if ($state -and $state.selections) { @($state.selections) } else { @() } + +$startIndex = [Array]::IndexOf($versions, $lastVersion) +if ($startIndex -lt 0) { $startIndex = $versions.Length - 1 } + +$version = $versions[(Select-Version $startIndex)] + +# Resolve every addon's branches from GitHub up front (parallel) so the addon menu is instant. +$script:branchMap = Resolve-AllBranches $availableAddons + +$selections = Select-Addons $lastSelections + +Save-State $version $selections +[Console]::Clear() + +$gradleArgs = @("runServer", "-PmcVersion=$version") +if ($selections.Count -gt 0) { + $addonArg = ($selections | ForEach-Object { "$($_.repo)@$($_.branch)" }) -join ',' + $gradleArgs += "-Paddons=$addonArg" + Write-Host "Launching Minecraft $version with addons:" -ForegroundColor Green + $selections | ForEach-Object { Write-Host " - $($_.repo) @ $($_.branch)" -ForegroundColor Green } +} else { + $gradleArgs += "-PskipAddons" + Write-Host "Launching Minecraft $version (core only)" -ForegroundColor Green +} +Write-Host "" + +& "$projectRoot\gradlew.bat" @gradleArgs +exit $LASTEXITCODE diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000000..72c369c276 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,22 @@ +pluginManagement { + val shadowVersion: String by settings + val githubGradleVersion: String by settings + val runPaperVersion: String by settings + plugins { + id("com.gradleup.shadow") version shadowVersion + id("io.github.intisy.github-gradle") version githubGradleVersion + id("xyz.jpenilla.run-paper") version runPaperVersion + } +} + +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" +} + +rootProject.name = "Slimefun" + +include("core") +include("compat-api") +include("compat-stubs") +include("nms:v1_8_R3") +include("nms:v1_21_R1") diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java deleted file mode 100644 index 15243da62f..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains classes that are centered around the - * {@link io.github.thebusybiscuit.slimefun4.api.geo.GEOResource} API. - */ -package io.github.thebusybiscuit.slimefun4.api.geo; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java deleted file mode 100644 index 078403c9c2..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package stores classes of the API that are related to the - * {@link io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork}. - */ -package io.github.thebusybiscuit.slimefun4.api.gps; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java deleted file mode 100644 index e95ee138f5..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package contains a few {@link io.github.thebusybiscuit.slimefun4.api.items.ItemGroup} variations. - */ -package io.github.thebusybiscuit.slimefun4.api.items.groups; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java deleted file mode 100644 index fd1bd1c8d6..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package contains a few classes that revolve around the API for - * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem}, such as - * {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting} - */ -package io.github.thebusybiscuit.slimefun4.api.items; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java deleted file mode 100644 index 2f6bea34ce..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package contains various sub classes of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting}. - */ -package io.github.thebusybiscuit.slimefun4.api.items.settings; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java deleted file mode 100644 index ba6cd3df54..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds everything connected to the {@link io.github.thebusybiscuit.slimefun4.api.researches.Research} - * class. - */ -package io.github.thebusybiscuit.slimefun4.api.researches; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java deleted file mode 100644 index c8d0bf92b1..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains the various possible {@link io.github.thebusybiscuit.slimefun4.core.attributes.interactions.InteractionResult}s - * that can be returned by an {@link io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable} object. - */ -package io.github.thebusybiscuit.slimefun4.core.attributes.interactions; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java deleted file mode 100644 index 9a2c8c5699..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains all variations of {@link io.github.thebusybiscuit.slimefun4.core.attributes.ItemAttribute} that - * can be assigned to a {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - */ -package io.github.thebusybiscuit.slimefun4.core.attributes; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java deleted file mode 100644 index 14f426c5c6..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package contains the Settings menu for the {@link io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide} as - * well as the interface {@link io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideOption} for adding - * your own options - */ -package io.github.thebusybiscuit.slimefun4.core.guide.options; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java deleted file mode 100644 index af07c73dce..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package contains sources related to the - * {@link io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor} - * and any {@link io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation}. - */ -package io.github.thebusybiscuit.slimefun4.core.machines; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java deleted file mode 100644 index 23867e7f6a..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds all core mechanics related to a - * {@link io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock}, like that class itself. - */ -package io.github.thebusybiscuit.slimefun4.core.multiblocks; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java deleted file mode 100644 index 5f4e747aff..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package provides the core functionality for the {@link io.github.thebusybiscuit.slimefun4.api.network.Network} - * class, such as the {@link io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager} and also the subpackages - * for actual implementations of the {@link io.github.thebusybiscuit.slimefun4.api.network.Network} class. - */ -package io.github.thebusybiscuit.slimefun4.core.networks; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/package-info.java deleted file mode 100644 index d081769ee3..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains everything related to the - * {@link io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService}. - */ -package io.github.thebusybiscuit.slimefun4.core.services.holograms; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/package-info.java deleted file mode 100644 index e6921498b3..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds the different implementations of - * {@link io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector}. - */ -package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java deleted file mode 100644 index d7cd73b2cd..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java +++ /dev/null @@ -1,218 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.sounds; - -import java.util.Locale; -import java.util.logging.Level; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - - -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.SoundCategory; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -import com.google.common.base.Preconditions; - -/** - * This enum holds references to all our sounds. - * - * @author TheBusyBiscuit - * @author J3fftw1 - * - * @see SoundService - * @see SoundConfiguration - * - */ -public enum SoundEffect { - - ANCIENT_ALTAR_ITEM_CHECK_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F), - ANCIENT_ALTAR_ITEM_DROP_SOUND(Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1F, 1F), - ANCIENT_ALTAR_ITEM_PICK_UP_SOUND(Sound.ENTITY_ITEM_PICKUP, 1F, 1F), - ANCIENT_ALTAR_FINISH_SOUND(Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1F, 1F), - ANCIENT_ALTAR_START_SOUND(Sound.ENTITY_ILLUSIONER_PREPARE_MIRROR, 1F, 1F), - ANCIENT_PEDESTAL_ITEM_PLACE_SOUND(Sound.ENTITY_ITEM_PICKUP, 0.5F, 0.5F), - ARMOR_FORGE_FINISH_SOUND(Sound.BLOCK_ANVIL_USE, 1F, 1F), - ARMOR_FORGE_WORKING_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - AUTO_CRAFTER_GUI_CLICK_SOUND(Sound.UI_BUTTON_CLICK, 1F, 1F), - AUTO_CRAFTER_UPDATE_RECIPE(Sound.UI_BUTTON_CLICK, 1F, 1F), - AUTOMATED_PANNING_MACHINE_FAIL_SOUND(Sound.ENTITY_ARMOR_STAND_BREAK, 1F, 1F), - AUTOMATED_PANNING_MACHINE_SUCCESS_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - BEE_BOOTS_FALL_SOUND(Sound.BLOCK_HONEY_BLOCK_FALL, 1F, 1F), - BACKPACK_CLOSE_SOUND(Sound.ENTITY_HORSE_ARMOR, 1F, 1F), - BACKPACK_OPEN_SOUND(Sound.ENTITY_HORSE_ARMOR, 1F, 1F), - COMPOSTER_COMPOST_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - COMPRESSOR_CRAFT_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - COMPRESSOR_CRAFT_CONTRACT_SOUND(Sound.BLOCK_PISTON_CONTRACT, 1F, 1F), - COMPRESSOR_CRAFT_EXTEND_SOUND(Sound.BLOCK_PISTON_EXTEND, 1F, 1F), - COOLER_CONSUME_SOUND(Sound.ENTITY_GENERIC_DRINK, 1F, 1F), - CRUCIBLE_ADD_WATER_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), - CRUCIBLE_ADD_LAVA_SOUND(Sound.BLOCK_LAVA_POP, 1F , 1F), - CRUCIBLE_BLOCK_BREAK_SOUND(Sound.BLOCK_METAL_BREAK, 1F, 1F), - CRUCIBLE_GENERATE_LIQUID_SOUND(Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F), - CRUCIBLE_INTERACT_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - CRUCIBLE_PLACE_LAVA_SOUND(Sound.BLOCK_LAVA_POP, 1F , 1F), - CRUCIBLE_PLACE_WATER_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), - DEBUG_FISH_CLICK_SOUND(Sound.BLOCK_BAMBOO_PLACE, 1F, 1F), - DIET_COOKIE_CONSUME_SOUND(Sound.ENTITY_GENERIC_EAT, 1F, 1F), - ENCHANTMENT_RUNE_ADD_ENCHANT_SOUND(Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1F, 1F), - ENDER_BACKPACK_OPEN_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 1F), - ENHANCED_CRAFTING_TABLE_CRAFT_SOUND(Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F), - ELYTRA_CAP_IMPACT_SOUND(Sound.BLOCK_STONE_HIT, 1F, 1F), - EXPLOSIVE_BOW_HIT_SOUND(Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F), - EXPLOSIVE_TOOL_EXPLODE_SOUND(Sound.ENTITY_GENERIC_EXPLODE, 0.2F, 1F), - FISHERMAN_ANDROID_FISHING_SOUND(Sound.ENTITY_PLAYER_SPLASH, 0.3F, 0.7F), - FLASK_OF_KNOWLEDGE_FILLUP_SOUND(Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1F, 0.5F), - GUIDE_BUTTON_CLICK_SOUND(Sound.ITEM_BOOK_PAGE_TURN, 1F, 1F), - GUIDE_CONTRIBUTORS_OPEN_SOUND(Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F), - GUIDE_LANGUAGE_OPEN_SOUND(Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F), - GUIDE_OPEN_SETTING_SOUND(Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F), - GRIND_STONE_INTERACT_SOUND(Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F), - IGNITION_CHAMBER_USE_FLINT_AND_STEEL_SOUND(Sound.ENTITY_ITEM_BREAK, 1F, 1F), - INFUSED_HOPPER_TELEPORT_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 0.5F, 2F), - INFUSED_MAGNET_TELEPORT_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 0.25F, 0.9F), - IRON_GOLEM_ASSEMBLER_ASSEMBLE_SOUND(Sound.ENTITY_IRON_GOLEM_REPAIR, 0.5F, 1F), - JETBOOTS_THRUST_SOUND(Sound.ENTITY_TNT_PRIMED, 0.25F, 1F), - JETPACK_THRUST_SOUND(Sound.ENTITY_GENERIC_EXPLODE, 0.25F, 1F), - JUICER_USE_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), - LIMITED_USE_ITEM_BREAK_SOUND(Sound.ENTITY_ITEM_BREAK, 1F, 1F), - MAGICAL_EYE_OF_ENDER_USE_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 1F), - MAGIC_SUGAR_CONSUME_SOUND(Sound.ENTITY_GENERIC_EAT, 1F, 1F), - MAGIC_WORKBENCH_FINISH_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - MAGIC_WORKBENCH_START_ANIMATION_SOUND(Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F), - MINER_ANDROID_BLOCK_GENERATION_SOUND(Sound.BLOCK_FIRE_EXTINGUISH, 0.075F, 0.8F), - MINING_TASK_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 0.2F, 1F), - ORE_WASHER_WASH_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), - PLAYER_RESEARCHING_SOUND(Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F), - PORTABLE_DUSTBIN_OPEN_SOUND(Sound.BLOCK_ANVIL_LAND, 1F, 1F), - PORTABLE_CRAFTER_OPEN_SOUND(Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F), - PRESSURE_CHAMBER_FINISH_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - PRESSURE_CHAMBER_WORKING_SOUND(Sound.ENTITY_TNT_PRIMED, 1F, 1F), - PROGRAMMABLE_ANDROID_SCRIPT_DOWNLOAD_SOUND(Sound.BLOCK_NOTE_BLOCK_HAT, 0.7F, 0.7F), - SLIME_BOOTS_FALL_SOUND(Sound.BLOCK_SLIME_BLOCK_FALL, 1F, 1F), - TELEPORTATION_MANAGER_OPEN_GUI(Sound.UI_BUTTON_CLICK, 1F, 1F), - GPS_NETWORK_ADD_WAYPOINT(Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 1F), - GPS_NETWORK_CREATE_WAYPOINT(Sound.BLOCK_NOTE_BLOCK_PLING, 0.5F, 1F), - GPS_NETWORK_OPEN_PANEL_SOUND(Sound.UI_BUTTON_CLICK, 1F, 1F), - SMELTERY_CRAFT_SOUND(Sound.BLOCK_LAVA_POP, 1F, 1F), - SOULBOUND_RUNE_RITUAL_SOUND(Sound.ENTITY_GENERIC_EXPLODE, 0.3F, 1F), - SPLINT_CONSUME_SOUND(Sound.ENTITY_SKELETON_HURT, 1F, 1F), - STOMPER_BOOTS_STOMP_SOUND(Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F), - TAPE_MEASURE_MEASURE_SOUND(Sound.ITEM_BOOK_PUT, 1, 0.7F), - TOME_OF_KNOWLEDGE_USE_SOUND(Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F), - TELEPORT_UPDATE_SOUND(Sound.BLOCK_BEACON_AMBIENT, 1F, 0.6F), - TELEPORT_SOUND(Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F), - VAMPIRE_BLADE_HEALING_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 0.7F, 0.7F), - VANILLA_AUTO_CRAFTER_UPDATE_RECIPE_SOUND(Sound.UI_BUTTON_CLICK, 1F, 1F), - VILLAGER_RUNE_TRANSFORM_SOUND(Sound.ENTITY_VILLAGER_CELEBRATE, 1F, 1.4F), - VITAMINS_CONSUME_SOUND(Sound.ENTITY_GENERIC_EAT, 1F, 1F), - WIND_STAFF_USE_SOUND(Sound.ENTITY_TNT_PRIMED, 1F, 1F); - - private final String defaultSound; - private final float defaultVolume; - private final float defaultPitch; - - SoundEffect(@Nonnull String sound, float volume, float pitch) { - Preconditions.checkNotNull(sound, "The Sound id cannot be null!"); - Preconditions.checkArgument(volume >= 0, "The volume cannot be a negative number."); - Preconditions.checkArgument(pitch >= 0.5, "A pitch below 0.5 has no effect on the sound."); - - this.defaultSound = sound; - this.defaultVolume = volume; - this.defaultPitch = pitch; - } - - SoundEffect(@Nonnull Sound sound, float volume, float pitch) { - Preconditions.checkNotNull(sound, "The Sound id cannot be null!"); - Preconditions.checkArgument(volume >= 0, "The volume cannot be a negative number."); - Preconditions.checkArgument(pitch >= 0.5, "A pitch below 0.5 has no effect on the sound."); - - this.defaultSound = sound.getKey().getKey(); - this.defaultVolume = volume; - this.defaultPitch = pitch; - } - - private @Nullable SoundConfiguration getConfiguration() { - SoundConfiguration config = Slimefun.getSoundService().getConfiguration(this); - - if (config == null) { - // This should not happen. But if it does... send a warning - Slimefun.logger().log(Level.WARNING, "Could not find any sound configuration for: {0}", name()); - } - - return config; - } - - /** - * This method will play this {@link SoundEffect} only to the given {@link Player} using the - * eye {@link Location} of the {@link Player} and the {@link SoundCategory} {@code PLAYERS}. - * - * @param player The {@link Player} which to play the {@link Sound} to. - */ - public void playFor(@Nonnull Player player) { - Preconditions.checkNotNull(player, "Cannot play sounds to a Player that is null!"); - SoundConfiguration config = getConfiguration(); - - if (config != null) { - Location loc = player.getEyeLocation(); - player.playSound(loc, config.getSoundId(), SoundCategory.PLAYERS, config.getVolume(), config.getPitch()); - } - } - - /** - * This method will play this {@link SoundEffect} at the given {@link Location} using the - * provided {@link SoundCategory}. - * - * @param loc The {@link Location} at which to play the {@link SoundEffect}. - * @param category The {@link SoundCategory} that should be used. - */ - public void playAt(@Nonnull Location loc, @Nonnull SoundCategory category) { - Preconditions.checkNotNull(loc, "The location should not be null."); - SoundConfiguration config = getConfiguration(); - - if (config != null && loc.getWorld() != null) { - loc.getWorld().playSound(loc, config.getSoundId(), category, config.getVolume(), config.getPitch()); - } - } - - /** - * This method will play this {@link SoundEffect} at the {@link Location} of the given {@link Block}, - * the used {@link SoundCategory} will be {@code BLOCKS}. - * - * @param block The {@link Block} at which to play the {@link SoundEffect} - */ - public void playAt(@Nonnull Block block) { - Preconditions.checkNotNull(block, "The block cannot be null."); - playAt(block.getLocation(), SoundCategory.BLOCKS); - } - - /** - * This returns the default sound id. - * - * @return The default sound id. - */ - public @Nonnull String getDefaultSoundId() { - return defaultSound; - } - - /** - * This returns the default volume. - * - * @return The default volume. - */ - public float getDefaultVolume() { - return defaultVolume; - } - - /** - * This returns the default pitch. - * - * @return The default pitch. - */ - public float getDefaultPitch() { - return defaultPitch; - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/package-info.java deleted file mode 100644 index 231751cda5..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package provides the different implementations of our - * {@link io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide} - */ -package io.github.thebusybiscuit.slimefun4.implementation.guide; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/package-info.java deleted file mode 100644 index 5e588c64bb..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds the {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} implementations related to - * the {@link io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.altar; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java deleted file mode 100644 index cd8b72c723..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java +++ /dev/null @@ -1,83 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; - -import java.util.Random; -import java.util.concurrent.ThreadLocalRandom; - -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.Bukkit; -import org.bukkit.Effect; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.data.Ageable; -import org.bukkit.block.data.BlockData; -import org.bukkit.inventory.ItemStack; - -import io.github.thebusybiscuit.slimefun4.api.events.AndroidFarmEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; - -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; - -public class FarmerAndroid extends ProgrammableAndroid { - - @ParametersAreNonnullByDefault - public FarmerAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(itemGroup, tier, item, recipeType, recipe); - } - - @Override - public AndroidType getAndroidType() { - return getTier() == 1 ? AndroidType.FARMER : AndroidType.ADVANCED_FARMER; - } - - @Override - protected void farm(Block b, BlockMenu menu, Block block, boolean isAdvanced) { - Material blockType = block.getType(); - BlockData data = block.getBlockData(); - ItemStack drop = null; - - if (!block.getWorld().getWorldBorder().isInside(block.getLocation())) { - return; - } - - if (data instanceof Ageable ageable && ageable.getAge() >= ageable.getMaximumAge()) { - drop = getDropFromCrop(blockType); - } - - AndroidInstance instance = new AndroidInstance(this, b); - - AndroidFarmEvent event = new AndroidFarmEvent(block, instance, isAdvanced, drop); - Bukkit.getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - drop = event.getDrop(); - - if (drop != null && menu.pushItem(drop, getOutputSlots()) == null) { - block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, blockType); - - if (data instanceof Ageable ageable) { - ageable.setAge(0); - block.setBlockData(data); - } - } - } - } - - private ItemStack getDropFromCrop(Material crop) { - Random random = ThreadLocalRandom.current(); - - return switch (crop) { - case WHEAT -> new ItemStack(Material.WHEAT, random.nextInt(2) + 1); - case POTATOES -> new ItemStack(Material.POTATO, random.nextInt(3) + 1); - case CARROTS -> new ItemStack(Material.CARROT, random.nextInt(3) + 1); - case BEETROOTS -> new ItemStack(Material.BEETROOT, random.nextInt(3) + 1); - case COCOA -> new ItemStack(Material.COCOA_BEANS, random.nextInt(3) + 1); - case NETHER_WART -> new ItemStack(Material.NETHER_WART, random.nextInt(3) + 1); - case SWEET_BERRY_BUSH -> new ItemStack(Material.SWEET_BERRIES, random.nextInt(3) + 1); - default -> null; - }; - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java deleted file mode 100644 index 0133cb3b25..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java +++ /dev/null @@ -1,188 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; - -import java.util.List; -import java.util.UUID; -import java.util.function.Predicate; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.Bukkit; -import org.bukkit.Effect; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.Tag; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.inventory.ItemStack; - -import io.github.bakedlibs.dough.blocks.Vein; -import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; - -import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; - -public class WoodcutterAndroid extends ProgrammableAndroid { - - private static final int MAX_REACH = 160; - - @ParametersAreNonnullByDefault - public WoodcutterAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(itemGroup, tier, item, recipeType, recipe); - } - - @Override - public AndroidType getAndroidType() { - return AndroidType.WOODCUTTER; - } - - @Override - protected boolean chopTree(Block b, BlockMenu menu, BlockFace face) { - Block target = b.getRelative(face); - - if (!target.getWorld().getWorldBorder().isInside(target.getLocation())) { - return true; - } - - if (Tag.LOGS.isTagged(target.getType())) { - List list = Vein.find(target, MAX_REACH, block -> Tag.LOGS.isTagged(block.getType())); - - if (!list.isEmpty()) { - Block log = list.get(list.size() - 1); - log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType()); - - OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))); - if (Slimefun.getProtectionManager().hasPermission(owner, log.getLocation(), Interaction.BREAK_BLOCK)) { - breakLog(log, b, menu, face); - } - - return false; - } - } - - return true; - } - - @ParametersAreNonnullByDefault - private void breakLog(Block log, Block android, BlockMenu menu, BlockFace face) { - ItemStack drop = new ItemStack(log.getType()); - - // We try to push the log into the android's inventory, but nothing happens if it does not fit - menu.pushItem(drop, getOutputSlots()); - - log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType()); - - // If the android just chopped the bottom log, we replant the appropriate sapling - if (log.getY() == android.getRelative(face).getY()) { - replant(log); - } else { - log.setType(Material.AIR); - } - } - - private void replant(@Nonnull Block block) { - Material logType = block.getType(); - Material saplingType = null; - Predicate soilRequirement = null; - - switch (logType) { - case OAK_LOG, - OAK_WOOD, - STRIPPED_OAK_LOG, - STRIPPED_OAK_WOOD -> { - saplingType = Material.OAK_SAPLING; - soilRequirement = SlimefunTag.DIRT_VARIANTS::isTagged; - } - case BIRCH_LOG, - BIRCH_WOOD, - STRIPPED_BIRCH_LOG, - STRIPPED_BIRCH_WOOD -> { - saplingType = Material.BIRCH_SAPLING; - soilRequirement = SlimefunTag.DIRT_VARIANTS::isTagged; - } - case JUNGLE_LOG, - JUNGLE_WOOD, - STRIPPED_JUNGLE_LOG, - STRIPPED_JUNGLE_WOOD -> { - saplingType = Material.JUNGLE_SAPLING; - soilRequirement = SlimefunTag.DIRT_VARIANTS::isTagged; - } - case SPRUCE_LOG, - SPRUCE_WOOD, - STRIPPED_SPRUCE_LOG, - STRIPPED_SPRUCE_WOOD -> { - saplingType = Material.SPRUCE_SAPLING; - soilRequirement = SlimefunTag.DIRT_VARIANTS::isTagged; - } - case ACACIA_LOG, - ACACIA_WOOD, - STRIPPED_ACACIA_LOG, - STRIPPED_ACACIA_WOOD -> { - saplingType = Material.ACACIA_SAPLING; - soilRequirement = SlimefunTag.DIRT_VARIANTS::isTagged; - } - case DARK_OAK_LOG, - DARK_OAK_WOOD, - STRIPPED_DARK_OAK_LOG, - STRIPPED_DARK_OAK_WOOD -> { - saplingType = Material.DARK_OAK_SAPLING; - soilRequirement = SlimefunTag.DIRT_VARIANTS::isTagged; - } - case CRIMSON_STEM, - CRIMSON_HYPHAE, - STRIPPED_CRIMSON_STEM, - STRIPPED_CRIMSON_HYPHAE -> { - saplingType = Material.CRIMSON_FUNGUS; - soilRequirement = SlimefunTag.FUNGUS_SOIL::isTagged; - } - case WARPED_STEM, - WARPED_HYPHAE, - STRIPPED_WARPED_STEM, - STRIPPED_WARPED_HYPHAE -> { - saplingType = Material.WARPED_FUNGUS; - soilRequirement = SlimefunTag.FUNGUS_SOIL::isTagged; - } - default -> {} - } - - if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_19)) { - switch (logType) { - case MANGROVE_LOG, - STRIPPED_MANGROVE_LOG -> { - saplingType = Material.MANGROVE_PROPAGULE; - soilRequirement = SlimefunTag.MANGROVE_BASE_BLOCKS::isTagged; - } - default -> {} - } - } - - if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_20)) { - switch (logType) { - case CHERRY_LOG, - STRIPPED_CHERRY_LOG -> { - saplingType = Material.CHERRY_SAPLING; - soilRequirement = SlimefunTag.DIRT_VARIANTS::isTagged; - } - default -> {} - } - } - - if (saplingType != null && soilRequirement != null) { - if (soilRequirement.test(block.getRelative(BlockFace.DOWN).getType())) { - // Replant the block - block.setType(saplingType); - } else { - // Simply drop the sapling if the soil does not fit - block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(saplingType)); - block.setType(Material.AIR); - } - } - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/package-info.java deleted file mode 100644 index 294fbe3880..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are related to the {@link io.github.thebusybiscuit.slimefun4.implementation.items.androids.ProgrammableAndroid}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.androids; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/package-info.java deleted file mode 100644 index 7f51e213a4..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package contains implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} that are - * related to armor, such as the expandable - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece} class for example. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.armor; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/package-info.java deleted file mode 100644 index 2b731988d1..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds classes related to - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/package-info.java deleted file mode 100644 index dc8273f08a..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package contains a few miscellaneous implementations of - * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} which are blocks. - * Such as the {@link io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer} for example. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/package-info.java deleted file mode 100644 index 4a49fce0db..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This package provides the different implementations of - * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are related to the {@link io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet}, most - * notably: Cargo Nodes. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.cargo; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/package-info.java deleted file mode 100644 index a64244d8cd..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are used in combination with electricity, like the - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Multimeter} or the - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.SolarHelmet} - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/package-info.java deleted file mode 100644 index b4e98ffd64..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/enchanting/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This package contains any electric machines related to enchanting. - * Prominent examples are the - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter} and - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter} - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/package-info.java deleted file mode 100644 index e1e938db31..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This package contains the different implementations of - * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} that are also an - * {@link io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent} with the type {@code CONSUMER}. - * - * Machines do not generate power, they consume it. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/package-info.java deleted file mode 100644 index 0e3cfe961f..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package contains the different implementations of - * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} that also implement the interface - * {@link io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent} - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/package-info.java deleted file mode 100644 index b3262e8206..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains the different implementations of - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/package-info.java deleted file mode 100644 index 46e84ac6f4..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/elevator/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds the {@link io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate} and any - * related classes to making the elevator work. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.elevator; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/package-info.java deleted file mode 100644 index 5aeb74b009..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are related to food. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.food; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/package-info.java deleted file mode 100644 index c9648a3e9e..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This package holds implementations of any {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} that - * deals with the {@link io.github.thebusybiscuit.slimefun4.api.geo.GEOResource} API. - * The most prominent example of this being the - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner} and the - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.geo; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/package-info.java deleted file mode 100644 index 822973f363..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are related to the {@link io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.gps; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/package-info.java deleted file mode 100644 index c36abae61b..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are considered magical items. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/package-info.java deleted file mode 100644 index 637d8ad9be..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds any implementation of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that is an ancient rune with functionality. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/package-info.java deleted file mode 100644 index a8121cce10..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/staves/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds any implementation of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} that is - * considered a "Magical Staff". - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/package-info.java deleted file mode 100644 index f4a6ef052c..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds any {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} related to the - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.Talisman}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/package-info.java deleted file mode 100644 index 3a92307efb..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} that are - * related to healing yourself. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.medical; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFood.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFood.java deleted file mode 100644 index a9471d0968..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/OrganicFood.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; - -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.FoodFabricator; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.accelerators.AnimalGrowthAccelerator; - -/** - * {@link OrganicFood} is created using a {@link FoodFabricator} and can - * be used to fuel an {@link AnimalGrowthAccelerator}. - * - * @author TheBusyBiscuit - * - * @see AnimalGrowthAccelerator - * - */ -public class OrganicFood extends SlimefunItem { - - public static final int OUTPUT = 2; - - @ParametersAreNonnullByDefault - public OrganicFood(ItemGroup itemGroup, SlimefunItemStack item, Material ingredient) { - super(itemGroup, item, RecipeType.FOOD_FABRICATOR, new ItemStack[] { SlimefunItems.TIN_CAN.item(), new ItemStack(ingredient), null, null, null, null, null, null, null }, new SlimefunItemStack(item, OUTPUT).item()); - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/package-info.java deleted file mode 100644 index 0a68f4ec31..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds any miscellaneous {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * implementations. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.misc; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary16.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary16.java deleted file mode 100644 index f69ebc46d6..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary16.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner; - -import java.util.Random; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -/** - * Our {@link OreDictionary} implementation for MC 1.16 or higher. - * - * @author TheBusyBiscuit - * - */ -class OreDictionary16 implements OreDictionary { - - @Override - @ParametersAreNonnullByDefault - public @Nonnull ItemStack getDrops(Material material, Random random) { - return switch (material) { - case COAL_ORE -> new ItemStack(Material.COAL); - case DIAMOND_ORE -> new ItemStack(Material.DIAMOND); - case EMERALD_ORE -> new ItemStack(Material.EMERALD); - case REDSTONE_ORE -> new ItemStack(Material.REDSTONE, 4 + random.nextInt(2)); - case LAPIS_ORE -> new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4)); - case NETHER_QUARTZ_ORE -> new ItemStack(Material.QUARTZ); - case IRON_ORE -> new ItemStack(Material.IRON_ORE); - case GOLD_ORE -> new ItemStack(Material.GOLD_ORE); - case NETHER_GOLD_ORE -> new ItemStack(Material.GOLD_NUGGET, 2 + random.nextInt(4)); - case ANCIENT_DEBRIS -> new ItemStack(Material.ANCIENT_DEBRIS); - default -> new ItemStack(material); - }; - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary17.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary17.java deleted file mode 100644 index 7db6e3948e..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/OreDictionary17.java +++ /dev/null @@ -1,43 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner; - -import java.util.Random; - -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -/** - * Our {@link OreDictionary} implementation for MC 1.17 or higher. - * - * @author TheBusyBiscuit - * - */ -class OreDictionary17 extends OreDictionary16 { - - @Override - @ParametersAreNonnullByDefault - public ItemStack getDrops(Material material, Random random) { - // In 1.17, breaking metal ores should get raw metals. Also support deepslate ores. - return switch (material) { - case COAL_ORE, - DEEPSLATE_COAL_ORE -> new ItemStack(Material.COAL); - case DIAMOND_ORE, - DEEPSLATE_DIAMOND_ORE -> new ItemStack(Material.DIAMOND); - case EMERALD_ORE, - DEEPSLATE_EMERALD_ORE -> new ItemStack(Material.EMERALD); - case REDSTONE_ORE, - DEEPSLATE_REDSTONE_ORE -> new ItemStack(Material.REDSTONE, 4 + random.nextInt(2)); - case LAPIS_ORE, - DEEPSLATE_LAPIS_ORE -> new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4)); - case COPPER_ORE, - DEEPSLATE_COPPER_ORE -> new ItemStack(Material.RAW_COPPER); - case IRON_ORE, - DEEPSLATE_IRON_ORE -> new ItemStack(Material.RAW_IRON); - case GOLD_ORE, - DEEPSLATE_GOLD_ORE -> new ItemStack(Material.RAW_GOLD); - default -> super.getDrops(material, random); - }; - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/package-info.java deleted file mode 100644 index 00d47d6263..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds classes associated with the - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner.IndustrialMiner}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.miner; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/package-info.java deleted file mode 100644 index 27d269c53b..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains all the different implementations of - * {@link io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine} - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/package-info.java deleted file mode 100644 index 7f21ba5a38..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains the different classes for each - * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - */ -package io.github.thebusybiscuit.slimefun4.implementation.items; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/package-info.java deleted file mode 100644 index 6769d846ae..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/teleporter/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are related to the {@link io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.teleporter; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/package-info.java deleted file mode 100644 index 86289513a0..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are tools. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.tools; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java deleted file mode 100644 index ce40980ded..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java +++ /dev/null @@ -1,106 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; - -import java.util.Random; -import java.util.concurrent.ThreadLocalRandom; - -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.Material; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.Monster; -import org.bukkit.entity.Piglin; -import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.WitherSkeleton; -import org.bukkit.entity.Zombie; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.SkullMeta; - -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; - -/** - * The {@link SwordOfBeheading} is a special kind of sword which allows you to obtain - * {@link Zombie}, {@link Skeleton}, {@link Creeper} and {@link Piglin} skulls when killing the respective - * {@link Monster}. - * Additionally, you can also obtain the head of a {@link Player} by killing them too. - * This sword also allows you to have a higher chance of getting the skull of a {@link WitherSkeleton} too. - * - * All chances are managed by an {@link ItemSetting} and can be configured. - * - * @author TheBusyBiscuit - * - */ -public class SwordOfBeheading extends SimpleSlimefunItem { - - private final ItemSetting chanceZombie = new IntRangeSetting(this, "chance.ZOMBIE", 0, 40, 100); - private final ItemSetting chanceSkeleton = new IntRangeSetting(this, "chance.SKELETON", 0, 40, 100); - private final ItemSetting chanceWitherSkeleton = new IntRangeSetting(this, "chance.WITHER_SKELETON", 0, 25, 100); - private final ItemSetting chanceCreeper = new IntRangeSetting(this, "chance.CREEPER", 0, 40, 100); - private final ItemSetting chancePiglin = new IntRangeSetting(this, "chance.PIGLIN", 0, 40, 100); - private final ItemSetting chancePlayer = new IntRangeSetting(this, "chance.PLAYER", 0, 70, 100); - - @ParametersAreNonnullByDefault - public SwordOfBeheading(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(itemGroup, item, recipeType, recipe); - - addItemSetting(chanceZombie, chanceSkeleton, chanceWitherSkeleton, chanceCreeper, chancePiglin, chancePlayer); - } - - @Override - public EntityKillHandler getItemHandler() { - return (e, entity, killer, item) -> { - Random random = ThreadLocalRandom.current(); - - switch (e.getEntityType()) { - case ZOMBIE -> { - if (random.nextInt(100) < chanceZombie.getValue()) { - e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD)); - } - } - case SKELETON -> { - if (random.nextInt(100) < chanceSkeleton.getValue()) { - e.getDrops().add(new ItemStack(Material.SKELETON_SKULL)); - } - } - case CREEPER -> { - if (random.nextInt(100) < chanceCreeper.getValue()) { - e.getDrops().add(new ItemStack(Material.CREEPER_HEAD)); - } - } - case WITHER_SKELETON -> { - if (random.nextInt(100) < chanceWitherSkeleton.getValue()) { - e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL)); - } - } - case PIGLIN -> { - if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_20) && - random.nextInt(100) < chancePiglin.getValue()) { - e.getDrops().add(new ItemStack(Material.PIGLIN_HEAD)); - } - } - case PLAYER -> { - if (random.nextInt(100) < chancePlayer.getValue()) { - ItemStack skull = new ItemStack(Material.PLAYER_HEAD); - - ItemMeta meta = skull.getItemMeta(); - ((SkullMeta) meta).setOwningPlayer((Player) e.getEntity()); - skull.setItemMeta(meta); - - e.getDrops().add(skull); - } - } - default -> {} - } - }; - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/package-info.java deleted file mode 100644 index 748b027ad3..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} - * that are weapons, implementations of - * {@link io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SlimefunBow} for example. - */ -package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/package-info.java deleted file mode 100644 index 36f0cae11c..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/operations/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package contains implementations of {@link io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.operations; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/package-info.java deleted file mode 100644 index 67b4e2fef0..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package contains all implementations of {@link io.github.thebusybiscuit.slimefun4.api.geo.GEOResource}. - */ -package io.github.thebusybiscuit.slimefun4.implementation.resources; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/package-info.java deleted file mode 100644 index ff665f2f5c..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/settings/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This package holds implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting} that are for - * very specific {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem SlimefunItems} and generally not - * very useful out of their context. - */ -package io.github.thebusybiscuit.slimefun4.implementation.settings; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/ClearLagIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/ClearLagIntegration.java deleted file mode 100644 index bd9da15a1a..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/ClearLagIntegration.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.integrations; - -import java.util.Iterator; - -import javax.annotation.Nonnull; - -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - -import me.minebuilders.clearlag.Clearlag; -import me.minebuilders.clearlag.events.EntityRemoveEvent; - -/** - * This handles all integrations with {@link Clearlag}. - * We don't want it to clear our altar items. - * - * @author TheBusyBiscuit - * - */ -class ClearLagIntegration implements Listener { - - private final Slimefun plugin; - - ClearLagIntegration(@Nonnull Slimefun plugin) { - this.plugin = plugin; - } - - public void register() { - plugin.getServer().getPluginManager().registerEvents(this, plugin); - } - - @EventHandler - public void onEntityRemove(EntityRemoveEvent e) { - Iterator iterator = e.getEntityList().iterator(); - - while (iterator.hasNext()) { - Entity n = iterator.next(); - - if (n instanceof Item item && SlimefunUtils.hasNoPickupFlag(item)) { - iterator.remove(); - } - } - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java deleted file mode 100644 index 6b9f2cf28e..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.integrations; - -import javax.annotation.Nonnull; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; - -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent; -import com.gmail.nossr50.util.skills.SkillUtils; - -import io.github.thebusybiscuit.slimefun4.api.events.AutoDisenchantEvent; -import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; - -/** - * This handles all integrations with {@link mcMMO}. - * - * @author TheBusyBiscuit - * - */ -class McMMOIntegration implements Listener { - - private final Slimefun plugin; - - McMMOIntegration(@Nonnull Slimefun plugin) { - this.plugin = plugin; - } - - public void register() { - plugin.getServer().getPluginManager().registerEvents(this, plugin); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onBlockPlacerPlace(BlockPlacerPlaceEvent e) { - // This registers blocks placed by the BlockPlacer as "player-placed" - try { - mcMMO.getPlaceStore().setTrue(e.getBlock()); - } catch (Exception | LinkageError x) { - Slimefun.getIntegrations().logError("mcMMO", x); - } - } - - @EventHandler(ignoreCancelled = true) - public void onItemSalvage(McMMOPlayerSalvageCheckEvent e) { - // Prevent Slimefun items from being salvaged - if (!isSalvageable(e.getSalvageItem())) { - e.setCancelled(true); - Slimefun.getLocalization().sendMessage(e.getPlayer(), "anvil.mcmmo-salvaging"); - } - } - - @EventHandler(ignoreCancelled = true) - public void onAutoDisenchant(AutoDisenchantEvent e) { - try { - SkillUtils.removeAbilityBuff(e.getItem()); - } catch (Exception | LinkageError x) { - Slimefun.getIntegrations().logError("mcMMO", x); - } - } - - /** - * This method checks if an {@link ItemStack} can be salvaged or not. - * We basically don't want players to salvage any {@link SlimefunItem} unless - * it is a {@link VanillaItem}. - * - * @param item - * The {@link ItemStack} to check - * - * @return Whether this item can be safely salvaged - */ - private boolean isSalvageable(@Nonnull ItemStack item) { - SlimefunItem sfItem = SlimefunItem.getByItem(item); - return sfItem == null || sfItem instanceof VanillaItem; - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java deleted file mode 100644 index f9982fec2e..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/OrebfuscatorIntegration.java +++ /dev/null @@ -1,74 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.integrations; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.annotation.Nonnull; - -import org.bukkit.Bukkit; -import org.bukkit.block.Block; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent; -import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.api.events.ReactorExplodeEvent; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; - -import net.imprex.orebfuscator.api.OrebfuscatorService; - -/** - * - * This handles block breaks with orebfuscator - * - * @author NgLoader - * - */ -class OrebfuscatorIntegration implements Listener { - - private final Slimefun plugin; - private OrebfuscatorService service; - - OrebfuscatorIntegration(@Nonnull Slimefun plugin) { - this.plugin = plugin; - } - - /** - * Init orebfuscation service and register listener - */ - public void register() { - this.service = Bukkit.getServer().getServicesManager().getRegistration(OrebfuscatorService.class).getProvider(); - - plugin.getServer().getPluginManager().registerEvents(this, plugin); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onBlockPlacerPlace(BlockPlacerPlaceEvent event) { - this.service.deobfuscate(Arrays.asList(event.getBlock(), event.getBlockPlacer())); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onExplosiveToolBreakBlocks(ExplosiveToolBreakBlocksEvent event) { - Set blocks = new HashSet<>(); - blocks.addAll(event.getAdditionalBlocks()); - blocks.add(event.getPrimaryBlock()); - this.service.deobfuscate(blocks); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onReactorExplode(ReactorExplodeEvent event) { - this.service.deobfuscate(Arrays.asList(event.getLocation().getBlock())); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onGoldPanUse(PlayerRightClickEvent event) { - if (event.getSlimefunItem().isPresent() && event.getClickedBlock().isPresent() && event.getSlimefunItem().get() instanceof GoldPan) { - this.service.deobfuscate(List.of(event.getClickedBlock().get())); - } - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java deleted file mode 100644 index 9fe766e5e0..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ColoredMaterial.java +++ /dev/null @@ -1,263 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.utils; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import javax.annotation.Nonnull; - -import org.apache.commons.lang.Validate; -import org.bukkit.DyeColor; -import org.bukkit.Material; - -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; - -/** - * This class holds a few ordered {@link List Lists} that hold colored variants - * of {@link Material}. - * - * @author TheBusyBiscuit - * - * @see SlimefunTag - * - */ -public enum ColoredMaterial { - - // @formatter:off (We want this to stay formatted like this) - - /** - * This {@link List} contains all wool colors ordered by their appearance ingame. - */ - WOOL(new Material[] { - Material.WHITE_WOOL, - Material.ORANGE_WOOL, - Material.MAGENTA_WOOL, - Material.LIGHT_BLUE_WOOL, - Material.YELLOW_WOOL, - Material.LIME_WOOL, - Material.PINK_WOOL, - Material.GRAY_WOOL, - Material.LIGHT_GRAY_WOOL, - Material.CYAN_WOOL, - Material.PURPLE_WOOL, - Material.BLUE_WOOL, - Material.BROWN_WOOL, - Material.GREEN_WOOL, - Material.RED_WOOL, - Material.BLACK_WOOL - }), - - /** - * This {@link List} contains all carpet colors ordered by their appearance ingame. - */ - CARPET(new Material[] { - Material.WHITE_CARPET, - Material.ORANGE_CARPET, - Material.MAGENTA_CARPET, - Material.LIGHT_BLUE_CARPET, - Material.YELLOW_CARPET, - Material.LIME_CARPET, - Material.PINK_CARPET, - Material.GRAY_CARPET, - Material.LIGHT_GRAY_CARPET, - Material.CYAN_CARPET, - Material.PURPLE_CARPET, - Material.BLUE_CARPET, - Material.BROWN_CARPET, - Material.GREEN_CARPET, - Material.RED_CARPET, - Material.BLACK_CARPET - }), - - /** - * This {@link List} contains all stained glass colors ordered by their appearance ingame. - */ - STAINED_GLASS(new Material[] { - Material.WHITE_STAINED_GLASS, - Material.ORANGE_STAINED_GLASS, - Material.MAGENTA_STAINED_GLASS, - Material.LIGHT_BLUE_STAINED_GLASS, - Material.YELLOW_STAINED_GLASS, - Material.LIME_STAINED_GLASS, - Material.PINK_STAINED_GLASS, - Material.GRAY_STAINED_GLASS, - Material.LIGHT_GRAY_STAINED_GLASS, - Material.CYAN_STAINED_GLASS, - Material.PURPLE_STAINED_GLASS, - Material.BLUE_STAINED_GLASS, - Material.BROWN_STAINED_GLASS, - Material.GREEN_STAINED_GLASS, - Material.RED_STAINED_GLASS, - Material.BLACK_STAINED_GLASS - }), - - /** - * This {@link List} contains all stained glass pane colors ordered by their appearance ingame. - */ - STAINED_GLASS_PANE(new Material[] { - Material.WHITE_STAINED_GLASS_PANE, - Material.ORANGE_STAINED_GLASS_PANE, - Material.MAGENTA_STAINED_GLASS_PANE, - Material.LIGHT_BLUE_STAINED_GLASS_PANE, - Material.YELLOW_STAINED_GLASS_PANE, - Material.LIME_STAINED_GLASS_PANE, - Material.PINK_STAINED_GLASS_PANE, - Material.GRAY_STAINED_GLASS_PANE, - Material.LIGHT_GRAY_STAINED_GLASS_PANE, - Material.CYAN_STAINED_GLASS_PANE, - Material.PURPLE_STAINED_GLASS_PANE, - Material.BLUE_STAINED_GLASS_PANE, - Material.BROWN_STAINED_GLASS_PANE, - Material.GREEN_STAINED_GLASS_PANE, - Material.RED_STAINED_GLASS_PANE, - Material.BLACK_STAINED_GLASS_PANE - }), - - /** - * This {@link List} contains all terracotta colors ordered by their appearance ingame. - */ - TERRACOTTA(new Material[] { - Material.WHITE_TERRACOTTA, - Material.ORANGE_TERRACOTTA, - Material.MAGENTA_TERRACOTTA, - Material.LIGHT_BLUE_TERRACOTTA, - Material.YELLOW_TERRACOTTA, - Material.LIME_TERRACOTTA, - Material.PINK_TERRACOTTA, - Material.GRAY_TERRACOTTA, - Material.LIGHT_GRAY_TERRACOTTA, - Material.CYAN_TERRACOTTA, - Material.PURPLE_TERRACOTTA, - Material.BLUE_TERRACOTTA, - Material.BROWN_TERRACOTTA, - Material.GREEN_TERRACOTTA, - Material.RED_TERRACOTTA, - Material.BLACK_TERRACOTTA - }), - - /** - * This {@link List} contains all glazed terracotta colors ordered by their appearance ingame. - */ - GLAZED_TERRACOTTA(new Material[] { - Material.WHITE_GLAZED_TERRACOTTA, - Material.ORANGE_GLAZED_TERRACOTTA, - Material.MAGENTA_GLAZED_TERRACOTTA, - Material.LIGHT_BLUE_GLAZED_TERRACOTTA, - Material.YELLOW_GLAZED_TERRACOTTA, - Material.LIME_GLAZED_TERRACOTTA, - Material.PINK_GLAZED_TERRACOTTA, - Material.GRAY_GLAZED_TERRACOTTA, - Material.LIGHT_GRAY_GLAZED_TERRACOTTA, - Material.CYAN_GLAZED_TERRACOTTA, - Material.PURPLE_GLAZED_TERRACOTTA, - Material.BLUE_GLAZED_TERRACOTTA, - Material.BROWN_GLAZED_TERRACOTTA, - Material.GREEN_GLAZED_TERRACOTTA, - Material.RED_GLAZED_TERRACOTTA, - Material.BLACK_GLAZED_TERRACOTTA - }), - - /** - * This {@link List} contains all concrete colors ordered by their appearance ingame. - */ - CONCRETE(new Material[] { - Material.WHITE_CONCRETE, - Material.ORANGE_CONCRETE, - Material.MAGENTA_CONCRETE, - Material.LIGHT_BLUE_CONCRETE, - Material.YELLOW_CONCRETE, - Material.LIME_CONCRETE, - Material.PINK_CONCRETE, - Material.GRAY_CONCRETE, - Material.LIGHT_GRAY_CONCRETE, - Material.CYAN_CONCRETE, - Material.PURPLE_CONCRETE, - Material.BLUE_CONCRETE, - Material.BROWN_CONCRETE, - Material.GREEN_CONCRETE, - Material.RED_CONCRETE, - Material.BLACK_CONCRETE - }), - - /** - * This {@link List} contains all shulker box colors ordered by their appearance ingame. - */ - SHULKER_BOX(new Material[] { - Material.WHITE_SHULKER_BOX, - Material.ORANGE_SHULKER_BOX, - Material.MAGENTA_SHULKER_BOX, - Material.LIGHT_BLUE_SHULKER_BOX, - Material.YELLOW_SHULKER_BOX, - Material.LIME_SHULKER_BOX, - Material.PINK_SHULKER_BOX, - Material.GRAY_SHULKER_BOX, - Material.LIGHT_GRAY_SHULKER_BOX, - Material.CYAN_SHULKER_BOX, - Material.PURPLE_SHULKER_BOX, - Material.BLUE_SHULKER_BOX, - Material.BROWN_SHULKER_BOX, - Material.GREEN_SHULKER_BOX, - Material.RED_SHULKER_BOX, - Material.BLACK_SHULKER_BOX - }); - - // @formatter:on - - /** - * This is our {@link List} of {@link Material Materials}, the backbone of this enum. - */ - private final List list; - - /** - * This creates a new constant of {@link ColoredMaterial}. - * The array must have a length of 16 and cannot contain null elements! - * - * @param materials - * The {@link Material Materials} for this {@link ColoredMaterial}. - */ - ColoredMaterial(@Nonnull Material[] materials) { - Validate.noNullElements(materials, "The List cannot contain any null elements"); - Validate.isTrue(materials.length == 16, "Expected 16, received: " + materials.length + ". Did you miss a color?"); - - list = Collections.unmodifiableList(Arrays.asList(materials)); - } - - /** - * This returns an ordered {@link List} of {@link Material Materials} - * that are part o this {@link ColoredMaterial}. - * - * @return An ordered {@link List} of {@link Material Materials} - */ - public @Nonnull List asList() { - return list; - } - - /** - * This returns the {@link Material} at the given index. - * - * @param index - * The index - * - * @return The {@link Material} at that index - */ - public @Nonnull Material get(int index) { - Validate.isTrue(index >= 0 && index < 16, "The index must be between 0 and 15 (inclusive)."); - - return list.get(index); - } - - /** - * This returns the {@link Material} with the given {@link DyeColor}. - * - * @param color - * The {@link DyeColor} - * - * @return The {@link Material} with that {@link DyeColor} - */ - public @Nonnull Material get(@Nonnull DyeColor color) { - Validate.notNull(color, "Color cannot be null!"); - - return get(color.ordinal()); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/package-info.java deleted file mode 100644 index c4f513a0bc..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * This package contains classes centered around our {@link io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap} - * utility. - */ -package io.github.thebusybiscuit.slimefun4.utils.biomes; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedEnchantment.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedEnchantment.java deleted file mode 100644 index d5063ce413..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedEnchantment.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.utils.compatibility; - -import org.bukkit.NamespacedKey; -import org.bukkit.Registry; -import org.bukkit.enchantments.Enchantment; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#86-110 -public class VersionedEnchantment { - - public static final Enchantment EFFICIENCY; - public static final Enchantment UNBREAKING; - public static final Enchantment PROTECTION; - public static final Enchantment SHARPNESS; - public static final Enchantment LUCK_OF_THE_SEA; - public static final Enchantment AQUA_AFFINITY; - public static final Enchantment FORTUNE; - - static { - // DIG_SPEED is renamed to EFFICIENCY in 1.20.5 - EFFICIENCY = getKey("efficiency"); - - // DURABILITY is renamed to UNBREAKING in 1.20.5 - UNBREAKING = getKey("unbreaking"); - - // PROTECTION_ENVIRONMENTAL is renamed to PROTECTION in 1.20.5 - PROTECTION = getKey("protection"); - - // DAMAGE_ALL is renamed to SHARPNESS in 1.20.5 - SHARPNESS = getKey("sharpness"); - - // LUCK is renamed to LUCK_OF_THE_SEA in 1.20.5 - LUCK_OF_THE_SEA = getKey("luck_of_the_sea"); - - // WATER_WORKER is renamed to AQUA_AFFINITY in 1.20.5 - AQUA_AFFINITY = getKey("aqua_affinity"); - - // LOOT_BONUS_BLOCKS is renamed to FORTUNE in 1.20.5 - FORTUNE = getKey("fortune"); - } - - @Nullable - private static Enchantment getKey(@Nonnull String key) { - return Registry.ENCHANTMENT.get(NamespacedKey.minecraft(key)); - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedEntityType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedEntityType.java deleted file mode 100644 index 10ae11e803..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedEntityType.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.utils.compatibility; - -import org.bukkit.NamespacedKey; -import org.bukkit.Registry; -import org.bukkit.entity.EntityType; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#158-193 -public class VersionedEntityType { - - public static final EntityType MOOSHROOM; - public static final EntityType SNOW_GOLEM; - public static final EntityType FIREWORK; - - static { - // MUSHROOM_COW is renamed to MOOSHROOM in 1.20.5 - MOOSHROOM = getKey("mooshroom"); - - // SNOWMAN is renamed to SNOW_GOLEM in 1.20.5 - SNOW_GOLEM = getKey("snow_golem"); - - FIREWORK = getKey("firework_rocket"); - } - - @Nullable - private static EntityType getKey(@Nonnull String key) { - return Registry.ENTITY_TYPE.get(NamespacedKey.minecraft(key)); - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedItemFlag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedItemFlag.java deleted file mode 100644 index 507a903a23..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedItemFlag.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.utils.compatibility; - -import java.lang.reflect.Field; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import org.bukkit.inventory.ItemFlag; - -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - -public class VersionedItemFlag { - - public static final ItemFlag HIDE_ADDITIONAL_TOOLTIP; - - static { - MinecraftVersion version = Slimefun.getMinecraftVersion(); - - HIDE_ADDITIONAL_TOOLTIP = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? ItemFlag.HIDE_ADDITIONAL_TOOLTIP - : getKey("HIDE_POTION_EFFECTS"); - } - - @Nullable - private static ItemFlag getKey(@Nonnull String key) { - try { - Field field = ItemFlag.class.getDeclaredField(key); - return (ItemFlag) field.get(null); - } catch(Exception e) { - return null; - } - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedPotionEffectType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedPotionEffectType.java deleted file mode 100644 index f3dbe6b6d1..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedPotionEffectType.java +++ /dev/null @@ -1,75 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.utils.compatibility; - -import java.lang.reflect.Field; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import org.bukkit.potion.PotionEffectType; - -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - -// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#216-228 -public class VersionedPotionEffectType { - - public static final PotionEffectType SLOWNESS; - public static final PotionEffectType HASTE; - public static final PotionEffectType MINING_FATIGUE; - public static final PotionEffectType STRENGTH; - public static final PotionEffectType INSTANT_HEALTH; - public static final PotionEffectType INSTANT_DAMAGE; - public static final PotionEffectType JUMP_BOOST; - public static final PotionEffectType NAUSEA; - public static final PotionEffectType RESISTANCE; - - static { - MinecraftVersion version = Slimefun.getMinecraftVersion(); - - SLOWNESS = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.SLOWNESS - : getKey("SLOW"); - - HASTE = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.HASTE - : getKey("FAST_DIGGING"); - - MINING_FATIGUE = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.MINING_FATIGUE - : getKey("SLOW_DIGGING"); - - STRENGTH = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.STRENGTH - : getKey("INCREASE_DAMAGE"); - - INSTANT_HEALTH = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.INSTANT_HEALTH - : getKey("HEAL"); - - INSTANT_DAMAGE = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.INSTANT_DAMAGE - : getKey("HARM"); - - JUMP_BOOST = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.JUMP_BOOST - : getKey("JUMP"); - - NAUSEA = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.NAUSEA - : getKey("CONFUSION"); - - RESISTANCE = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionEffectType.RESISTANCE - : getKey("DAMAGE_RESISTANCE"); - } - - @Nullable - private static PotionEffectType getKey(@Nonnull String key) { - try { - Field field = PotionEffectType.class.getDeclaredField(key); - return (PotionEffectType) field.get(null); - } catch(Exception e) { - return null; - } - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedPotionType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedPotionType.java deleted file mode 100644 index 1713d77baf..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/compatibility/VersionedPotionType.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.utils.compatibility; - -import java.lang.reflect.Field; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import org.bukkit.potion.PotionType; - -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - -// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/FieldRename.java?until=2a6207fe150b6165722fce94c83cc1f206620ab5&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Flegacy%2FFieldRename.java#242-250 -public class VersionedPotionType { - - public static final PotionType LEAPING; - public static final PotionType SWIFTNESS; - public static final PotionType HEALING; - public static final PotionType HARMING; - public static final PotionType REGENERATION; - - static { - MinecraftVersion version = Slimefun.getMinecraftVersion(); - - LEAPING = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionType.LEAPING - : getKey("JUMP"); - - SWIFTNESS = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionType.SWIFTNESS - : getKey("SPEED"); - - HEALING = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionType.HEALING - : getKey("INSTANT_HEAL"); - - HARMING = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionType.HARMING - : getKey("INSTANT_DAMAGE"); - - REGENERATION = version.isAtLeast(MinecraftVersion.MINECRAFT_1_20_5) - ? PotionType.REGENERATION - : getKey("REGEN"); - } - - @Nullable - private static PotionType getKey(@Nonnull String key) { - try { - Field field = PotionType.class.getDeclaredField(key); - return (PotionType) field.get(null); - } catch(Exception e) { - return null; - } - } -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/package-info.java deleted file mode 100644 index 9cd7707847..0000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package holds utilities related to the {@link io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag} enum. - */ -package io.github.thebusybiscuit.slimefun4.utils.tags; \ No newline at end of file diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockSlimefunItem.java b/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockSlimefunItem.java deleted file mode 100644 index 4b374eb309..0000000000 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/test/mocks/MockSlimefunItem.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.test.mocks; - -import org.bukkit.inventory.ItemStack; - -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; - -public class MockSlimefunItem extends SlimefunItem { - - public MockSlimefunItem(ItemGroup itemGroup, ItemStack item, String id) { - super(itemGroup, new SlimefunItemStack(id, item), RecipeType.NULL, new ItemStack[9]); - } - -}