Compare commits

...
96 Commits
Author SHA1 Message Date
Andre_601 38d6ac3972 Merge pull request #94 from Andre601/fix/81-noclassdeffoundexception-issue
Fix ProtocolLib component issue
2023-05-08 17:38:06 +02:00
Andre601 360b961221 Bump version 2023-05-08 17:34:57 +02:00
Andre601 ef22ede56d Fix ProtocolLib component issue 2023-05-08 17:03:09 +02:00
Andre_601 ec9ea799cf Merge pull request #93 from Andre601/dependabot/pip/mkdocs-material-9.1.9
Bump mkdocs-material from 9.1.8 to 9.1.9
2023-05-02 18:12:08 +02:00
dependabot[bot] 99f762ff18 Bump mkdocs-material from 9.1.8 to 9.1.9
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.1.8 to 9.1.9.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.1.8...9.1.9)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-02 16:04:19 +00:00
Andre601 2bd59ff554 Load JoinEvent properly on Paper 2023-04-26 23:21:07 +02:00
Andre601 53157a7c06 Bump version 2023-04-26 23:11:20 +02:00
Andre_601 bfc39ab172 Merge pull request #91 from Andre601/feature/plugin-improvements
Plugin improvements
2023-04-26 23:08:39 +02:00
Andre_601 fa44192bd3 Ignore non-code files 2023-04-26 18:30:58 +02:00
Andre_601 53fc434bdd Merge pull request #92 from Andre601/dependabot/pip/mkdocs-material-9.1.8
Bump mkdocs-material from 9.1.7 to 9.1.8
2023-04-26 18:28:42 +02:00
dependabot[bot] b6152372a8 Bump mkdocs-material from 9.1.7 to 9.1.8
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.1.7 to 9.1.8.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.1.7...9.1.8)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 16:03:16 +00:00
Andre_601 5441d2bd96 Merge pull request #88 from Andre601/dependabot/maven/velocity/com.squareup.okhttp3-okhttp-4.11.0
Bump okhttp from 4.10.0 to 4.11.0 in /velocity
2023-04-24 18:35:57 +02:00
Andre_601 2d358f76c0 Merge pull request #89 from Andre601/dependabot/maven/core/com.squareup.okhttp3-okhttp-4.11.0
Bump okhttp from 4.10.0 to 4.11.0 in /core
2023-04-24 18:34:34 +02:00
Andre_601 d1cbaa3ef6 Merge pull request #90 from Andre601/dependabot/pip/mkdocs-material-9.1.7
Bump mkdocs-material from 9.1.6 to 9.1.7
2023-04-24 18:34:05 +02:00
dependabot[bot] 29513d953d Bump mkdocs-material from 9.1.6 to 9.1.7
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.1.6 to 9.1.7.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.1.6...9.1.7)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-24 16:06:42 +00:00
dependabot[bot] 365ec3d6f5 Bump okhttp from 4.10.0 to 4.11.0 in /core
Bumps [okhttp](https://github.com/square/okhttp) from 4.10.0 to 4.11.0.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okhttp/compare/parent-4.10.0...parent-4.11.0)

---
updated-dependencies:
- dependency-name: com.squareup.okhttp3:okhttp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-24 16:02:45 +00:00
dependabot[bot] d4babddc31 Bump okhttp from 4.10.0 to 4.11.0 in /velocity
Bumps [okhttp](https://github.com/square/okhttp) from 4.10.0 to 4.11.0.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okhttp/compare/parent-4.10.0...parent-4.11.0)

---
updated-dependencies:
- dependency-name: com.squareup.okhttp3:okhttp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-24 16:02:17 +00:00
Andre601 648b656dd4 Reduce duplicate code. 2023-04-22 00:04:21 +02:00
Andre601 b2b71144d9 Improve plugin code... I guess? 2023-04-21 23:34:22 +02:00
Andre601 f696fc2160 Add missing perms and command info 2023-04-16 23:35:39 +02:00
Andre_601 97a71958e1 Add permission 2023-04-14 23:32:19 +02:00
Andre_601 b15d5f0633 Add permissions 2023-04-14 23:32:03 +02:00
Andre601 b4e39ca985 Add examples to profiles page 2023-04-13 16:24:56 +02:00
Andre_601 5aae2cccdc Add comment info output 2023-04-11 21:48:11 +02:00
Andre_601 c7ccd48037 Add some info lines 2023-04-11 21:47:31 +02:00
Andre_601 2b6c904fbf Update pr-comment.yml 2023-04-11 21:36:16 +02:00
Andre_601 eeefea3f6a Make finding comment more precise 2023-04-11 21:33:45 +02:00
Andre_601 2840c29a90 Merge pull request #85 from Andre601/dependabot/pip/mkdocs-material-9.1.6
Bump mkdocs-material from 9.1.5 to 9.1.6
2023-04-10 18:07:20 +02:00
Andre_601 862e631405 Merge pull request #84 from Andre601/dependabot/maven/core/net.kyori-adventure-text-serializer-legacy-4.13.1
Bump adventure-text-serializer-legacy from 4.13.0 to 4.13.1 in /core
2023-04-10 18:06:45 +02:00
dependabot[bot] f00737b0f0 Bump mkdocs-material from 9.1.5 to 9.1.6
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.1.5 to 9.1.6.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.1.5...9.1.6)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 16:06:42 +00:00
Andre_601 2d4d1d3136 Merge pull request #83 from Andre601/dependabot/maven/core/net.kyori-adventure-api-4.13.1
Bump adventure-api from 4.13.0 to 4.13.1 in /core
2023-04-10 18:06:38 +02:00
Andre_601 04d255bb54 Merge pull request #82 from Andre601/dependabot/maven/core/net.kyori-adventure-text-minimessage-4.13.1
Bump adventure-text-minimessage from 4.13.0 to 4.13.1 in /core
2023-04-10 18:06:30 +02:00
dependabot[bot] f77db9c760 Bump adventure-text-serializer-legacy from 4.13.0 to 4.13.1 in /core
Bumps [adventure-text-serializer-legacy](https://github.com/KyoriPowered/adventure) from 4.13.0 to 4.13.1.
- [Release notes](https://github.com/KyoriPowered/adventure/releases)
- [Commits](https://github.com/KyoriPowered/adventure/compare/v4.13.0...v4.13.1)

---
updated-dependencies:
- dependency-name: net.kyori:adventure-text-serializer-legacy
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 16:03:03 +00:00
dependabot[bot] 9cde35aa2f Bump adventure-api from 4.13.0 to 4.13.1 in /core
Bumps [adventure-api](https://github.com/KyoriPowered/adventure) from 4.13.0 to 4.13.1.
- [Release notes](https://github.com/KyoriPowered/adventure/releases)
- [Commits](https://github.com/KyoriPowered/adventure/compare/v4.13.0...v4.13.1)

---
updated-dependencies:
- dependency-name: net.kyori:adventure-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 16:02:53 +00:00
dependabot[bot] 13ca53140c Bump adventure-text-minimessage from 4.13.0 to 4.13.1 in /core
Bumps [adventure-text-minimessage](https://github.com/KyoriPowered/adventure) from 4.13.0 to 4.13.1.
- [Release notes](https://github.com/KyoriPowered/adventure/releases)
- [Commits](https://github.com/KyoriPowered/adventure/compare/v4.13.0...v4.13.1)

---
updated-dependencies:
- dependency-name: net.kyori:adventure-text-minimessage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 16:02:46 +00:00
Andre_601 bc1d0722fa Merge pull request #80 from Andre601/feature/gh-actions-include-commit
Include Commit SHA in PR builds
2023-04-08 02:12:09 +02:00
Andre601 6201342ca7 Trigger new workflow 2023-04-08 02:06:42 +02:00
Andre_601 801e0a2749 Use PR SHA 2023-04-08 02:04:22 +02:00
Andre601 10718e6d03 Include Commit SHA in PR builds 2023-04-08 01:52:31 +02:00
Andre601 03203345c0 Include commit SHA for PR builds 2023-04-08 01:49:23 +02:00
Andre601 3ade0952e2 Folia support 2023-04-06 21:22:33 +02:00
Andre_601 f0e30d47dc typo fixes 2023-04-05 19:37:11 +02:00
Andre_601 bb94510858 Update URL and add expire date 2023-04-05 19:33:03 +02:00
Andre_601 c9d94619dd Merge pull request #77 from Andre601/dependabot/github_actions/peter-evans/create-or-update-comment-3
Bump peter-evans/create-or-update-comment from 2 to 3
2023-04-05 18:59:21 +02:00
dependabot[bot] 7ab8749421 Bump peter-evans/create-or-update-comment from 2 to 3
Bumps [peter-evans/create-or-update-comment](https://github.com/peter-evans/create-or-update-comment) from 2 to 3.
- [Release notes](https://github.com/peter-evans/create-or-update-comment/releases)
- [Commits](https://github.com/peter-evans/create-or-update-comment/compare/v2...v3)

---
updated-dependencies:
- dependency-name: peter-evans/create-or-update-comment
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-05 16:00:47 +00:00
Andre_601 a9216cc82c Improve badges 2023-04-05 17:13:28 +02:00
Andre_601 f14ef643b8 Improve badge 2023-04-05 17:10:47 +02:00
Andre_601 cc876d2f21 Fix Java version 2023-04-05 16:57:20 +02:00
Andre_601 0f8693add2 typo fixes 2023-04-05 16:50:55 +02:00
Andre_601 dcc9d18dbe typo fixes 2023-04-05 16:50:29 +02:00
Andre_601 f579aa0088 Fix broken ref 2023-04-05 16:48:19 +02:00
Andre601 579b945fbd Update workflow 2023-04-04 15:55:28 +02:00
Andre601 664bea8109 Create actions for PR previews. 2023-04-04 15:53:13 +02:00
Andre601 73d94e99e4 Fix length check 2023-04-03 21:26:09 +02:00
Andre601 389ed1df53 Improve HangarUploader 2023-04-03 21:22:01 +02:00
Andre601 5f4a07cb71 Remove cache 2023-04-03 20:59:23 +02:00
Andre601 b16f5e193c fix wrong path (hopefully) 2023-04-03 20:56:58 +02:00
Andre601 1c423e6cfa Add debug workflow 2023-04-03 20:52:10 +02:00
Andre601 a27dcd5248 Fix workflow file 2023-04-03 20:42:08 +02:00
Andre601 17bd1782fb Remove Paper module 2023-04-03 20:33:52 +02:00
Andre_601 96c44dafe2 Merge pull request #75 from Andre601/feature/hangar-automation
Automate Hangar publishing
2023-04-03 20:30:24 +02:00
Andre601 d4d9a7e3c5 Temporarely disable pr-build action 2023-04-03 20:29:32 +02:00
Andre601 9f0f7297f0 Final touches 2023-04-03 20:20:16 +02:00
Andre601 691cb14c63 Merge actions 2023-04-03 18:37:44 +02:00
Andre601 8670ea026e Pretty-print date (Also temp remove ViaVersion) 2023-04-03 17:40:09 +02:00
Andre601 27c019c00d Remove posting of the JSON Body 2023-04-03 17:25:33 +02:00
Andre601 d34ea9c2ad Further reduce dependency sizes 2023-04-03 17:21:47 +02:00
Andre601 74a61f2e09 Don't include ViaVersion dependency. 2023-04-03 16:33:36 +02:00
Andre601 5e550d5a7f Add JSON body for debugging 2023-04-03 15:13:11 +02:00
Andre601 b1180c0a8e Make plugin run on Folia 2023-04-03 01:38:40 +02:00
Andre601 fc4253acce Include body in error logging 2023-04-03 01:37:48 +02:00
Andre601 a4e2cc29d5 Add more logging messages 2023-04-03 01:24:19 +02:00
Andre601 95097a581a Fix jar names and add logback.xml 2023-04-03 01:10:33 +02:00
Andre601 aff3aefb72 Add mainClass attribute 2023-04-03 01:04:22 +02:00
Andre_601 089e56be70 Set working-directory 2023-04-03 00:58:05 +02:00
Andre601 e7b8f1a0dc First attempt at hangar automation... 2023-04-03 00:54:17 +02:00
Andre_601 a2252f55c4 Update hangar.yml 2023-04-03 00:53:24 +02:00
Andre_601 dcd6a1e867 try with just one file 2023-04-02 23:04:46 +02:00
Andre_601 24bf5193ff fix file names 2023-04-02 22:50:14 +02:00
Andre_601 2e0068115d Create hangar.yml 2023-04-02 22:43:29 +02:00
Andre_601 1accbfb5f0 Merge pull request #73 from Andre601/dependabot/pip/mkdocs-material-9.1.5
Bump mkdocs-material from 9.1.4 to 9.1.5
2023-03-31 18:10:44 +02:00
dependabot[bot] f0f520d12b Bump mkdocs-material from 9.1.4 to 9.1.5
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.1.4 to 9.1.5.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.1.4...9.1.5)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-31 16:03:53 +00:00
Andre601 3edef1c2e4 Bump API and plugin version for release 2023-03-29 18:41:31 +02:00
Andre_601 0c835da51a Merge pull request #72 from Andre601/dependabot/maven/velocity/org.bstats-bstats-velocity-3.0.2
Bump bstats-velocity from 3.0.1 to 3.0.2 in /velocity
2023-03-29 18:31:46 +02:00
dependabot[bot] 1dc937e7b6 Bump bstats-velocity from 3.0.1 to 3.0.2 in /velocity
Bumps [bstats-velocity](https://github.com/Bastian/bStats-Metrics) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/Bastian/bStats-Metrics/releases)
- [Commits](https://github.com/Bastian/bStats-Metrics/compare/v3.0.1...v3.0.2)

---
updated-dependencies:
- dependency-name: org.bstats:bstats-velocity
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-29 16:10:44 +00:00
Andre_601 8d63d92ab0 Merge pull request #71 from Andre601/dependabot/maven/paper/org.bstats-bstats-bukkit-3.0.2
Bump bstats-bukkit from 3.0.1 to 3.0.2 in /paper
2023-03-29 18:02:40 +02:00
dependabot[bot] 2ade1c2506 Bump bstats-bukkit from 3.0.1 to 3.0.2 in /paper
Bumps [bstats-bukkit](https://github.com/Bastian/bStats-Metrics) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/Bastian/bStats-Metrics/releases)
- [Commits](https://github.com/Bastian/bStats-Metrics/compare/v3.0.1...v3.0.2)

---
updated-dependencies:
- dependency-name: org.bstats:bstats-bukkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-29 16:01:29 +00:00
Andre_601 c1b699aab7 Merge pull request #69 from Andre601/dependabot/maven/paper/com.viaversion-viaversion-api-4.6.2
Bump viaversion-api from 4.6.1 to 4.6.2 in /paper
2023-03-27 18:08:25 +02:00
dependabot[bot] 6d5fc7a697 Bump viaversion-api from 4.6.1 to 4.6.2 in /paper
Bumps viaversion-api from 4.6.1 to 4.6.2.

---
updated-dependencies:
- dependency-name: com.viaversion:viaversion-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-27 16:07:49 +00:00
Andre_601 a5acd73482 Add "Available on SpigotMC" badge 2023-03-24 23:03:16 +01:00
Andre_601 f1afcc0fd8 Merge pull request #68 from Andre601/dependabot/pip/mkdocs-material-9.1.4
Bump mkdocs-material from 9.1.3 to 9.1.4
2023-03-24 17:23:02 +01:00
dependabot[bot] 9922485c34 Bump mkdocs-material from 9.1.3 to 9.1.4
Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.1.3 to 9.1.4.
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.1.3...9.1.4)

---
updated-dependencies:
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-24 16:13:48 +00:00
Andre601 9ee543fe28 Use old Command handling for Spigot 2023-03-23 20:11:30 +01:00
Andre_601 da4eccdfcc remove spigot 2023-03-23 20:00:45 +01:00
Andre_601 89f5a45809 Use own fork for hangar badge 2023-03-23 18:24:25 +01:00
Andre601 29664fde70 Fix wrong artifact name 2023-03-23 16:50:39 +01:00
68 changed files with 1192 additions and 1312 deletions

No files matched your search

+100
View File
@@ -0,0 +1,100 @@
name: Create PR Artifacts
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
branches:
- master
paths-ignore:
- '.github/**'
- 'docs/**'
- '.gitignore'
- 'LICENSE'
- 'README.md'
- 'mkdocs.yml'
- 'requirements.txt'
concurrency:
group: '${{ github.workflow }}-${{ github.head_ref }}'
cancel-in-progress: false
permissions:
issues: write
pull-requests: write
jobs:
buildArtifacts:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Find Comment
uses: peter-evans/find-comment@v2
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- pr-build comment -->'
- name: Print Comment info
run: |
echo "Comment ID: ${{ steps.find-comment.outputs.comment-id }}"
echo "Comment Author: ${{ steps.find-comment.outputs.comment-author }}"
echo "Comment created at: ${{ steps.find-comment.outputs.comment-created-at }}"
- name: Post/Update Comment
uses: peter-evans/create-or-update-comment@v3
id: comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |-
<!-- pr-build comment -->
![badge]
Please wait while we're building the Jar files for this Pull request...
[badge]: https://img.shields.io/badge/Building...-0d1117?style=for-the-badge&labelColor=7a8490&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNNC43NSAyaDE0LjVhLjc1Ljc1IDAgMCAxIDAgMS41aC0uNzV2Mi45ODJhNC43NSA0Ljc1IDAgMCAxLTIuMjE1IDQuMDE3bC0yLjA0NCAxLjI5YS4yNS4yNSAwIDAgMCAwIC40MjJsMi4wNDQgMS4yOWE0Ljc1IDQuNzUgMCAwIDEgMi4yMTUgNC4wMTdWMjAuNWguNzVhLjc1Ljc1IDAgMCAxIDAgMS41SDQuNzVhLjc1Ljc1IDAgMCAxIDAtMS41aC43NXYtMi45ODJhNC43NSA0Ljc1IDAgMCAxIDIuMjE1LTQuMDE3bDIuMDQ0LTEuMjlhLjI1LjI1IDAgMCAwIDAtLjQyMmwtMi4wNDQtMS4yOUE0Ljc1IDQuNzUgMCAwIDEgNS41IDYuNDgyVjMuNWgtLjc1YS43NS43NSAwIDAgMSAwLTEuNVpNMTcgMy41SDd2Mi45ODJBMy4yNSAzLjI1IDAgMCAwIDguNTE2IDkuMjNsMi4wNDQgMS4yOWExLjc1IDEuNzUgMCAwIDEgMCAyLjk2bC0yLjA0NCAxLjI5QTMuMjUgMy4yNSAwIDAgMCA3IDE3LjUxOFYyMC41aDEwdi0yLjk4MmEzLjI1IDMuMjUgMCAwIDAtMS41MTYtMi43NDhsLTIuMDQ0LTEuMjlhMS43NSAxLjc1IDAgMCAxIDAtMi45NmwyLjA0NC0xLjI5QTMuMjUgMy4yNSAwIDAgMCAxNyA2LjQ4MloiPjwvcGF0aD48L3N2Zz4=
- name: Set up JDK 1.16
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '16'
cache: 'maven'
- name: Obtain short Commit SHA
id: get-commit
run: 'echo "sha_short=$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" >> $GITHUB_OUTPUT'
- name: Build Jar files
run: mvn clean install
env:
COMMIT_SHA: ${{ steps.get-commit.outputs.sha_short }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: AdvancedServerList-Artifacts
path: '*/target/AdvancedServerList-*.jar'
if-no-files-found: error
- name: Update Comment (Failure)
if: failure()
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.comment.outputs.comment-id }}
edit-mode: replace
body: |-
<!-- pr-build comment -->
![badge]
The Build of this Pull request failed.
Please check the below linked logs for a possible cause.
| Name | Link |
| ------ | ----------------------------------------------------------------------------------- |
| Commit | ${{ github.event.pull_request.head.sha }} |
| Logs | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
[badge]: https://img.shields.io/badge/Build_Failure!-0d1117?style=for-the-badge&labelColor=f85149&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNNS43MiA1LjcyYS43NS43NSAwIDAgMSAxLjA2IDBMMTIgMTAuOTRsNS4yMi01LjIyYS43NDkuNzQ5IDAgMCAxIDEuMjc1LjMyNi43NDkuNzQ5IDAgMCAxLS4yMTUuNzM0TDEzLjA2IDEybDUuMjIgNS4yMmEuNzQ5Ljc0OSAwIDAgMS0uMzI2IDEuMjc1Ljc0OS43NDkgMCAwIDEtLjczNC0uMjE1TDEyIDEzLjA2bC01LjIyIDUuMjJhLjc1MS43NTEgMCAwIDEtMS4wNDItLjAxOC43NTEuNzUxIDAgMCAxLS4wMTgtMS4wNDJMMTAuOTQgMTIgNS43MiA2Ljc4YS43NS43NSAwIDAgMSAwLTEuMDZaIj48L3BhdGg+PC9zdmc+
+99
View File
@@ -0,0 +1,99 @@
name: Comment on Pull request
on:
workflow_run:
types:
- completed
workflows:
- 'Create PR Artifacts'
permissions:
issues: write
pull-requests: write
jobs:
comment:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Get Artifact and Pull request info
env:
GITHUB_TOKEN: ${{ github.token }} # No idea why this is set here when ${{ secrets.GITHUB_TOKEN }} is a thing...
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Previous Job ID: $PREVIOUS_JOB_ID"
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV"
SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Previous Suite ID: $SUITE_ID"
echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV"
ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
--jq ".artifacts.[] |
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
select(.expired==false) |
.id")
echo "Artifact ID: $ARTIFACT_ID"
echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV"
ARTIFACT_EXPIRE_DATE=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
--jq ".artifacts.[] |
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
select(.expired==false) |
.expires_at")
echo "Artifact Expire Date: $ARTIFACT_EXPIRE_DATE"
echo "ARTIFACT_EXPIRE_DATE=$ARTIFACT_EXPIRE_DATE" >> "$GITHUB_ENV"
PR_NUMBER=$(jq -r '.pull_requests[0].number' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Pull request Number: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"
HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Head SHA: $HEAD_SHA"
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"
- name: Find Comment
uses: peter-evans/find-comment@v2
id: find-comment
with:
issue-number: ${{ env.PR_NUMBER }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- pr-build comment -->'
- name: Print Comment info
run: |
echo "Comment ID: ${{ steps.find-comment.outputs.comment-id }}"
echo "Comment Author: ${{ steps.find-comment.outputs.comment-author }}"
echo "Comment created at: ${{ steps.find-comment.outputs.comment-created-at }}"
- name: Update Comment
env:
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}"
ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}"
ARTIFACT_EXPIRE_DATE: "${{ env.ARTIFACT_EXPIRE_DATE }}"
HEAD_SHA: "${{ env.HEAD_SHA }}"
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ env.PR_NUMBER }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |-
<!-- pr-build comment -->
![badge]
Build Successful! You can find a link to the downloadable artifact below.
Expire Date: `${{ env.ARTIFACT_EXPIRE_DATE }}`
| Name | Link |
| -------- | ----------------------- |
| Commit | ${{ env.HEAD_SHA }} |
| Logs | ${{ env.JOB_PATH }} |
| Download | ${{ env.ARTIFACT_URL }} |
[badge]: https://img.shields.io/badge/Build_Success!-0d1117?style=for-the-badge&labelColor=3fb950&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZmZmZmZmIj48cGF0aCBkPSJNMjEuMDMgNS43MmEuNzUuNzUgMCAwIDEgMCAxLjA2bC0xMS41IDExLjVhLjc0Ny43NDcgMCAwIDEtMS4wNzItLjAxMmwtNS41LTUuNzVhLjc1Ljc1IDAgMSAxIDEuMDg0LTEuMDM2bDQuOTcgNS4xOTVMMTkuOTcgNS43MmEuNzUuNzUgMCAwIDEgMS4wNiAwWiI+PC9wYXRoPjwvc3ZnPg==
+40 -30
View File
@@ -13,8 +13,16 @@ on:
jobs:
buildJars:
runs-on: ubuntu-latest
outputs:
plugin_release: ${{ steps.github-release.outputs.PLUGIN_RELEASE }}
steps:
- uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Version from Release
id: github-release
run: |
version=$(echo ${{ github.event.release.tag_name }} | cut -d'v' -f2)
echo "PLUGIN_RELEASE=$version" >> $GITHUB_OUTPUT
- name: Set up JDK 1.16
uses: actions/setup-java@v3
with:
@@ -23,25 +31,13 @@ jobs:
cache: 'maven'
- name: Build Jar files
run: mvn clean install
- name: Save BungeeCord Jar file
- name: Save All files
uses: actions/upload-artifact@v3
with:
name: asl-bungeecord
path: bungeecord/target/AdvancedServerList-*.jar
if-no-files-found: error
retention-days: 1
- name: Save Bukkit Jar file
uses: actions/upload-artifact@v3
with:
name: asl-spigot
path: bukkit/target/AdvancedServerList-*.jar
if-no-files-found: error
retention-days: 1
- name: Save Velocity Jar file
uses: actions/upload-artifact@v3
with:
name: asl-velocity
path: velocity/target/AdvancedServerList-*.jar
name: asl-files
path: |
*/target/AdvancedServerList-*.jar
hangar-uploader/target/HangarUploader.jar
if-no-files-found: error
retention-days: 1
publish:
@@ -68,19 +64,13 @@ jobs:
- name: Get Jar files
uses: actions/download-artifact@v3
with:
name: asl-${{ matrix.directory }}
path: ${{ matrix.directory }}/target
- name: Get Version
id: github-release
run: |
version=$(echo ${{ github.event.release.tag_name }} | cut -d'v' -f2)
echo "PLUGIN_RELEASE=$version" >> $GITHUB_OUTPUT
- name: Upload AdvancedServerList (${{ matrix.loaders }}) to GitHub and Modrinth
name: asl-files
- name: Upload AdvancedServerList v${{ needs.buildJars.outputs.plugin_release }} (${{ matrix.loaders }}) to GitHub and Modrinth
if: '!github.event.release.prerelease'
uses: Kir-Antipov/mc-publish@v3.2
with:
name: ${{ github.event.release.tag_name }} (${{ matrix.platforms }})
version: ${{ steps.github-release.outputs.PLUGIN_RELEASE }}
version: ${{ needs.buildJars.outputs.plugin_release }}
version-type: release
files: ${{ matrix.directory}}/target/AdvancedServerList-*.jar
files-secondary: ""
@@ -97,12 +87,12 @@ jobs:
modrinth-featured: false
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload AdvancedServerList (${{ matrix.loaders }}) to GitHub and Modrinth [Pre-Release]
- name: Upload AdvancedServerList v${{ needs.buildJars.outputs.plugin_release }} (${{ matrix.loaders }}) to GitHub and Modrinth [Pre-Release]
if: 'github.event.release.prerelease'
uses: Kir-Antipov/mc-publish@v3.2
with:
name: ${{ github.event.release.tag_name }} (${{ matrix.platforms }})
version: ${{ steps.github-release.outputs.PLUGIN_RELEASE }}
version: ${{ needs.buildJars.outputs.plugin_release }}
version-type: beta
files: ${{ matrix.directory }}/target/AdvancedServerList-*.jar
files-secondary: ""
@@ -118,4 +108,24 @@ jobs:
modrinth-id: xss83sOY
modrinth-featured: false
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
publishHangar:
needs: [buildJars]
runs-on: ubuntu-latest
steps:
- name: Set up JDK 1.16
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '16'
- name: Download Release Assets
uses: actions/download-artifact@v3
with:
name: asl-files
- name: Move HangarUploader.jar
working-directory: hangar-uploader/target/
run: mv HangarUploader.jar ../../
- name: Execute HangarUploader.jar
run: java -jar HangarUploader.jar ${{ secrets.HANGAR_TOKEN }} ${{ needs.buildJars.outputs.plugin_release }} ${{ github.event.release.prerelease }}
env:
GITHUB_RELEASE_BODY: ${{ github.event.release.body }}
+21 -11
View File
@@ -1,26 +1,36 @@
# AdvancedServerList
<a href="https://modrinth.com/plugin/advancedserverlist" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/available/modrinth_vector.svg" height="64" align="right" alt="modrinth" title="Available on Modrinth">
</a>
AdvancedServerList is a plugin that allowys you to customize your server's MOTD, favicon, Player count text and player count hover displayed in a player's multiplayer server list based on conditions and priorities.
## Downloads
<a href="https://modrinth.com/plugin/advancedserverlist" target="_blank">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact/available/modrinth_vector.svg" height="46" alt="modrinth" title="Available on Modrinth">
</a>
<br>
<a href="https://hangar.papermc.io/Andre_601/AdvancedServerList" target="_blank">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact/available/hangar_vector.svg" height="46" alt="hangar" title="Available on Hangar">
</a>
<br>
<a href="https://www.spigotmc.org/resources/102910" target="_blank">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@b9ff12b/assets/compact/available/spigot_vector.svg" height="46" alt="spigot" title="Available on SpigotMC">
</a>
## Supported Platforms
<a href="https://www.spigotmc.org" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/supported/spigot_vector.svg" height="64" alt="platform-spigot" title="Tested on Spigot">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact-minimal/supported/spigot_vector.svg" height="64" alt="platform-spigot" title="Tested on Spigot">
</a>
<a href="https://papermc.io" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/supported/paper_vector.svg" height="64" alt="platform-paper" title="Tested on Paper">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact-minimal/supported/paper_vector.svg" height="64" alt="platform-paper" title="Tested on Paper">
</a>
<a href="https://www.spigotmc.org" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/supported/bungeecord_vector.svg" height="64" alt="platform-bungeecord" title="Tested on BungeeCord">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact-minimal/supported/bungeecord_vector.svg" height="64" alt="platform-bungeecord" title="Tested on BungeeCord">
</a>
<a href="https://www.papermc.io" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/supported/waterfall_vector.svg" height="64" alt="platform-waterfall" title="Tested on Waterfall">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact-minimal/supported/waterfall_vector.svg" height="64" alt="platform-waterfall" title="Tested on Waterfall">
</a>
<a href="https://velocitypowered.com" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/supported/velocity_vector.svg" height="64" alt="platform-velocity" title="Tested on Velocity">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact-minimal/supported/velocity_vector.svg" height="64" alt="platform-velocity" title="Tested on Velocity">
</a>
## What is a Server List Profile?
@@ -77,13 +87,13 @@ You can disable this in the global bStats config file located in `/plugins/bstat
## Support
<a href="https://discord.gg/6dazXp6" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/social/discord-singular_vector.svg" height="64" alt="discord" title="Join my Discord Server">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact-minimal/social/discord-singular_vector.svg" height="64" alt="discord" title="Join my Discord Server">
</a>
<a href="https://app.revolt.chat/invite/74TpERXA" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/social/revolt-singular_vector.svg" height="64" alt="revolt" title="Join my Revolt Server">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact-minimal/social/revolt-singular_vector.svg" height="64" alt="revolt" title="Join my Revolt Server">
</a>
<a href="https://blobfox.coffee/@andre_601" target="_blank">
<img src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/compact-minimal/social/mastodon-singular_vector.svg" height="64" alt="mastodon" title="Chat with me on Mastodon">
<img src="https://cdn.jsdelivr.net/gh/Andre601/devins-badges@13e0142/assets/compact-minimal/social/mastodon-singular_vector.svg" height="64" alt="mastodon" title="Chat with me on Mastodon">
</a>
<!-- Links -->
+5 -7
View File
@@ -95,6 +95,7 @@
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
@@ -105,7 +106,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -117,12 +118,13 @@
<dependency>
<groupId>com.viaversion</groupId>
<artifactId>viaversion-api</artifactId>
<version>4.6.1</version>
<version>4.6.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>AdvancedServerList-Bukkit-${plugin.version}</finalName>
<finalName>AdvancedServerList-Bukkit-${plugin.version}${project.build.commit}</finalName>
<resources>
<resource>
<filtering>true</filtering>
@@ -149,10 +151,6 @@
<pattern>org.bstats</pattern>
<shadedPattern>ch.andre601.advancedserverlist.spigot.depends.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>ch.andre601.advancedserverlist.spigot.depends.caffeine</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
@@ -23,14 +23,14 @@
*
*/
package ch.andre601.advancedserverlist.paper.events;
package ch.andre601.advancedserverlist.bukkit;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.spigot.events.PreServerListSetEvent;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import org.bukkit.plugin.java.JavaPlugin;
public class PreServerListSetEventImpl extends PreServerListSetEvent{
public PreServerListSetEventImpl(ProfileEntry entry){
super(entry);
}
}
/*
* Small convenience class to "merge" the PluginCore and JavaPlugin classes.
* Allows me to have BukkitCore<?> for whenever I also need a JavaPlugin (i.e. registering events).
* See JoinEvent class for an example.
*/
public abstract class BukkitCore<F> extends JavaPlugin implements PluginCore<F>{}
@@ -31,12 +31,13 @@ import ch.andre601.advancedserverlist.paper.commands.PaperCmdSender;
import ch.andre601.advancedserverlist.spigot.commands.SpigotCmdSender;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
public class CmdAdvancedServerList extends Command{
public class CmdAdvancedServerList extends Command implements CommandExecutor{
private final PluginCore<?> plugin;
private final BukkitAudiences audiences;
@@ -49,7 +50,7 @@ public class CmdAdvancedServerList extends Command{
super(
"advancedserverlist",
"Main command of the plugin",
"/asl [reload|help]",
"/asl [reload|help|clearCache]",
Collections.singletonList("asl")
);
@@ -62,6 +63,12 @@ public class CmdAdvancedServerList extends Command{
return true;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args){
plugin.getCore().getCommandHandler().handle(getSender(sender), args);
return true;
}
private CmdSender getSender(CommandSender sender){
return audiences == null ? new PaperCmdSender(sender) : new SpigotCmdSender(sender, audiences);
}
@@ -25,7 +25,9 @@
package ch.andre601.advancedserverlist.bukkit.events;
import ch.andre601.advancedserverlist.bukkit.BukkitCore;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -33,12 +35,17 @@ import org.bukkit.event.player.PlayerJoinEvent;
import java.net.InetSocketAddress;
public class JoinEvent implements Listener{
public class JoinEvent<F> implements Listener{
private final PluginCore<?> plugin;
private final BukkitCore<F> plugin;
public JoinEvent(PluginCore<?> plugin){
private JoinEvent(BukkitCore<F> plugin){
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public static <F> void init(BukkitCore<F> plugin){
new JoinEvent<>(plugin);
}
@EventHandler
@@ -32,10 +32,14 @@ import ch.andre601.advancedserverlist.spigot.objects.SpigotPlayer;
public class BukkitPlayerPlaceholders extends PlaceholderProvider{
public BukkitPlayerPlaceholders(){
private BukkitPlayerPlaceholders(){
super("player");
}
public static BukkitPlayerPlaceholders init(){
return new BukkitPlayerPlaceholders();
}
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
SpigotPlayer bukkitPlayer = (SpigotPlayer)player;
@@ -28,7 +28,7 @@ package ch.andre601.advancedserverlist.bukkit.objects;
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import ch.andre601.advancedserverlist.bukkit.BukkitCore;
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
import ch.andre601.advancedserverlist.core.objects.GenericServerImpl;
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
@@ -46,17 +46,21 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.net.InetSocketAddress;
import java.util.Locale;
import java.util.*;
public class PAPIPlaceholders extends PlaceholderExpansion{
public class PAPIPlaceholders<F> extends PlaceholderExpansion{
private final PluginCore<?> plugin;
private final BukkitCore<F> plugin;
public PAPIPlaceholders(PluginCore<?> plugin){
private PAPIPlaceholders(BukkitCore<F> plugin){
this.plugin = plugin;
this.register();
}
public static <F> PAPIPlaceholders<F> init(BukkitCore<F> plugin){
return new PAPIPlaceholders<>(plugin);
}
@Override
public @NotNull String getIdentifier(){
return "asl";
@@ -72,6 +76,11 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
return plugin.getCore().getVersion();
}
@Override
public boolean persist(){
return true;
}
@Override
public String onPlaceholderRequest(Player pl, @NotNull String identifier){
InetSocketAddress address = pl.getAddress();
@@ -91,33 +100,32 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
ProfileEntry entry = ProfileManager.merge(profile);
if(ProfileManager.checkOption(entry.isExtraPlayersEnabled()))
max = online + (entry.getExtraPlayersCount() == null ? 0 : entry.getExtraPlayersCount());
if(ProfileManager.checkOption(entry.extraPlayersEnabled()))
max = online + (entry.extraPlayersCount() == null ? 0 : entry.extraPlayersCount());
GenericServer finalServer = new GenericServerImpl(online, max, host);
return switch(identifier.toLowerCase(Locale.ROOT)){
case "motd" -> ComponentParser.list(entry.getMotd())
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.toString();
case "favicon" -> ComponentParser.text(entry.getFavicon())
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.toString();
case "playercount_hover" -> ComponentParser.list(entry.getPlayers())
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.toString();
case "playercount_text" -> ComponentParser.text(entry.getPlayerCountText())
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.toString();
case "motd" -> getOption(entry.motd(), pl, player, finalServer);
case "favicon" -> getOption(entry.favicon(), pl, player, finalServer);
case "playercount_hover" -> getOption(entry.players(), pl, player, finalServer);
case "playercount_text" -> getOption(entry.playerCountText(), pl, player, finalServer);
case "extra_players_max" -> String.valueOf(max);
default -> null;
};
}
private String getOption(String str, Player pl, GenericPlayer player, GenericServer server){
return getOption(Collections.singletonList(str), pl, player, server);
}
private String getOption(List<String> list, Player pl, GenericPlayer player, GenericServer server){
return ComponentParser.list(list)
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, server))
.toString();
}
private int resolveProtocol(Player player){
if(Bukkit.getPluginManager().isPluginEnabled("ViaVersion"))
return Via.getAPI().getPlayerVersion(player.getUniqueId());
@@ -126,7 +134,7 @@ public class PAPIPlaceholders extends PlaceholderExpansion{
if(plugin instanceof SpigotCore)
return ProtocolLibrary.getProtocolManager().getProtocolVersion(player);
// getProtocolVersion is only in Paper, so this is only called when
// getProtocolVersion is only in Paper, so this is only called when main class isn't SpigotCore
return Bukkit.getUnsafe().getProtocolVersion();
}
@@ -25,6 +25,7 @@
package ch.andre601.advancedserverlist.paper;
import ch.andre601.advancedserverlist.bukkit.BukkitCore;
import ch.andre601.advancedserverlist.bukkit.commands.CmdAdvancedServerList;
import ch.andre601.advancedserverlist.bukkit.events.JoinEvent;
import ch.andre601.advancedserverlist.bukkit.logging.BukkitLogger;
@@ -32,33 +33,37 @@ import ch.andre601.advancedserverlist.bukkit.objects.BukkitPlayerPlaceholders;
import ch.andre601.advancedserverlist.bukkit.objects.PAPIPlaceholders;
import ch.andre601.advancedserverlist.core.AdvancedServerList;
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
import ch.andre601.advancedserverlist.paper.events.PaperPingEvent;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.CachedServerIcon;
import java.nio.file.Path;
public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon>{
public class PaperCore extends BukkitCore<CachedServerIcon>{
private final PluginLogger logger = new BukkitLogger(getLogger());
private AdvancedServerList core;
private AdvancedServerList<CachedServerIcon> core;
private FaviconHandler<CachedServerIcon> faviconHandler;
private PAPIPlaceholders<CachedServerIcon> papiPlaceholders = null;
@Override
public void onEnable(){
this.core = new AdvancedServerList(this, new BukkitPlayerPlaceholders());
this.core = AdvancedServerList.init(this, BukkitPlayerPlaceholders.init());
if(getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"))
new PAPIPlaceholders(this);
papiPlaceholders = PAPIPlaceholders.init(this);
}
@Override
public void onDisable(){
if(papiPlaceholders != null){
papiPlaceholders.unregister();
papiPlaceholders = null;
}
getCore().disable();
}
@@ -73,8 +78,8 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
@Override
public void loadEvents(){
new JoinEvent(this);
new PaperPingEvent(this);
JoinEvent.init(this);
PaperPingEvent.init(this);
}
@Override
@@ -93,7 +98,7 @@ public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon
}
@Override
public AdvancedServerList getCore(){
public AdvancedServerList<CachedServerIcon> getCore(){
return core;
}
@@ -28,9 +28,9 @@ package ch.andre601.advancedserverlist.paper.events;
import ch.andre601.advancedserverlist.api.events.GenericServerListEvent;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.bukkit.BukkitCore;
import ch.andre601.advancedserverlist.bukkit.events.PreServerListSetEventImpl;
import ch.andre601.advancedserverlist.bukkit.objects.SpigotPlayerImpl;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import ch.andre601.advancedserverlist.core.interfaces.events.GenericEventWrapper;
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
@@ -164,7 +164,7 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
}
@Override
public PluginCore<CachedServerIcon> getPlugin(){
public BukkitCore<CachedServerIcon> getPlugin(){
return plugin;
}
@@ -35,11 +35,15 @@ public class PaperPingEvent implements Listener{
private final PaperCore plugin;
public PaperPingEvent(PaperCore plugin){
private PaperPingEvent(PaperCore plugin){
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public static void init(PaperCore plugin){
new PaperPingEvent(plugin);
}
@EventHandler
public void onPaperServerListPing(PaperServerListPingEvent event){
PingEventHandler.handleEvent(new PaperEventWrapper(plugin, event));
@@ -25,27 +25,30 @@
package ch.andre601.advancedserverlist.spigot;
import ch.andre601.advancedserverlist.bukkit.BukkitCore;
import ch.andre601.advancedserverlist.bukkit.commands.CmdAdvancedServerList;
import ch.andre601.advancedserverlist.bukkit.logging.BukkitLogger;
import ch.andre601.advancedserverlist.bukkit.objects.BukkitPlayerPlaceholders;
import ch.andre601.advancedserverlist.bukkit.objects.PAPIPlaceholders;
import ch.andre601.advancedserverlist.core.AdvancedServerList;
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
import ch.andre601.advancedserverlist.spigot.events.LoadEvent;
import com.comphenix.protocol.wrappers.WrappedServerPing;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.command.PluginCommand;
import java.nio.file.Path;
public class SpigotCore extends JavaPlugin implements PluginCore<WrappedServerPing.CompressedImage>{
public class SpigotCore extends BukkitCore<WrappedServerPing.CompressedImage>{
private final PluginLogger logger = new BukkitLogger(getLogger());
private AdvancedServerList core;
FaviconHandler<WrappedServerPing.CompressedImage> faviconHandler = null;
private AdvancedServerList<WrappedServerPing.CompressedImage> core;
private FaviconHandler<WrappedServerPing.CompressedImage> faviconHandler = null;
private PAPIPlaceholders<WrappedServerPing.CompressedImage> papiPlaceholders = null;
@Override
public void onEnable(){
@@ -62,21 +65,27 @@ public class SpigotCore extends JavaPlugin implements PluginCore<WrappedServerPi
}catch(ClassNotFoundException ignored){}
}
this.core = new AdvancedServerList(this, new BukkitPlayerPlaceholders());
this.core = AdvancedServerList.init(this, BukkitPlayerPlaceholders.init());
}
@Override
public void onDisable(){
if(papiPlaceholders != null){
papiPlaceholders.unregister();
papiPlaceholders = null;
}
getCore().disable();
}
@Override
public void loadCommands(){
if(getServer().getCommandMap().register("asl", new CmdAdvancedServerList(this))){
getPluginLogger().info("Registered /advancedserverlist:advancedserverlist");
}else{
getPluginLogger().info("Registered /asl:advancedserverlist");
PluginCommand cmd = getServer().getPluginCommand("advancedserverlist");
if(cmd == null){
getPluginLogger().warn("Unable to register command /advancedserverlist");
return;
}
cmd.setExecutor(new CmdAdvancedServerList(this, BukkitAudiences.create(this)));
}
@Override
@@ -100,7 +109,7 @@ public class SpigotCore extends JavaPlugin implements PluginCore<WrappedServerPi
}
@Override
public AdvancedServerList getCore(){
public AdvancedServerList<WrappedServerPing.CompressedImage> getCore(){
return core;
}
@@ -137,12 +146,16 @@ public class SpigotCore extends JavaPlugin implements PluginCore<WrappedServerPi
return "spigot";
}
public void setPapiPlaceholders(PAPIPlaceholders<WrappedServerPing.CompressedImage> papiPlaceholders){
this.papiPlaceholders = papiPlaceholders;
}
private void printPaperInfo(){
getPluginLogger().warn("======================================================================================");
getPluginLogger().warn("You are using the Spigot version of AdvancedServerList on a Paper server.");
getPluginLogger().warn("It is recommended to use the dedicated Paper version, to benefit from the");
getPluginLogger().warn("following improvements:");
getPluginLogger().warn(" - No need to download external libraries already provided by PaperMC.");
getPluginLogger().warn(" - No downloading of external Libraries already provided by Paper (i.e. Adventure).");
getPluginLogger().warn(" - No dependency on ProtocolLib thanks to provided Events.");
getPluginLogger().warn("");
getPluginLogger().warn("AdvancedServerList may work as normal, but consider using the PaperMC version instead!");
@@ -54,10 +54,10 @@ public class LoadEvent implements Listener{
return;
}
manager.registerEvents(new JoinEvent(plugin), plugin);
manager.registerEvents(new ProtocolLibEvents(plugin, ProtocolLibrary.getProtocolManager()), plugin);
JoinEvent.init(plugin);
ProtocolLibEvents.init(plugin, ProtocolLibrary.getProtocolManager());
if(manager.isPluginEnabled("PlaceholderAPI"))
new PAPIPlaceholders(plugin);
plugin.setPapiPlaceholders(PAPIPlaceholders.init(plugin));
}
}
@@ -28,8 +28,8 @@ package ch.andre601.advancedserverlist.spigot.events;
import ch.andre601.advancedserverlist.api.events.GenericServerListEvent;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.bukkit.BukkitCore;
import ch.andre601.advancedserverlist.bukkit.events.PreServerListSetEventImpl;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import ch.andre601.advancedserverlist.core.interfaces.events.GenericEventWrapper;
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
@@ -37,11 +37,12 @@ import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
import ch.andre601.advancedserverlist.spigot.SpigotCore;
import ch.andre601.advancedserverlist.bukkit.objects.SpigotPlayerImpl;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.AdventureComponentConverter;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedServerPing;
import me.clip.placeholderapi.PlaceholderAPI;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
@@ -77,7 +78,7 @@ public class ProtocolLibEventWrapper implements GenericEventWrapper<WrappedServe
@Override
public void setMotd(Component component){
ping.setMotD(AdventureComponentConverter.fromComponent(component));
ping.setMotD(WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(component)));
}
@Override
@@ -124,7 +125,9 @@ public class ProtocolLibEventWrapper implements GenericEventWrapper<WrappedServe
// Not used in ProtocolLib
@Override
public void updateEvent(){}
public void updateEvent(){
event.getPacket().getServerPings().write(0, ping);
}
@Override
public boolean isInvalidProtocol(){
@@ -169,7 +172,7 @@ public class ProtocolLibEventWrapper implements GenericEventWrapper<WrappedServe
}
@Override
public PluginCore<WrappedServerPing.CompressedImage> getPlugin(){
public BukkitCore<WrappedServerPing.CompressedImage> getPlugin(){
return plugin;
}
@@ -32,6 +32,7 @@ import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import java.net.InetSocketAddress;
@@ -44,10 +45,15 @@ public class ProtocolLibEvents implements Listener{
private static final Map<String, String> hostAddresses = new HashMap<>();
public ProtocolLibEvents(SpigotCore plugin, ProtocolManager protocolManager){
private ProtocolLibEvents(SpigotCore plugin, ProtocolManager protocolManager){
this.protocolManager = protocolManager;
loadPacketListener(plugin);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public static void init(SpigotCore plugin, ProtocolManager protocolManager){
new ProtocolLibEvents(plugin, protocolManager);
}
public static Map<String, String> getHostAddresses(){
@@ -22,6 +22,7 @@ load-after:
- name: ViaVersion
bootstrap: false
# The below stuff is NOT used by Paper plugin.
commands:
advancedserverlist:
description: 'Main command of AdvancedServerList'
@@ -30,6 +31,7 @@ commands:
- 'asl'
permission: 'advancedserverlist.admin'
# This is actually supported(?)
permissions:
advancedserverlist.*:
description: 'Grants access to all permissions'
+6 -1
View File
@@ -7,6 +7,8 @@ main: 'ch.andre601.advancedserverlist.spigot.SpigotCore'
api-version: 1.19
folia-supported: true
libraries:
- 'org.spongepowered:configurate-yaml:4.1.2'
- 'net.kyori:adventure-api:4.12.0'
@@ -22,7 +24,7 @@ softdepend:
commands:
advancedserverlist:
description: 'Main command of AdvancedServerList'
usage: '/<command> [help|reload]'
usage: '/<command> [help|reload|clearCache]'
aliases:
- 'asl'
permission: 'advancedserverlist.admin'
@@ -49,4 +51,7 @@ permissions:
default: op
advancedserverlist.command.reload:
description: 'Grants access to /asl reload'
default: op
advancedserverlist.command.clearcache:
description: 'Clears the Player and Favicon cache'
default: op
+25 -5
View File
@@ -78,6 +78,18 @@
<type>javadoc</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.13.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.13.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
@@ -90,10 +102,22 @@
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>configurate-yaml</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>AdvancedServerList-BungeeCord-${plugin.version}</finalName>
<finalName>AdvancedServerList-BungeeCord-${plugin.version}${project.build.commit}</finalName>
<resources>
<resource>
<filtering>true</filtering>
@@ -125,10 +149,6 @@
<pattern>org.bstats</pattern>
<shadedPattern>ch.andre601.advancedserverlist.bungeecord.depends.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>ch.andre601.advancedserverlist.bungeecord.depends.caffeine</shadedPattern>
</relocation>
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>ch.andre601.advancedserverlist.bungeecord.depends.okhttp3</shadedPattern>
@@ -43,13 +43,13 @@ import java.nio.file.Path;
public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
private AdvancedServerList core;
private AdvancedServerList<Favicon> core;
private FaviconHandler<Favicon> faviconHandler = null;
private final PluginLogger logger = new BungeeLogger(getLogger());
@Override
public void onEnable(){
this.core = new AdvancedServerList(this, new BungeePlayerPlaceholders());
this.core = AdvancedServerList.init(this, BungeePlayerPlaceholders.init());
}
@Override
@@ -85,7 +85,7 @@ public class BungeeCordCore extends Plugin implements PluginCore<Favicon>{
}
@Override
public AdvancedServerList getCore(){
public AdvancedServerList<Favicon> getCore(){
return core;
}
@@ -33,10 +33,14 @@ import java.util.Locale;
public class BungeePlayerPlaceholders extends PlaceholderProvider{
public BungeePlayerPlaceholders(){
private BungeePlayerPlaceholders(){
super("player");
}
public static BungeePlayerPlaceholders init(){
return new BungeePlayerPlaceholders();
}
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
return switch(placeholder.toLowerCase(Locale.ROOT)){
+18 -11
View File
@@ -61,42 +61,49 @@
<groupId>org.spongepowered</groupId>
<artifactId>configurate-yaml</artifactId>
<version>4.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.13.0</version>
<version>4.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.13.0</version>
<version>4.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-legacy</artifactId>
<version>4.13.0</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.5</version>
<scope>compile</scope>
<version>4.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
<version>4.11.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.unascribed</groupId>
<artifactId>flexver-java</artifactId>
<version>1.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->
@@ -109,7 +116,7 @@
</dependencies>
<build>
<finalName>AdvancedServerList-Core-${plugin.version}</finalName>
<finalName>AdvancedServerList-Core-${plugin.version}${project.build.commit}</finalName>
<resources>
<resource>
<filtering>true</filtering>
@@ -39,9 +39,9 @@ import java.io.InputStream;
import java.nio.file.Path;
import java.util.Properties;
public class AdvancedServerList{
public class AdvancedServerList<F>{
private final PluginCore<?> plugin;
private final PluginCore<F> plugin;
private final FileHandler fileHandler;
private final CommandHandler commandHandler;
private final PlayerHandler playerHandler;
@@ -51,19 +51,23 @@ public class AdvancedServerList{
private String version;
public AdvancedServerList(PluginCore<?> plugin, PlaceholderProvider player){
private AdvancedServerList(PluginCore<F> plugin, PlaceholderProvider placeholders){
this.plugin = plugin;
this.fileHandler = new FileHandler(this);
this.commandHandler = new CommandHandler(this);
this.playerHandler = new PlayerHandler(this);
this.api.addPlaceholderProvider(player);
this.api.addPlaceholderProvider(placeholders);
this.api.addPlaceholderProvider(new ServerPlaceholders());
load();
}
public PluginCore<?> getPlugin(){
public static <F> AdvancedServerList<F> init(PluginCore<F> plugin, PlaceholderProvider placeholders){
return new AdvancedServerList<>(plugin, placeholders);
}
public PluginCore<F> getPlugin(){
return plugin;
}
@@ -116,7 +116,7 @@ public class CommandHandler{
core.clearPlayerCache();
sender.sendPrefixedMsg("<green>Successfully cleared Player Cache!");
sender.sendErrorMsg("<green>Reload complete!");
sender.sendPrefixedMsg("<green>Reload complete!");
}
}
@@ -68,43 +68,43 @@ public class PingEventHandler{
if(entry.isInvalid())
return;
if(ProfileManager.checkOption(entry.isExtraPlayersEnabled())){
max = online + (entry.getExtraPlayersCount() == null ? 0 : entry.getExtraPlayersCount());
if(ProfileManager.checkOption(entry.extraPlayersEnabled())){
max = online + (entry.extraPlayersCount() == null ? 0 : entry.extraPlayersCount());
event.setMaxPlayers(max);
}
GenericServer finalServer = new GenericServerImpl(online, max, host);
if(ProfileManager.checkOption(entry.getMotd())){
if(ProfileManager.checkOption(entry.motd())){
event.setMotd(
ComponentParser.list(entry.getMotd())
ComponentParser.list(entry.motd())
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
.toComponent()
);
}
boolean hidePlayers = ProfileManager.checkOption(entry.isHidePlayersEnabled());
boolean hidePlayers = ProfileManager.checkOption(entry.hidePlayersEnabled());
if(hidePlayers){
event.hidePlayers();
}
if(ProfileManager.checkOption(entry.getPlayerCountText()) && !hidePlayers){
if(ProfileManager.checkOption(entry.playerCountText()) && !hidePlayers){
event.setPlayerCount(
ComponentParser.text(entry.getPlayerCountText())
ComponentParser.text(entry.playerCountText())
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.modifyText(text -> event.parsePAPIPlaceholders(text, player))
.toString()
);
}
if(ProfileManager.checkOption(entry.getPlayers()) && !hidePlayers){
event.setPlayers(entry.getPlayers(), player, server);
if(ProfileManager.checkOption(entry.players()) && !hidePlayers){
event.setPlayers(entry.players(), player, server);
}
if(ProfileManager.checkOption(entry.getFavicon())){
String favicon = StringReplacer.replace(entry.getFavicon(), player, server);
if(ProfileManager.checkOption(entry.favicon())){
String favicon = StringReplacer.replace(entry.favicon(), player, server);
F fav = plugin.getFaviconHandler().getFavicon(favicon, image -> {
try{
@@ -25,6 +25,8 @@
package ch.andre601.advancedserverlist.core.interfaces.commands;
import java.util.Locale;
public abstract class PluginCommand{
private final String argument;
@@ -38,7 +40,7 @@ public abstract class PluginCommand{
}
public String getPermission(){
return "advancedserverlist.command." + getArgument();
return "advancedserverlist.command." + getArgument().toLowerCase(Locale.ROOT);
}
public abstract void handle(CmdSender sender);
@@ -26,8 +26,8 @@
package ch.andre601.advancedserverlist.core.profiles.favicon;
import ch.andre601.advancedserverlist.core.AdvancedServerList;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import javax.imageio.ImageIO;
import java.awt.*;
@@ -39,12 +39,13 @@ import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Locale;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
public class FaviconHandler<F>{
private final Cache<String, F> favicons = Caffeine.newBuilder()
private final Cache<String, F> favicons = CacheBuilder.newBuilder()
.expireAfterWrite(5, TimeUnit.MINUTES)
.build();
@@ -55,13 +56,17 @@ public class FaviconHandler<F>{
}
public F getFavicon(String input, Function<BufferedImage, F> function){
return favicons.get(input, k -> {
BufferedImage image = resolveImage(core, input);
if(image == null)
return null;
return function.apply(image);
});
try{
return favicons.get(input, () -> {
BufferedImage image = resolveImage(core, input);
if(image == null)
return null;
return function.apply(image);
});
}catch(ExecutionException ignored){
return null;
}
}
public void clearCache(){
@@ -99,7 +99,7 @@ public class ProfileManager{
return !list.isEmpty(); // Check if list isn't empty
}else
if(obj instanceof String str){
return !str.isEmpty(); // Check if list is not empty
return !str.isEmpty(); // Check if String is not empty
}else
if(obj instanceof NullBool nb){
return nb.getOrDefault(false); // Return NullBool's value
@@ -109,52 +109,52 @@ public class ProfileManager{
}
private static List<String> resolveMOTD(ProfileEntry profile, ProfileEntry defaultProfile){
if(profile == null || !checkOption(profile.getMotd()))
return defaultProfile.getMotd();
if(profile == null || !checkOption(profile.motd()))
return defaultProfile.motd();
return profile.getMotd();
return profile.motd();
}
private static List<String> resolvePlayers(ProfileEntry profile, ProfileEntry defaultProfile){
if(profile == null || !checkOption(profile.getPlayers()))
return defaultProfile.getPlayers();
if(profile == null || !checkOption(profile.players()))
return defaultProfile.players();
return profile.getPlayers();
return profile.players();
}
private static String resolvePlayerCountText(ProfileEntry profile, ProfileEntry defaultProfile){
if(profile == null || !checkOption(profile.getPlayerCountText()))
return defaultProfile.getPlayerCountText();
if(profile == null || !checkOption(profile.playerCountText()))
return defaultProfile.playerCountText();
return profile.getPlayerCountText();
return profile.playerCountText();
}
private static String resolveFavicon(ProfileEntry profile, ProfileEntry defaultProfile){
if(profile == null || !checkOption(profile.getFavicon()))
return defaultProfile.getFavicon();
if(profile == null || !checkOption(profile.favicon()))
return defaultProfile.favicon();
return profile.getFavicon();
return profile.favicon();
}
private static boolean resolveHidePlayersEnabled(ProfileEntry profile, ProfileEntry defaultProfile){
if(profile == null || !checkOption(profile.isHidePlayersEnabled()))
return defaultProfile.isHidePlayersEnabled().getOrDefault(false);
if(profile == null || !checkOption(profile.hidePlayersEnabled()))
return defaultProfile.hidePlayersEnabled().getOrDefault(false);
return profile.isHidePlayersEnabled().getOrDefault(false);
return profile.hidePlayersEnabled().getOrDefault(false);
}
private static boolean resolveExtraPlayersEnabled(ProfileEntry profile, ProfileEntry defaultProfile){
if(profile == null || !checkOption(profile.isExtraPlayersEnabled()))
return defaultProfile.isExtraPlayersEnabled().getOrDefault(false);
if(profile == null || !checkOption(profile.extraPlayersEnabled()))
return defaultProfile.extraPlayersEnabled().getOrDefault(false);
return profile.isExtraPlayersEnabled().getOrDefault(false);
return profile.extraPlayersEnabled().getOrDefault(false);
}
private static Integer resolveExtraPlayersCount(ProfileEntry profile, ProfileEntry defaultProfile){
if(profile == null || profile.getExtraPlayersCount() == null)
return defaultProfile.getExtraPlayersCount() == null ? 0 : defaultProfile.getExtraPlayersCount();
if(profile == null || profile.extraPlayersCount() == null)
return defaultProfile.extraPlayersCount() == null ? 0 : defaultProfile.extraPlayersCount();
return profile.getExtraPlayersCount();
return profile.extraPlayersCount();
}
private static List<String> resolveList(ConfigurationNode node, Object... path){
@@ -48,12 +48,12 @@ public class ProfileSerializer implements TypeSerializer<ProfileEntry>{
return;
}
node.node("motd").set(profile.getMotd());
node.node("playerCount", "hover").set(profile.getPlayers());
node.node("playerCount", "text").set(profile.getPlayerCountText());
node.node("favicon").set(profile.getFavicon());
node.node("playerCount", "hidePlayers").set(profile.isHidePlayersEnabled());
node.node("playerCount", "extraPlayers", "enabled").set(profile.isExtraPlayersEnabled());
node.node("playerCount", "extraPlayers", "amount").set(profile.getExtraPlayersCount());
node.node("motd").set(profile.motd());
node.node("playerCount", "hover").set(profile.players());
node.node("playerCount", "text").set(profile.playerCountText());
node.node("favicon").set(profile.favicon());
node.node("playerCount", "hidePlayers").set(profile.hidePlayersEnabled());
node.node("playerCount", "extraPlayers", "enabled").set(profile.extraPlayersEnabled());
node.node("playerCount", "extraPlayers", "amount").set(profile.extraPlayersCount());
}
}
+7
View File
@@ -3,6 +3,13 @@
This page lists the recent changes made towards the AdvancedServerListAPI.
They are ordered newest to oldest.
## v2.1.0
### :octicons-pencil-24:{ .changelog-changed title="Changed" } Changed { #v-changed }
- Turned `ProfileEntry` class into a record
- Former `getX()` methods are now deprecated in favour of the recor's own `x()` methods (i.e. `getMotd()` -> `motd()`)
## v2.0.0
### :octicons-alert-24:{ .changelog-breaking title="Breaking Changes" } Breaking Changes { #v2-breaking }
+11 -9
View File
@@ -11,7 +11,7 @@ Add the following to your `build.gradle` or `pom.xml` file to use the API:
Make sure to replace `{version}` with the latest version available in the [GitHub Repository][api-repo].
```groovy
```groovy title="build.gradle"
repositorories {
maven { url = 'https://jitpack.io/' }
}
@@ -30,7 +30,7 @@ Add the following to your `build.gradle` or `pom.xml` file to use the API:
Make sure to replace `{version}` with the latest version available in the [GitHub Repository][api-repo].
```xml
```xml title="pom.xml"
<repositories>
<repository>
<id>jitpack</id>
@@ -78,8 +78,9 @@ It will be needed at a later point.
### 2) Create a Placeholder class
Make a new class that you want to use for the placeholders and let it extend the `PlaceholderProvider` class of AdvancedServerList.
Your IDE should now tell you to implement/override some methods. Confirm this action and your class should look something alongside this:
```java
Your IDE should now tell you to implement/override some methods. Confirm this action and your class should look something alongside this:
```java title="PlaceholderProvider example"
public class MyPlaceholders extends PlaceholderProvider {
public MyPlaceholders(String identifier) {
@@ -94,7 +95,8 @@ public class MyPlaceholders extends PlaceholderProvider {
```
It's recommended to replace your generated constructor with a no-args one and set the identifier directly in the `super()`.
For example:
For example:
```java
public MyPlaceholders() {
super("myplaceholders");
@@ -106,8 +108,9 @@ The `placeholder` String is whatever value was provided after the identifier in
Something to note is, that when returning `null` will AdvancedServerList understand it as an invalid placeholder and return it unchanged.
Here is a small example of the final class:
```java
Here is a small example of the final class:
```java title="PlaceholderProvider example"
public class MyPlaceholders extends PlaceholderProvider {
public MyPlaceholders() {
@@ -128,8 +131,7 @@ public class MyPlaceholders extends PlaceholderProvider {
All that is left to do now is to register your class as a new PlaceholderProvider instance. To do this, get the API instance you retrieved earlier and use `addPlaceholderProvider` with a new instance of your class.
Example:
```java
```java title="Registering PlaceholderProvider class"
AdvancedServerListAPI api = AdvancedServerListAPI.get();
api.addPlaceholderProvider(new MyPlaceholders());
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

+10
View File
@@ -27,6 +27,16 @@
color: #d29922;
}
.result {
border: .05rem solid var(--md-code-bg-color);
border-bottom-left-radius: .1rem;
border-bottom-right-radius: .1rem;
border-top-width: .1rem;
margin-top: -1.125em;
overflow: visible;
padding: 0 1em;
}
/* Override mkdocs-material styling */
.md-banner--warning {
background: rgba(187,128,9,0.15);
+7 -6
View File
@@ -28,7 +28,7 @@ Some examples about version-related things.
You may want to display a separate MOTD or text for incompatible client versions.
This example here shows a separate MOTD and player count message for when the player's client version is older than what the server supports.
```yaml
```yaml title="outdated-client.yml"
priority: 1
# Display this profile, if the version of the player is below 760 (1.19.1)
@@ -47,7 +47,7 @@ playerCount:
This profile would display a MOTD without HEX colours if the player's version is below 735 (1.16).
```yaml
```yaml title="pre-1_16.yml"
priority: 1
# Display this profile, if the version of the player is below 735 (1.16)
@@ -70,7 +70,7 @@ Examples that can be used with the Spigot or PaperMC version.
Displays a separate profile for when the player has been banned from the server.
```yaml
```yaml title="banned.yml"
priority: 1
conditions:
@@ -94,7 +94,7 @@ Some misc examples.
Display a different profile when the playing pings a specific domain/IP.
```yaml
```yaml title="specific-host.yml"
priority: 1
conditions:
@@ -109,7 +109,7 @@ motd:
Display a different profile, if the player pinging the server is "known" by AdvancedServerList (Has joined before with the same IP).
```yaml
```yaml title="personalized.yml"
priority: 1
conditions:
@@ -132,7 +132,8 @@ playerCount:
v1.10.0 of AdvancedServerList introduced an option called `profiles`. It allows you to create multiple variants of an MOTD, playercount, etc. while also supporting the normal (global) options as a fallback.
The following example will create a profile that has a randomized MOTD, but the same hover for both:
```yaml
```yaml title="random-motd.yml"
priority: 1
profiles:
+16
View File
@@ -2,6 +2,22 @@
All text options with exception of [`Conditions`](../#conditions) allow the usage of formatting options using [MiniMessage].
!!! warning "IMPORTANT"
Whenever your text starts with a colour or formatting code (`<aqua>`, `<blue>`, `<bold>`, `<italic>`, etc.) should it be surrounded with single or double quotes.
Not doing so will cause the YAML parses used - Configurate - to not see the value as a String, but something else, causing exceptions to appear.
```yaml title="Wrong formatting"
motd:
- <red>This will cause
- <red>Errors
```
```yaml title="Right formatting"
motd:
- '<green>This will be formatted'
- '<green>properly.'
```
## Unsupported options
The following options are **not** supported, no matter what option they are used in:
+133 -21
View File
@@ -54,27 +54,29 @@ The profiles option allows you to add multiple combinations of all the other opt
If an option is not present in an entry will AdvancedServerList try to use one defined in the file or use whatever default value would be for that option.
As an example:
```yaml
priority: 0
??? example "Example"
```yaml title="YAML file"
priority: 0
profiles:
- motd:
- '<rainbow>Line 1</rainbow>'
- '<rainbow:!>Line 2</rainbow>'
playerCount:
text: '<green><bold>Awesome!'
- playerCount:
text: '<yellow><bold>Also Awesome!'
motd:
- '<rainbow:2>Line A</rainbow>'
- '<rainbow:!2>Line B</rainbow>'
```
<div class="result">
![profiles-example-1](../assets/images/examples/profiles-example-1.jpg)
![profiles-example-2](../assets/images/examples/profiles-example-2.jpg)
profiles:
- motd:
- '<rainbow>Line 1</rainbow>'
- '<rainbow:!>Line 2</rainbow>'
playerCount:
text: '<green><bold>Awesome!'
- playerCount:
text: '<yellow><bold>Also Awesome!'
motd:
- '<rainbow:2>Line A</rainbow>'
- '<rainbow:!2>Line B</rainbow>'
```
...the above example would randomly select between the following combinations of MOTD and Player count text:
![motd-example-1](../assets/images/examples/motd-example-1.jpg)
![motd-example-2](../assets/images/examples/motd-example-2.jpg)
</div>
## Motd
@@ -83,6 +85,21 @@ Normal colour and formatting codes such as `<aqua>` or `<bold>` are supported. O
If you want to display multiple MOTDs will you need to use the [`Profiles` option](#profiles)
??? example "Example"
```yaml title="YAML file"
priority: 0
motd:
- '<rainbow:2>Rainbow Gradients</rainbow>'
- '<rainbow:!2>|||||||||||||||||||||||||||||||||||||</rainbow>'
```
<div class="result">
![motd-example](../assets/images/examples/motd-example.jpg)
</div>
## Favicon
The favicon option allows you to customize the favicon and display one or multiple different images.
@@ -95,6 +112,24 @@ This option currently supports the following values:
Please note that AdvancedServerList will rescale the image to be 64x64 pixels, so be sure to provide images at that particular scale.
??? example "Example"
```yaml title="YAML file"
priority: 0
# We use just colour to hide the MOTD
motd:
- '<grey>'
- '<grey>'
# Player is Andre_601
favicon: ${player uuid}
```
<div class="result">
![hideplayers-example](../assets/images/examples/favicon-example.jpg)
</div>
## PlayerCount
The `playerCount` option contains multiple different options all about the Player count itself.
@@ -104,12 +139,51 @@ The `playerCount` option contains multiple different options all about the Playe
Boolean option to set whether AdvancedServerList should hide the player count or not. When set to `true` will the player count be replaced with `???`.
Additionally will the [`Text`](#text) and [`Hover`](#hover) option be ignored.
??? example "Example"
```yaml title="YAML file"
priority: 0
# We use just colour to hide the MOTD
motd:
- '<grey>'
- '<grey>'
playerCount:
hidePlayers: true
```
<div class="result">
![hideplayers-example](../assets/images/examples/hideplayers-example.jpg)
</div>
### Hover
This option allows to override the hover text usually displaying the players on the server when hovering over the player count.
You can either remove this option or set to an empty list (`hover: []`) to not override the hover.
??? example "Example"
```yaml title="YAML file"
priority: 0
# We use just colour to hide the MOTD
motd:
- '<grey>'
- '<grey>'
playerCount:
hover:
- '<grey>Line 1'
- '<aqua>Line 2'
- '<gold>Line 3'
```
<div class="result">
![hover-example](../assets/images/examples/hover-example.jpg)
</div>
### Text
This option allows to override the text usually displaying the online players and total players that can join.
@@ -121,6 +195,24 @@ Note that AdvancedServerList will not add the `<online>/<max>` text to the playe
To not override the player count, remove this option or set it to an empty String (`text: ''`).
??? example "Example"
```yaml title="YAML file"
priority: 0
# We use just colour to hide the MOTD
motd:
- '<grey>'
- '<grey>'
playerCount:
text: '<yellow><bold>Cool text!'
```
<div class="result">
![hover-example](../assets/images/examples/text-example.jpg)
</div>
### ExtraPlayers
Contains options to modify how the `<max>` number in the player count should look like.
@@ -136,4 +228,24 @@ When set to `true` will the max amount of players be modified by taking the curr
Sets the number to add to the current online players to then use as the new max players count.
As an example, setting this to `1` while `10` players are online will display `11`, while `-1` would display `9`.
As an example, setting this to `1` while `10` players are online will display `11`, while `-1` would display `9`.
??? example "Example"
```yaml title="YAML file"
priority: 0
# We use just colour to hide the MOTD
motd:
- '<grey>'
- '<grey>'
playerCount:
extraPlayers:
enabled: true
amount: 1
```
<div class="result">
![hover-example](../assets/images/examples/extraplayers-example.jpg)
</div>
+109
View File
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2022-2023 Andre_601
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ch.andre601.advancedserverlist</groupId>
<artifactId>parent</artifactId>
<version>parent</version>
</parent>
<artifactId>hangar-uploader</artifactId>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>HangarUploader</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>16</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>ch.andre601.advancedserverlist.hangaruploader.HangarUploader</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,209 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.hangaruploader;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.entity.mime.FileBody;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.client5.http.entity.mime.StringBody;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpMessage;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class HangarUploader{
private static final Logger LOGGER = LoggerFactory.getLogger(HangarUploader.class);
private static final String API_URL = "https://hangar.papermc.io/api/v1/";
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private final String apiKey;
private ActiveJWT activeJWT;
public HangarUploader(String apiKey){
this.apiKey = apiKey;
}
public static void main(String[] args) throws IOException{
LOGGER.info("Starting Jar file...");
final VersionUpload.Namespace project = new VersionUpload.Namespace("Andre_601", "AdvancedServerList");
if(args.length < 3){
throw new IllegalStateException("Application requires HANGAR_TOKEN, RELEASE_TAG, PRERELEASE and RELEASE_BODY to work");
}
String apiToken = args[0];
String version = args[1].startsWith("v") ? args[1].substring(1) : args[1];
boolean isPreRelease = args[2].equalsIgnoreCase("true");
String body = System.getenv("GITHUB_RELEASE_BODY");
LOGGER.info("Version: {}", version);
LOGGER.info("Is Prerelease: {}", isPreRelease);
LOGGER.info("Release Message: {}", body);
final List<Path> filePaths = List.of(
new File("bukkit/target/AdvancedServerList-Bukkit-" + version + ".jar").toPath(),
new File("bungeecord/target/AdvancedServerList-BungeeCord-" + version + ".jar").toPath(),
new File("velocity/target/AdvancedServerList-Velocity-" + version + ".jar").toPath()
);
final List<VersionUpload.PluginDependency> paperDependencies = List.of(
VersionUpload.PluginDependency.createWithHangarNamespace(
"ViaVersion",
false,
new VersionUpload.Namespace("ViaVersion", "ViaVersion")
),
VersionUpload.PluginDependency.createWithExternalUrl(
"PlaceholderAPI",
false,
"https://www.spigotmc.org/resources/6245/"
)
);
final List<VersionUpload.MultipartFileOrUrl> fileInfo = List.of(
new VersionUpload.MultipartFileOrUrl(List.of(VersionUpload.Platform.PAPER), null),
new VersionUpload.MultipartFileOrUrl(List.of(VersionUpload.Platform.WATERFALL), null),
new VersionUpload.MultipartFileOrUrl(List.of(VersionUpload.Platform.VELOCITY), null)
);
final VersionUpload versionUpload = new VersionUpload(
version,
Map.of(
VersionUpload.Platform.PAPER, paperDependencies,
VersionUpload.Platform.WATERFALL, List.of(),
VersionUpload.Platform.VELOCITY, List.of()
),
Map.of(
VersionUpload.Platform.PAPER, List.of("1.19.x"),
VersionUpload.Platform.WATERFALL, List.of("1.19.x"),
VersionUpload.Platform.VELOCITY, List.of("3.1")
),
body,
fileInfo,
isPreRelease ? "Beta" : "Release"
);
HangarUploader uploader = new HangarUploader(apiToken);
try(CloseableHttpClient client = HttpClients.createDefault()){
uploader.uploadVersion(client, project, versionUpload, filePaths);
}catch(ParseException ex){
LOGGER.error("Encountered ParseException while performing a request.", ex);
}
}
public void uploadVersion(HttpClient client, VersionUpload.Namespace namespace, VersionUpload versionUpload,
List<Path> filePaths) throws IOException, ParseException{
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addPart("versionUpload", new StringBody(GSON.toJson(versionUpload), ContentType.APPLICATION_JSON));
for(Path path : filePaths){
builder.addPart("files", new FileBody(path.toFile(), ContentType.DEFAULT_BINARY));
}
HttpPost post = new HttpPost(API_URL + "projects/" + namespace + "/upload");
post.setEntity(builder.build());
this.addAuthHeader(client, post);
LOGGER.info("Uploading release...");
final boolean success = client.execute(post, response -> {
if(response.getCode() != 200){
LOGGER.error("Error while uploading version. Received response code {}: {}", response.getCode(), response.getReasonPhrase());
LOGGER.error("Body: {}", EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8));
return false;
}
return true;
});
if(!success){
throw new RuntimeException("Error uploading version!");
}
LOGGER.info("Upload complete!");
System.exit(0);
}
private synchronized void addAuthHeader(HttpClient client, HttpMessage message) throws IOException{
LOGGER.info("Applying Authorization Header...");
if(this.activeJWT != null && !this.activeJWT.hasExpired()){
message.addHeader("Authorization", this.activeJWT.jwt());
LOGGER.info("Authorization Header applied. Expires at {}", getDate(this.activeJWT.expiresAt()));
return;
}
LOGGER.info("Current JWT expired. Requesting new one...");
ActiveJWT jwt = client.execute(new HttpPost(API_URL + "authenticate?apiKey=" + this.apiKey), response -> {
if(response.getCode() == 400){
LOGGER.error("Bad JWT request; is the API-token valid?");
return null;
}else
if(response.getCode() != 200){
LOGGER.error("Received non-successful response code {}: {}", response.getCode(), response.getReasonPhrase());
return null;
}
final String json = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
final JsonObject jsonObject = GSON.fromJson(json, JsonObject.class);
final String token = jsonObject.getAsJsonPrimitive("token").getAsString();
final long expiresIn = jsonObject.getAsJsonPrimitive("expiresIn").getAsLong();
LOGGER.info("Received new JWT!");
return new ActiveJWT(token, System.currentTimeMillis() + expiresIn);
});
if(jwt == null){
throw new RuntimeException("Error getting JWT.");
}
this.activeJWT = jwt;
LOGGER.info("Authorization Header applied. Expires at {}", getDate(this.activeJWT.expiresAt()));
message.addHeader("Authorization", jwt.jwt());
}
private synchronized String getDate(long timestamp){
return timestamp + " (" + new Date(timestamp) + ")";
}
private record ActiveJWT(String jwt, long expiresAt){
public boolean hasExpired(){
return System.currentTimeMillis() < this.expiresAt + TimeUnit.SECONDS.toMillis(3);
}
}
}
@@ -0,0 +1,66 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.hangaruploader;
import java.util.List;
import java.util.Map;
public record VersionUpload(String version, Map<Platform, List<PluginDependency>> pluginDependencies,
Map<Platform, List<String>> platformDependencies, String description,
List<MultipartFileOrUrl> files, String channel){
public record Namespace(String owner, String slug){
@Override
public String toString(){
return this.owner + "/" + this.slug;
}
}
public record PluginDependency(String name, boolean required, Namespace namespace, String externalUrl){
public PluginDependency{
if(namespace == null && externalUrl == null)
throw new IllegalStateException("Either a Hangar Namespace or an external URL needs to be defined.");
}
public static PluginDependency createWithHangarNamespace(String name, boolean required, Namespace namespace){
return new PluginDependency(name, required, namespace, null);
}
public static PluginDependency createWithExternalUrl(String name, boolean required, String externalUrl){
return new PluginDependency(name, required, null, externalUrl);
}
}
public record MultipartFileOrUrl(List<Platform> platforms, String externalUrl){}
public enum Platform{
PAPER,
WATERFALL,
VELOCITY
}
}
@@ -0,0 +1,60 @@
<!--
~ MIT License
~
~ Copyright (c) 2022-2023 Andre_601
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
~
-->
<configuration debug="false">
<property name="DEV_HOME" value="./logs"/>
<!--CONSOLE -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight([) %boldWhite(%d{dd.MM.yyyy HH:mm:ss}) %highlight(%-5level) %highlight(]) %cyan([%t]) %boldWhite([%logger{0}]) %boldRed(-) %white(%msg) %n</pattern>
</encoder>
</appender>
<!--FILE OUT-->
<appender name="FILE-AUDIT" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<file>${DEV_HOME}/Purr.log</file>
<encoder>
<pattern>%d{dd.MM.yyyy HH:mm:ss} [%thread] [ %-5level] [%logger{0}] %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${DEV_HOME}/archived/purr-%d{dd.MM.yyyy}.%i.log</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>60</maxHistory>
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
</appender>
<!--Root logger-->
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE-AUDIT"/>
</root>
</configuration>
+2
View File
@@ -35,6 +35,7 @@ theme:
- navigation.indexes
- navigation.tabs
- navigation.tabs.sticky
- content.code.copy
icon:
repo: 'octicons/mark-github-16'
@@ -78,3 +79,4 @@ markdown_extensions:
- pymdownx.superfences:
- pymdownx.tabbed:
alternate_style: true
- pymdownx.details:
-156
View File
@@ -1,156 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2022-2023 Andre_601
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent</artifactId>
<groupId>ch.andre601.advancedserverlist</groupId>
<version>parent</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>paper</artifactId>
<packaging>jar</packaging>
<version>${plugin.version}</version>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>placeholderapi-repo</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>viaversion</id>
<url>https://repo.viaversion.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>ch.andre601.advancedserverlist</groupId>
<artifactId>core</artifactId>
<version>${plugin.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.andre601.asl-api</groupId>
<artifactId>platform-spigot</artifactId>
<version>${api.version}</version>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.viaversion</groupId>
<artifactId>viaversion-api</artifactId>
<version>4.6.1</version>
</dependency>
</dependencies>
<build>
<finalName>AdvancedServerList-Paper-${plugin.version}</finalName>
<resources>
<resource>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>16</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>org.spongepowered.configurate</pattern>
<shadedPattern>ch.andre601.advancedserverlist.paper.depends.configurate</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>ch.andre601.advancedserverlist.paper.depends.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>ch.andre601.advancedserverlist.paper.depends.caffeine</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -1,169 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper;
import ch.andre601.advancedserverlist.core.AdvancedServerList;
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import ch.andre601.advancedserverlist.core.profiles.favicon.FaviconHandler;
import ch.andre601.advancedserverlist.paper.commands.CmdAdvancedServerList;
import ch.andre601.advancedserverlist.paper.events.JoinEvent;
import ch.andre601.advancedserverlist.paper.events.PingEvent;
import ch.andre601.advancedserverlist.paper.logging.PaperLogger;
import ch.andre601.advancedserverlist.paper.objects.PAPIPlaceholders;
import ch.andre601.advancedserverlist.paper.objects.PaperPlayerPlaceholders;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.CachedServerIcon;
import java.nio.file.Path;
public class PaperCore extends JavaPlugin implements PluginCore<CachedServerIcon>{
private final PluginLogger logger = new PaperLogger(getLogger());
private AdvancedServerList core;
private FaviconHandler<CachedServerIcon> faviconHandler;
@Override
public void onEnable(){
try{
Class.forName("io.papermc.paper.configuration.ConfigurationLoaders");
enable();
}catch(ClassNotFoundException ex){
try{
Class.forName("com.destroystokyo.paper.PaperConfig");
enable();
}catch(ClassNotFoundException ex1){
printSpigotWarning();
getServer().getPluginManager().disablePlugin(this);
}
}
}
@Override
public void onDisable(){
if(getCore() == null)
return; // This is always the case when the plugin is used on a Spigot server (See above try-catch blocks).
getCore().disable();
}
@Override
public void loadCommands(){
PluginCommand cmd = getServer().getPluginCommand("advancedserverlist");
if(cmd == null){
getPluginLogger().warn("Could not register command /advancedserverlist");
return;
}
cmd.setExecutor(new CmdAdvancedServerList(this));
}
@Override
public void loadEvents(){
new JoinEvent(this);
new PingEvent(this);
}
@Override
public void loadMetrics(){
new Metrics(this, 15584).addCustomChart(new SimplePie("profiles",
() -> String.valueOf(core.getFileHandler().getProfiles().size())
));
}
@Override
public void clearFaviconCache(){
if(faviconHandler == null)
return;
faviconHandler.clearCache();
}
@Override
public AdvancedServerList getCore(){
return core;
}
@Override
public Path getFolderPath(){
return getDataFolder().toPath();
}
@Override
public PluginLogger getPluginLogger(){
return logger;
}
@Override
public FaviconHandler<CachedServerIcon> getFaviconHandler(){
if(faviconHandler == null)
faviconHandler = new FaviconHandler<>(core);
return faviconHandler;
}
@Override
public String getPlatformName(){
return getServer().getName();
}
@Override
public String getPlatformVersion(){
return getServer().getVersion();
}
@Override
public String getLoader(){
return "paper";
}
private void enable(){
this.core = new AdvancedServerList(this, new PaperPlayerPlaceholders());
if(getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"))
new PAPIPlaceholders(this);
}
private void printSpigotWarning(){
getPluginLogger().warn("======================================== WARNING ========================================");
getPluginLogger().warn("");
getPluginLogger().warn("You are using the Paper version of AdvancedServerList on a SpigotMC server.");
getPluginLogger().warn("The Paper version is ONLY compatible with Paper itself due to it using exclusive");
getPluginLogger().warn("methods and events not available within SpigotMC.");
getPluginLogger().warn("");
getPluginLogger().warn("To avoid any exceptions and errors will AdvancedServerList disable itself now.");
getPluginLogger().warn("Please stop your server and either switch to Paper or use the Spigot version");
getPluginLogger().warn("of AdvancedServerList.");
getPluginLogger().warn("");
getPluginLogger().warn("Paper can be downloaded here:");
getPluginLogger().warn("https://papermc.io/downloads");
getPluginLogger().warn("");
getPluginLogger().warn("======================================== WARNING ========================================");
}
}
@@ -1,48 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.commands;
import ch.andre601.advancedserverlist.paper.PaperCore;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class CmdAdvancedServerList implements CommandExecutor{
private final PaperCore plugin;
public CmdAdvancedServerList(PaperCore plugin){
this.plugin = plugin;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args){
plugin.getCore().getCommandHandler().handle(new PaperCmdSender(sender), args);
return true;
}
}
@@ -1,49 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.commands;
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
import org.bukkit.command.CommandSender;
public class PaperCmdSender implements CmdSender{
private final CommandSender sender;
public PaperCmdSender(CommandSender sender){
this.sender = sender;
}
@Override
public boolean hasPermission(String permission){
return sender.hasPermission(permission) || sender.hasPermission("advancedserverlist.admin");
}
@Override
public void sendMsg(String msg, Object... args){
sender.sendMessage(ComponentParser.text(String.format(msg, args)).toComponent());
}
}
@@ -1,54 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.events;
import ch.andre601.advancedserverlist.paper.PaperCore;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import java.net.InetSocketAddress;
public class JoinEvent implements Listener{
private final PaperCore plugin;
public JoinEvent(PaperCore plugin){
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onJoin(PlayerJoinEvent event){
InetSocketAddress address = event.getPlayer().getAddress();
if(address == null)
return;
Player player = event.getPlayer();
plugin.getCore().getPlayerHandler().addPlayer(address.getHostString(), player.getName(), player.getUniqueId());
}
}
@@ -1,181 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.events;
import ch.andre601.advancedserverlist.api.events.GenericServerListEvent;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.core.interfaces.core.PluginCore;
import ch.andre601.advancedserverlist.core.interfaces.events.GenericEventWrapper;
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
import ch.andre601.advancedserverlist.paper.PaperCore;
import ch.andre601.advancedserverlist.paper.objects.PaperPlayerImpl;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import com.destroystokyo.paper.profile.PlayerProfile;
import me.clip.placeholderapi.PlaceholderAPI;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.util.CachedServerIcon;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon, PaperPlayerImpl>{
private final PaperCore plugin;
private final PaperServerListPingEvent event;
public PaperEventWrapper(PaperCore plugin, PaperServerListPingEvent event){
this.plugin = plugin;
this.event = event;
}
@Override
public GenericServerListEvent callEvent(ProfileEntry entry){
PreServerListSetEventImpl event = new PreServerListSetEventImpl(entry);
plugin.getServer().getPluginManager().callEvent(event);
return event;
}
@Override
public void setMaxPlayers(int maxPlayers){
event.setMaxPlayers(maxPlayers);
}
@Override
public void setMotd(Component component){
event.motd(component);
}
@Override
public void hidePlayers(){
event.setHidePlayers(true);
}
@Override
public void setPlayerCount(String name){
event.setVersion(name);
event.setProtocolVersion(-1);
}
@Override
public void setPlayers(List<String> lines, PaperPlayerImpl player, GenericServer server){
event.getPlayerSample().clear();
List<PlayerProfile> players = new ArrayList<>(lines.size());
for(String line : lines){
String parsed = ComponentParser.text(line)
.modifyText(text -> StringReplacer.replace(text, player, server))
.modifyText(text -> {
if(plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"))
return PlaceholderAPI.setPlaceholders(player.getPlayer(), text);
return text;
})
.toString();
players.add(Bukkit.createProfile(UUID.randomUUID(), parsed));
}
event.getPlayerSample().addAll(players);
}
@Override
public void setFavicon(CachedServerIcon favicon){
event.setServerIcon(favicon);
}
@Override
public void setDefaultFavicon(){
event.setServerIcon(event.getServerIcon());
}
// Not used in Paper
@Override
public void updateEvent(){}
// Not used in Paper
@Override
public boolean isInvalidProtocol(){
return false;
}
@Override
public int getProtocolVersion(){
return event.getClient().getProtocolVersion();
}
@Override
public int getOnlinePlayers(){
return event.getNumPlayers();
}
@Override
public int getMaxPlayers(){
return event.getMaxPlayers();
}
@Override
public String getPlayerIP(){
return event.getClient().getAddress().getHostString();
}
@Override
public String parsePAPIPlaceholders(String text, PaperPlayerImpl player){
if(plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"))
return PlaceholderAPI.setPlaceholders(player.getPlayer(), text);
return text;
}
@Override
public String getVirtualHost(){
return this.resolveHost(event.getClient().getVirtualHost());
}
@Override
public PluginCore<CachedServerIcon> getPlugin(){
return plugin;
}
@Override
public PaperPlayerImpl createPlayer(CachedPlayer player, int protocol){
OfflinePlayer pl = Bukkit.getOfflinePlayer(player.getUuid());
return new PaperPlayerImpl(pl.hasPlayedBefore() ? pl : null, player, protocol);
}
@Override
public CachedServerIcon createFavicon(BufferedImage image) throws Exception{
return Bukkit.loadServerIcon(image);
}
}
@@ -1,47 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.events;
import ch.andre601.advancedserverlist.core.events.PingEventHandler;
import ch.andre601.advancedserverlist.paper.PaperCore;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class PingEvent implements Listener{
private final PaperCore plugin;
public PingEvent(PaperCore plugin){
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onServerPing(PaperServerListPingEvent event){
PingEventHandler.handleEvent(new PaperEventWrapper(plugin, event));
}
}
@@ -1,60 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.logging;
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
import java.util.logging.Level;
import java.util.logging.Logger;
public class PaperLogger implements PluginLogger{
private final Logger logger;
public PaperLogger(Logger logger){
this.logger = logger;
}
@Override
public void info(String msg, Object... args){
logger.info(String.format(msg, args));
}
@Override
public void warn(String msg, Object... args){
logger.warning(String.format(msg, args));
}
@Override
public void warn(String msg, Throwable throwable){
logger.log(Level.WARNING, msg, throwable);
}
@Override
public void warn(String msg, Throwable throwable, Object... args){
logger.log(Level.WARNING, String.format(msg, args), throwable);
}
}
@@ -1,122 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.objects;
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.api.profiles.ProfileEntry;
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
import ch.andre601.advancedserverlist.core.objects.GenericServerImpl;
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
import ch.andre601.advancedserverlist.core.profiles.ServerListProfile;
import ch.andre601.advancedserverlist.core.profiles.profile.ProfileManager;
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
import ch.andre601.advancedserverlist.paper.PaperCore;
import com.viaversion.viaversion.api.Via;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
public class PAPIPlaceholders extends PlaceholderExpansion{
private final PaperCore plugin;
public PAPIPlaceholders(PaperCore plugin){
this.plugin = plugin;
this.register();
}
@Override
public @NotNull String getIdentifier(){
return "asl";
}
@Override
public @NotNull String getAuthor(){
return String.join(", ", plugin.getDescription().getAuthors());
}
@Override
public @NotNull String getVersion(){
return plugin.getDescription().getVersion();
}
@Override
public String onPlaceholderRequest(Player pl, @NotNull String identifier){
String host = pl.getVirtualHost() == null ? null : pl.getVirtualHost().getHostString();
CachedPlayer cached = plugin.getCore().getPlayerHandler().getCachedPlayer(pl.getUniqueId());
// Check if ViaVersion is enabled to resolve the player's protocol version.
// If not can we assume the client's version to be the same as the server's.
int protocol;
if(Bukkit.getPluginManager().isPluginEnabled("ViaVersion")){
protocol = Via.getAPI().getPlayerVersion(pl.getUniqueId());
}else{
protocol = Bukkit.getUnsafe().getProtocolVersion();
}
int online = Bukkit.getOnlinePlayers().size();
int max = Bukkit.getMaxPlayers();
GenericServer server = new GenericServerImpl(online, max, host);
GenericPlayer player = new PaperPlayerImpl(pl, cached, protocol);
ServerListProfile profile = ProfileManager.resolveProfile(plugin.getCore(), player, server);
if(profile == null)
return null;
ProfileEntry entry = ProfileManager.merge(profile);
if(ProfileManager.checkOption(entry.isExtraPlayersEnabled()))
max = online + (entry.getExtraPlayersCount() == null ? 0 : entry.getExtraPlayersCount());
GenericServer finalServer = new GenericServerImpl(online, max, host);
return switch(identifier.toLowerCase(Locale.ROOT)){
case "motd" -> ComponentParser.list(entry.getMotd())
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.toString();
case "favicon" -> ComponentParser.text(entry.getFavicon())
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.toString();
case "playercount_hover" -> ComponentParser.list(entry.getPlayers())
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.toString();
case "playercount_text" -> ComponentParser.text(entry.getPlayerCountText())
.modifyText(text -> PlaceholderAPI.setPlaceholders(pl, text))
.modifyText(text -> StringReplacer.replace(text, player, finalServer))
.toString();
case "extra_players_max" -> String.valueOf(max);
default -> null;
};
}
}
@@ -1,74 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.objects;
import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
import ch.andre601.advancedserverlist.core.profiles.players.GenericPlayerImpl;
import ch.andre601.advancedserverlist.spigot.objects.SpigotPlayer;
import org.bukkit.OfflinePlayer;
public class PaperPlayerImpl extends GenericPlayerImpl implements SpigotPlayer{
private final OfflinePlayer player;
private boolean playedBefore = false;
private boolean banned = false;
private boolean whitelisted = false;
public PaperPlayerImpl(OfflinePlayer player, CachedPlayer cachedPlayer, int protocol){
this.player = player;
this.name = player == null ? cachedPlayer.getName() : player.getName();
this.protocol = protocol;
this.uuid = player == null ? cachedPlayer.getUuid() : player.getUniqueId();
if(player == null)
return;
this.playedBefore = player.hasPlayedBefore();
this.banned = player.isBanned();
this.whitelisted = player.isWhitelisted();
}
@Override
public OfflinePlayer getPlayer(){
return player;
}
@Override
public boolean hasPlayedBefore(){
return playedBefore;
}
@Override
public boolean isBanned(){
return banned;
}
@Override
public boolean isWhitelisted(){
return whitelisted;
}
}
@@ -1,57 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2022-2023 Andre_601
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package ch.andre601.advancedserverlist.paper.objects;
import ch.andre601.advancedserverlist.api.PlaceholderProvider;
import ch.andre601.advancedserverlist.api.objects.GenericPlayer;
import ch.andre601.advancedserverlist.api.objects.GenericServer;
import ch.andre601.advancedserverlist.spigot.objects.SpigotPlayer;
public class PaperPlayerPlaceholders extends PlaceholderProvider{
public PaperPlayerPlaceholders(){
super("player");
}
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
SpigotPlayer paperPlayer = (SpigotPlayer)player;
return switch(placeholder){
case "name" -> paperPlayer.getName();
case "protocol" -> String.valueOf(paperPlayer.getProtocol());
case "uuid" -> String.valueOf(paperPlayer.getUUID());
case "hasPlayedBefore" -> returnValue(paperPlayer, paperPlayer.hasPlayedBefore());
case "isBanned" -> returnValue(paperPlayer, paperPlayer.isBanned());
case "isWhitelisted" -> returnValue(paperPlayer, paperPlayer.isWhitelisted());
default -> null;
};
}
private String returnValue(SpigotPlayer player, Object value){
return player.getPlayer() == null ? null : String.valueOf(value);
}
}
-47
View File
@@ -1,47 +0,0 @@
name: 'AdvancedServerList'
author: 'Andre_601'
version: '${plugin.version}'
description: '${plugin.description}'
main: 'ch.andre601.advancedserverlist.paper.PaperCore'
api-version: 1.19
libraries:
- 'com.squareup.okhttp3:okhttp:4.10.0'
softdepend:
- 'PlaceholderAPI'
- 'ViaVersion'
commands:
advancedserverlist:
description: 'Main command of AdvancedServerList'
usage: '/<command> [help|reload]'
aliases:
- 'asl'
permission: 'advancedserverlist.admin'
permissions:
advancedserverlist.*:
description: 'Grants access to all permissions'
default: op
children:
- 'advancedserverlist.admin'
advancedserverlist.admin:
description: 'Grants access to all permissions'
default: op
children:
- 'advancedserverlist.command.*'
advancedserverlist.command.*:
description: 'Grants access to all commands'
default: op
children:
- 'advancedserverlist.command.help'
- 'advancedserverlist.command.reload'
advancedserverlist.command.help:
description: 'Grants access to /asl help'
default: op
advancedserverlist.command.reload:
description: 'Grants access to /asl reload'
default: op
+18 -3
View File
@@ -36,16 +36,31 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.commit/>
<plugin.version>3.0.0-b1</plugin.version>
<plugin.version>3.0.2</plugin.version>
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
<api.version>v2.0.0</api.version>
<api.version>v2.1.0</api.version>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<profiles>
<profile>
<id>gh-actions</id>
<activation>
<property>
<name>env.COMMIT_SHA</name>
</property>
</activation>
<properties>
<project.build.commit>_${env.COMMIT_SHA}</project.build.commit>
</properties>
</profile>
</profiles>
<repositories>
<repository>
<id>jitpack</id>
@@ -56,8 +71,8 @@
<modules>
<module>core</module>
<module>bungeecord</module>
<module>paper</module>
<module>bukkit</module>
<module>velocity</module>
<module>hangar-uploader</module>
</modules>
</project>
+1 -1
View File
@@ -1 +1 @@
mkdocs-material==9.1.3
mkdocs-material==9.1.9
+14 -6
View File
@@ -72,13 +72,25 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>configurate-yaml</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.11.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>AdvancedServerList-Velocity-${plugin.version}</finalName>
<finalName>AdvancedServerList-Velocity-${plugin.version}${project.build.commit}</finalName>
<resources>
<resource>
<filtering>true</filtering>
@@ -106,10 +118,6 @@
<pattern>org.bstats</pattern>
<shadedPattern>ch.andre601.advancedserverlist.velocity.depends.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>ch.andre601.advancedserverlist.velocity.depends.caffeine</shadedPattern>
</relocation>
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>ch.andre601.advancedserverlist.velocity.depends.okhttp3</shadedPattern>
@@ -55,7 +55,7 @@ public class VelocityCore implements PluginCore<Favicon>{
private final Path path;
private final Metrics.Factory metrics;
private AdvancedServerList core;
private AdvancedServerList<Favicon> core;
private FaviconHandler<Favicon> faviconHandler = null;
@Inject
@@ -69,7 +69,7 @@ public class VelocityCore implements PluginCore<Favicon>{
@Subscribe
public void init(ProxyInitializeEvent event){
this.core = new AdvancedServerList(this, new VelocityPlayerPlaceholders());
this.core = AdvancedServerList.init(this, VelocityPlayerPlaceholders.init());
}
@Subscribe
@@ -109,7 +109,7 @@ public class VelocityCore implements PluginCore<Favicon>{
}
@Override
public AdvancedServerList getCore(){
public AdvancedServerList<Favicon> getCore(){
return core;
}
@@ -31,10 +31,14 @@ import ch.andre601.advancedserverlist.api.objects.GenericServer;
public class VelocityPlayerPlaceholders extends PlaceholderProvider{
public VelocityPlayerPlaceholders(){
private VelocityPlayerPlaceholders(){
super("player");
}
public static VelocityPlayerPlaceholders init(){
return new VelocityPlayerPlaceholders();
}
@Override
public String parsePlaceholder(String placeholder, GenericPlayer player, GenericServer server){
return switch(placeholder){