├── .github
├── issue_template.md
└── workflows
│ ├── gradle.yml
│ ├── javadocs.yml
│ ├── prerelease.yml
│ └── release.yml
├── .gitignore
├── .gitlab-ci.yml
├── LICENSE
├── README.md
├── api
├── build.gradle.kts
└── src
│ └── main
│ └── java
│ └── us
│ └── ajg0702
│ └── queue
│ └── api
│ ├── AjQueueAPI.java
│ ├── AliasManager.java
│ ├── EventHandler.java
│ ├── Implementation.java
│ ├── PlatformMethods.java
│ ├── ProtocolNameManager.java
│ ├── QueueManager.java
│ ├── ServerTimeManager.java
│ ├── commands
│ ├── IBaseCommand.java
│ ├── ICommandSender.java
│ └── ISubCommand.java
│ ├── communication
│ └── ComResponse.java
│ ├── events
│ ├── AutoQueueOnKickEvent.java
│ ├── BuildServersEvent.java
│ ├── Cancellable.java
│ ├── Event.java
│ ├── PositionChangeEvent.java
│ ├── PreConnectEvent.java
│ ├── PreQueueEvent.java
│ ├── PriorityCalculationEvent.java
│ ├── SuccessfulSendEvent.java
│ └── utils
│ │ └── EventReceiver.java
│ ├── players
│ ├── AdaptedPlayer.java
│ └── QueuePlayer.java
│ ├── premium
│ ├── Logic.java
│ ├── LogicGetter.java
│ ├── PermissionGetter.java
│ ├── PermissionHook.java
│ └── PermissionHookRegistry.java
│ ├── queueholders
│ ├── QueueHolder.java
│ └── QueueHolderRegistry.java
│ ├── queues
│ ├── Balancer.java
│ └── QueueServer.java
│ ├── server
│ ├── AdaptedServer.java
│ ├── AdaptedServerInfo.java
│ └── AdaptedServerPing.java
│ ├── spigot
│ ├── AjQueueSpigotAPI.java
│ └── MessagedResponse.java
│ └── util
│ ├── Handle.java
│ └── QueueLogger.java
├── build.gradle.kts
├── common
├── build.gradle.kts
└── src
│ └── main
│ ├── java
│ └── us
│ │ └── ajg0702
│ │ └── queue
│ │ ├── commands
│ │ ├── BaseCommand.java
│ │ ├── SubCommand.java
│ │ └── commands
│ │ │ ├── PlayerSender.java
│ │ │ ├── SlashServer
│ │ │ └── SlashServerCommand.java
│ │ │ ├── leavequeue
│ │ │ └── LeaveCommand.java
│ │ │ ├── listqueues
│ │ │ └── ListCommand.java
│ │ │ ├── manage
│ │ │ ├── Kick.java
│ │ │ ├── KickAll.java
│ │ │ ├── ManageCommand.java
│ │ │ ├── Pause.java
│ │ │ ├── PauseQueueServer.java
│ │ │ ├── QueueList.java
│ │ │ ├── Reload.java
│ │ │ ├── Send.java
│ │ │ ├── Update.java
│ │ │ └── debug
│ │ │ │ ├── ISP.java
│ │ │ │ ├── PermissionList.java
│ │ │ │ ├── Protocol.java
│ │ │ │ ├── Tasks.java
│ │ │ │ ├── Version.java
│ │ │ │ └── Whitelist.java
│ │ │ ├── queue
│ │ │ └── QueueCommand.java
│ │ │ └── send
│ │ │ └── SendAlias.java
│ │ ├── common
│ │ ├── DefaultQueueHolder.java
│ │ ├── EventHandlerImpl.java
│ │ ├── ProtocolNameManagerImpl.java
│ │ ├── QueueMain.java
│ │ ├── QueueManagerImpl.java
│ │ ├── ServerTimeManagerImpl.java
│ │ ├── SlashServerManager.java
│ │ ├── TaskManager.java
│ │ ├── communication
│ │ │ ├── CommunicationManager.java
│ │ │ ├── MessageHandler.java
│ │ │ └── handlers
│ │ │ │ ├── AckHandler.java
│ │ │ │ ├── EstimatedTimeHandler.java
│ │ │ │ ├── InQueueHandler.java
│ │ │ │ ├── LeaveQueueHandler.java
│ │ │ │ ├── MassQueueHandler.java
│ │ │ │ ├── PlayerStatusHandler.java
│ │ │ │ ├── PositionHandler.java
│ │ │ │ ├── PositionOfHandler.java
│ │ │ │ ├── QueueHandler.java
│ │ │ │ ├── QueueNameHandler.java
│ │ │ │ ├── QueuedForHandler.java
│ │ │ │ ├── ServerQueueHandler.java
│ │ │ │ └── StatusHandler.java
│ │ ├── players
│ │ │ └── QueuePlayerImpl.java
│ │ ├── queues
│ │ │ ├── QueueServerImpl.java
│ │ │ └── balancers
│ │ │ │ ├── DefaultBalancer.java
│ │ │ │ ├── FirstBalancer.java
│ │ │ │ └── MinigameBalancer.java
│ │ └── utils
│ │ │ ├── Debug.java
│ │ │ ├── LogConverter.java
│ │ │ ├── MapBuilder.java
│ │ │ └── QueueThreadFactory.java
│ │ └── logic
│ │ ├── FreeAliasManager.java
│ │ ├── FreeLogic.java
│ │ └── LogicGetterImpl.java
│ └── resources
│ └── config.yml
├── free
└── build.gradle.kts
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── libs
├── private
│ └── README.md
└── public
│ └── AquaCoreAPI.jar
├── platforms
├── bungeecord
│ ├── build.gradle.kts
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── us
│ │ │ └── ajg0702
│ │ │ └── queue
│ │ │ └── platforms
│ │ │ └── bungeecord
│ │ │ ├── BungeeLogger.java
│ │ │ ├── BungeeMethods.java
│ │ │ ├── BungeeQueue.java
│ │ │ ├── commands
│ │ │ ├── BungeeCommand.java
│ │ │ └── BungeeSender.java
│ │ │ ├── players
│ │ │ └── BungeePlayer.java
│ │ │ └── server
│ │ │ ├── BungeeServer.java
│ │ │ ├── BungeeServerInfo.java
│ │ │ └── BungeeServerPing.java
│ │ └── resources
│ │ └── bungee.yml
└── velocity
│ ├── build.gradle.kts
│ └── src
│ └── main
│ └── java
│ └── us
│ └── ajg0702
│ └── queue
│ └── platforms
│ └── velocity
│ ├── VelocityLogger.java
│ ├── VelocityMethods.java
│ ├── VelocityQueue.java
│ ├── commands
│ ├── VelocityCommand.java
│ └── VelocitySender.java
│ ├── players
│ └── VelocityPlayer.java
│ └── server
│ ├── VelocityServer.java
│ ├── VelocityServerInfo.java
│ └── VelocityServerPing.java
├── premium
├── build.gradle.kts
└── src
│ └── main
│ └── java
│ └── us
│ └── ajg0702
│ └── queue
│ └── logic
│ ├── LogicGetterImpl.java
│ ├── PremiumAliasManager.java
│ ├── PremiumLogic.java
│ └── permissions
│ ├── PermissionGetterImpl.java
│ └── hooks
│ ├── AquaCoreHook.java
│ ├── BuiltInHook.java
│ ├── LuckPermsHook.java
│ └── UltraPermissionsHook.java
├── settings.gradle.kts
├── spigot
├── build.gradle.kts
└── src
│ └── main
│ ├── java
│ └── us
│ │ └── ajg0702
│ │ └── queue
│ │ └── spigot
│ │ ├── Commands.java
│ │ ├── Placeholders.java
│ │ ├── QueueScoreboardActivator.java
│ │ ├── SpigotMain.java
│ │ ├── api
│ │ └── SpigotAPI.java
│ │ ├── communication
│ │ ├── ResponseKey.java
│ │ └── ResponseManager.java
│ │ ├── placeholders
│ │ ├── CachedPlaceholder.java
│ │ ├── Placeholder.java
│ │ ├── PlaceholderExpansion.java
│ │ └── placeholders
│ │ │ ├── EstimatedTime.java
│ │ │ ├── InQueue.java
│ │ │ ├── Position.java
│ │ │ ├── PositionOf.java
│ │ │ ├── Queued.java
│ │ │ ├── QueuedFor.java
│ │ │ ├── Status.java
│ │ │ └── StatusPlayer.java
│ │ └── utils
│ │ ├── ActionBar.java
│ │ ├── UUIDStringKey.java
│ │ └── VersionSupport.java
│ └── resources
│ ├── plugin.yml
│ └── spigot-config.yml
└── update.md
/.github/issue_template.md:
--------------------------------------------------------------------------------
1 |
12 |
--------------------------------------------------------------------------------
/.github/workflows/gradle.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub.
2 | # They are provided by a third-party and are governed by
3 | # separate terms of service, privacy policy, and support
4 | # documentation.
5 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
7 |
8 | name: Java CI with Gradle
9 |
10 | on: [push, pull_request]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK 11
20 | uses: actions/setup-java@v2
21 | with:
22 | java-version: '11'
23 | distribution: 'temurin'
24 | - name: Build with Gradle
25 | uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
26 | with:
27 | arguments: :free:shadowJar :premium:shadowJar
28 | - name: Upload plugin jar artifact
29 | uses: actions/upload-artifact@v2.3.1
30 | with:
31 | # Artifact name
32 | name: plugin jar
33 | # A file, directory or wildcard pattern that describes what to upload
34 | path: free/build/libs/ajQueue*.jar
35 | # The desired behavior if no files are found using the provided path.
36 | if-no-files-found: error
37 | - name: Upload build files artifact
38 | uses: actions/upload-artifact@v2.3.1
39 | with:
40 | # Artifact name
41 | name: build-files
42 | # A file, directory or wildcard pattern that describes what to upload
43 | path: '*/build/*'
44 | # The desired behavior if no files are found using the provided path.
45 | if-no-files-found: error
46 | retention-days: 2
47 | deploy:
48 | runs-on: ubuntu-latest
49 | environment: maven-repo-deploy
50 | env:
51 | REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
52 | needs: build
53 | if: github.ref == 'refs/heads/master'
54 | steps:
55 | - uses: actions/checkout@v2
56 | - uses: actions/download-artifact@v2
57 | with:
58 | name: build-files
59 | - name: Deploy api with Gradle
60 | run: './gradlew :api:publish'
61 | - name: Deploy common with Gradle
62 | run: './gradlew :common:publish'
63 | updater:
64 | runs-on: ubuntu-latest
65 | environment: upload-to-updater
66 | if: github.ref == 'refs/heads/master'
67 | needs: build
68 | steps:
69 | - uses: actions/checkout@v2
70 | - uses: actions/download-artifact@v2
71 | with:
72 | name: build-files
73 | - run: |
74 | mkdir jars
75 | cp free/build/libs/ajQueue*.jar jars/
76 | cp premium/build/libs/ajQueue*.jar jars/
77 | cd jars
78 | files=(*)
79 | ls
80 | echo ${files[0]}
81 | echo ${files[1]}
82 | curl -i -F "submit=true" -F "secret=${{ secrets.UPLOAD_TOKEN }}" -F "file=@${files[0]}" https://ajg0702.us/pl/updater/upload.php
83 | curl -i -F "submit=true" -F "secret=${{ secrets.UPLOAD_TOKEN }}" -F "file=@${files[1]}" https://ajg0702.us/pl/updater/upload.php
--------------------------------------------------------------------------------
/.github/workflows/javadocs.yml:
--------------------------------------------------------------------------------
1 | name: JavaDocs Generation
2 |
3 | on:
4 | push:
5 | branches: ["master"]
6 |
7 | # Allows you to run this workflow manually from the Actions tab
8 | workflow_dispatch:
9 |
10 | permissions:
11 | contents: read
12 | pages: write
13 | id-token: write
14 |
15 | jobs:
16 | build:
17 | runs-on: ubuntu-latest
18 | steps:
19 | - name: Checkout
20 | uses: actions/checkout@v3
21 | - name: Setup Pages
22 | uses: actions/configure-pages@v3
23 | - name: Set up JDK 11
24 | uses: actions/setup-java@v2
25 | with:
26 | java-version: '11'
27 | distribution: 'temurin'
28 | - name: Build with Gradle
29 | uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
30 | with:
31 | arguments: :api:javadoc
32 | - name: Upload artifact
33 | uses: actions/upload-pages-artifact@v1
34 | with:
35 | path: 'api/build/docs/javadoc'
36 |
37 | deploy:
38 | environment:
39 | name: github-pages
40 | url: ${{ steps.deployment.outputs.page_url }}
41 | runs-on: ubuntu-latest
42 | needs: build
43 | steps:
44 | - name: Deploy to GitHub Pages
45 | id: deployment
46 | uses: actions/deploy-pages@v2
--------------------------------------------------------------------------------
/.github/workflows/prerelease.yml:
--------------------------------------------------------------------------------
1 | name: Deploy Pre-Release to Polymart/Modrinth
2 |
3 | on:
4 | push:
5 | branches:
6 | - dev
7 |
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 | environment: polymart_deploy
13 | if: |
14 | !github.event.pull_request.head.repo.fork &&
15 | !contains(github.event.head_commit.message, '[nolist]')
16 | steps:
17 | - uses: actions/checkout@v2
18 | - name: Set up JDK 11
19 | uses: actions/setup-java@v2
20 | with:
21 | java-version: '11'
22 | distribution: 'temurin'
23 | - name: Change version to include build
24 | run: |
25 | export OLD_VERSION=`cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}'`
26 | export NEW_VERSION=$OLD_VERSION-b${{github.run_number}}
27 | (cat build.gradle.kts | sed "s/$OLD_VERSION/$NEW_VERSION/") > temp.txt
28 | mv temp.txt build.gradle.kts
29 | echo Version number is now $(cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}') - $NEW_VERSION
30 | cat build.gradle.kts
31 | - name: Build with Gradle
32 | uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
33 | with:
34 | arguments: :free:shadowJar :premium:shadowJar
35 | - name: Upload build files artifact
36 | uses: actions/upload-artifact@v2.3.1
37 | with:
38 | # Artifact name
39 | name: build-files
40 | # A file, directory or wildcard pattern that describes what to upload
41 | path: '*/build/*'
42 | # The desired behavior if no files are found using the provided path.
43 | if-no-files-found: error
44 | retention-days: 2
45 | - name: Deploy to Polymart/Modrinth
46 | env:
47 | POLYMART_TOKEN: ${{ secrets.POLYMART_TOKEN }}
48 | MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
49 | run: |
50 | export VERSION=`cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}'`
51 | curl --no-progress-meter -A "AJUPDATER/1.0" -H "Authorization: $MODRINTH_TOKEN" -F data="{\"project_id\": \"dzacATni\", \"version_number\": \"$VERSION\", \"name\": \"Pre-release v$VERSION\", \"changelog\": \"Note: This is a (most likely) un-tested build. It is not guarenteed to work.
Change since previous build:
${{ github.event.head_commit.message }}\", \"file_parts\": [\"file\"], \"version_type\": \"beta\", \"loaders\": [\"bungeecord\", \"velocity\"], \"featured\": false, \"game_versions\": $(curl https://ajg0702.us/pl/updater/mc-versions.php), \"dependencies\": [], \"primary_file\": \"file\"}" -F "file=@free/build/libs/ajQueue-$VERSION.jar" "https://api.modrinth.com/v2/version"
52 | curl -F "file=@free/build/libs/ajQueue-$VERSION.jar" -F api_key=$POLYMART_TOKEN -F resource_id="2535" -F version="$VERSION" -F title="Pre-release v$VERSION" -F beta=1 -F message=$'Note: This is a (most likely) un-tested build. It is not guarenteed to work!\n\nChange since previous build:\n[url=${{ github.event.compare }}"]${{ github.event.head_commit.message }}[/url]' "https://api.polymart.org/v1/postUpdate"
53 | curl -F "file=@premium/build/libs/ajQueuePlus-$VERSION.jar" -F api_key=$POLYMART_TOKEN -F resource_id="2714" -F version="$VERSION" -F title="Pre-release v$VERSION" -F beta=1 -F message=$'Note: This is a (most likely) un-tested build. It is not guarenteed to work!\n\nChange since previous build:\n[url=${{ github.event.compare }}"]${{ github.event.head_commit.message }}[/url]' "https://api.polymart.org/v1/postUpdate"
54 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Deploy Release to Polymart/Modrinth
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 | environment: polymart_deploy
13 | if: ${{ !github.event.pull_request.head.repo.fork }}
14 | steps:
15 | - uses: actions/checkout@v2
16 | - name: Set up JDK 11
17 | uses: actions/setup-java@v2
18 | with:
19 | java-version: '11'
20 | distribution: 'temurin'
21 | - name: Build with Gradle
22 | uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
23 | with:
24 | arguments: :free:shadowJar :premium:shadowJar
25 | - name: Upload build files artifact
26 | uses: actions/upload-artifact@v2.3.1
27 | with:
28 | # Artifact name
29 | name: build-files
30 | # A file, directory or wildcard pattern that describes what to upload
31 | path: '*/build/*'
32 | # The desired behavior if no files are found using the provided path.
33 | if-no-files-found: error
34 | retention-days: 2
35 | # - name: Download changelogs
36 | # run: |
37 | # curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}" > changelogs.bb
38 | # curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}&format=html" > changelogs.html
39 | # - name: Deploy to Polymart/Modrinth
40 | # env:
41 | # POLYMART_TOKEN: ${{ secrets.POLYMART_TOKEN }}
42 | # MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
43 | # DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
44 | # run: |
45 | # export VERSION=`cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}'`
46 | # curl --no-progress-meter -A "AJUPDATER/1.0" -H "Authorization: $MODRINTH_TOKEN" -F data="{\"project_id\": \"dzacATni\", \"version_number\": \"$VERSION\", \"name\": \"v$VERSION\", \"changelog\": \"$(cat changelogs.html)\", \"file_parts\": [\"file\"], \"version_type\": \"release\", \"loaders\": [\"bungeecord\", \"velocity\"], \"featured\": true, \"game_versions\": $(curl https://ajg0702.us/pl/updater/mc-versions.php), \"dependencies\": [], \"primary_file\": \"file\"}" -F "file=@free/build/libs/ajQueue-$VERSION.jar" "https://api.modrinth.com/v2/version"
47 | # curl -F "file=@free/build/libs/ajQueue-$VERSION.jar" -F api_key=$POLYMART_TOKEN -F resource_id="2535" -F version="$VERSION" -F title="v$VERSION" -F message="$(cat changelogs.bb)" "https://api.polymart.org/v1/postUpdate"
48 | # curl -F "file=@premium/build/libs/ajQueuePlus-$VERSION.jar" -F api_key=$POLYMART_TOKEN -F resource_id="2714" -F version="$VERSION" -F title="v$VERSION" -F message="$(cat changelogs.bb)" "https://api.polymart.org/v1/postUpdate"
49 | # curl -v --no-progress-meter -H "Content-Type: application/json" --request POST -d "{\"content\": \"<@&861713403080999003>\", \"embeds\": [{\"title\": \"${{ github.event.repository.name }} v$VERSION\", \"description\": \"Changelogs\n\n$(curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}&format=markdown")\n\n[Modrinth (free)](https://modrinth.com/plugin/ajQueue/version/$VERSION)\n[Polymart (free)](https://polymart.org/resource/2535/updates)\n[Polymart (plus)](https://polymart.org/resource/2714/updates)\", \"color\": 14845503, \"thumbnail\": {\"url\": \"https://ajg0702.us/pl/icons/${{ github.event.repository.name }}.png\"}}]}" "$DISCORD_WEBHOOK"
50 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | .idea
3 | .classpath
4 | .project
5 | dependency-reduced-pom.xml
6 | .gradle
7 | build
8 | .DS_Store
9 | .nosync
10 | libs/private/*
11 | !libs/private/README.md
12 |
--------------------------------------------------------------------------------
/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | image: gradle:7.2.0-jdk8
2 |
3 | # Cache downloaded dependencies and plugins between builds.
4 | # To keep cache across branches add 'key: "$CI_JOB_NAME"'
5 | cache:
6 | paths:
7 | - .gradle
8 | - ~/.gradle
9 |
10 |
11 | build:
12 | retry: 2
13 | stage: build
14 | script:
15 | - gradle clean :free:shadowJar
16 | - mkdir jars
17 | - cp free/build/libs/ajQueue*.jar jars/
18 | - gradle :premium:shadowJar
19 | - cp premium/build/libs/ajQueue*.jar jars/
20 | artifacts:
21 | untracked: true
22 | paths:
23 | - jars
24 |
25 | pages:
26 | retry: 2
27 | stage: build
28 | image: gradle:6.8.3-jdk15
29 | only:
30 | - master
31 | script:
32 | - gradle :api:javadoc
33 | - mv api/build/docs/javadoc public
34 | artifacts:
35 | paths:
36 | - public
37 |
38 | test:
39 | retry: 2
40 | stage: test
41 | dependencies:
42 | - build
43 | script:
44 | - gradle :free:test
45 |
46 | deploy to maven repo:
47 | stage: deploy
48 | only:
49 | - master
50 | dependencies:
51 | - build
52 | script:
53 | - gradle :api:publish --stacktrace
54 | - gradle :common:publish
55 |
56 | upload to updater:
57 | stage: deploy
58 | only:
59 | - master
60 | dependencies:
61 | - build
62 | script:
63 | - cd jars
64 | - files=(*)
65 | - curl -i -F "submit=true" -F "secret=$UPLOAD_SECRET" -F "file=@${files[0]}" https://ajg0702.us/pl/updater/upload.php
66 | - curl -i -F "submit=true" -F "secret=$UPLOAD_SECRET" -F "file=@${files[1]}" https://ajg0702.us/pl/updater/upload.php
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ajQueue
2 |
3 | [Wiki](https://wiki.ajg0702.us/ajqueue/) |
4 | [Spigot (free)](https://www.spigotmc.org/resources/ajqueue.78266/) |
5 | [Spigot (premium)](https://www.spigotmc.org/resources/ajqueueplus.79123/)
6 |
7 | ajQueue is (as far as I can tell) the best queue plugin out there.
8 | It was made because I wasn't satisfied with the existing queue plugins,
9 | all of them either being massively overpriced, or lacking basic features
10 |
11 | # Contributing
12 | As long as you don't break anything,
13 | i'll probably accept any merge requests you submit.
14 | I like to have the least number of steps possible for server owners
15 | updating my plugin.
16 |
17 | If you need *any* help making your changes, feel free to contact me
18 | on discord. The invite link is on the plugin page ;)
19 |
--------------------------------------------------------------------------------
/api/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `java-library`
3 | `maven-publish`
4 | }
5 |
6 | group = "us.ajg0702.queue.api"
7 |
8 | repositories {
9 | //mavenLocal()
10 |
11 | maven { url = uri("https://repo.ajg0702.us/releases/") }
12 |
13 | mavenCentral()
14 | }
15 |
16 | java {
17 | withJavadocJar()
18 | withSourcesJar()
19 | }
20 |
21 | dependencies {
22 | implementation("net.kyori:adventure-api:4.15.0")
23 | implementation("net.kyori:adventure-text-serializer-plain:4.15.0")
24 | compileOnly("com.google.guava:guava:30.1.1-jre")
25 |
26 | compileOnly("us.ajg0702:ajUtils:1.2.25")
27 | }
28 |
29 | publishing {
30 | publications {
31 | create("mavenJava") {
32 | from(components["java"])
33 | }
34 | }
35 |
36 | repositories {
37 |
38 | val mavenUrl = "https://repo.ajg0702.us/releases"
39 |
40 | if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
41 | maven {
42 | url = uri(mavenUrl)
43 | name = "ajRepo"
44 |
45 | credentials {
46 | username = "plugins"
47 | password = System.getenv("REPO_TOKEN")
48 | }
49 | }
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/AliasManager.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api;
2 |
3 | @SuppressWarnings("unused")
4 | public interface AliasManager {
5 | /**
6 | * Gets an alias from the server/group's name
7 | * @param server The original name of the server
8 | * @return The set alias (set in the config)
9 | */
10 | String getAlias(String server);
11 |
12 | /**
13 | * Gets the name of the server/group from an alias
14 | * @param alias The alias
15 | * @return The name of the server/group
16 | */
17 | String getServer(String alias);
18 | }
19 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/EventHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api;
2 |
3 | import net.kyori.adventure.text.Component;
4 | import org.jetbrains.annotations.Nullable;
5 | import us.ajg0702.queue.api.players.AdaptedPlayer;
6 | import us.ajg0702.queue.api.server.AdaptedServer;
7 |
8 | public interface EventHandler {
9 |
10 | void handleMessage(AdaptedPlayer reciever, byte[] data);
11 |
12 | void onPlayerJoin(AdaptedPlayer player);
13 |
14 | void onPlayerLeave(AdaptedPlayer player);
15 |
16 | /**
17 | * Called when a player joins a server or switches between servers
18 | * @param player the player
19 | */
20 | void onPlayerJoinServer(AdaptedPlayer player);
21 |
22 | void onServerKick(AdaptedPlayer player, AdaptedServer from, Component reason, boolean moving);
23 |
24 | @Nullable
25 | AdaptedServer changeTargetServer(AdaptedPlayer player, AdaptedServer initialChoice);
26 | }
27 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/Implementation.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api;
2 |
3 | import us.ajg0702.queue.api.commands.IBaseCommand;
4 |
5 | public interface Implementation {
6 | void registerCommand(IBaseCommand command);
7 | void unregisterCommand(String name);
8 | default void unregisterCommand(IBaseCommand command) {
9 | unregisterCommand(command.getName());
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/PlatformMethods.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api;
2 |
3 | import us.ajg0702.queue.api.commands.IBaseCommand;
4 | import us.ajg0702.queue.api.commands.ICommandSender;
5 | import us.ajg0702.queue.api.players.AdaptedPlayer;
6 | import us.ajg0702.queue.api.server.AdaptedServer;
7 |
8 | import java.util.List;
9 | import java.util.UUID;
10 |
11 | public interface PlatformMethods {
12 |
13 | /**
14 | * Sends a plugin message on the plugin messaging channel
15 | * @param player The player to send the message through
16 | * @param channel The (sub)channel
17 | * @param data The data
18 | */
19 | void sendPluginMessage(AdaptedPlayer player, String channel, String... data);
20 |
21 | /**
22 | * Converts a command sender to an AdaptedPlayer
23 | * @param sender the commandsender
24 | * @return the AdaptedPlayer
25 | */
26 | AdaptedPlayer senderToPlayer(ICommandSender sender);
27 |
28 | String getPluginVersion();
29 |
30 | @SuppressWarnings("unused")
31 | List getOnlinePlayers();
32 | List getPlayerNames(boolean lowercase);
33 |
34 | /**
35 | * Gets an online player by their name
36 | * @param name The players name
37 | * @return The AdaptedPlayer for this player
38 | */
39 | AdaptedPlayer getPlayer(String name);
40 |
41 | /**
42 | * Gets an online player by their UUID
43 | * @param uuid their UUID
44 | * @return the AdaptedPlayer for this player
45 | */
46 | AdaptedPlayer getPlayer(UUID uuid);
47 |
48 | /**
49 | * Gets a list of the server names
50 | * @return A list of the server names
51 | */
52 | List getServerNames();
53 |
54 | /**
55 | * Gets the name of the implementation. E.g. bungeecord, velocity
56 | * @return the name of the implementation
57 | */
58 | String getImplementationName();
59 |
60 | List getCommands();
61 |
62 | /**
63 | * Checks if a plugin is installed
64 | * @param pluginName The name of the plugin to check for (case in-sensitive)
65 | * @return if the plugin is on the server
66 | */
67 | boolean hasPlugin(String pluginName);
68 |
69 | /**
70 | * Gets an AdaptedServer from the server name
71 | * @param name The name of the server
72 | * @return The AdaptedServer
73 | */
74 | AdaptedServer getServer(String name);
75 |
76 | List extends AdaptedServer> getServers();
77 |
78 | String getProtocolName(int protocol);
79 | }
80 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/ProtocolNameManager.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api;
2 |
3 | import java.util.HashMap;
4 |
5 | public interface ProtocolNameManager {
6 | String getProtocolName(int protocol);
7 | }
8 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/ServerTimeManager.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 |
5 | public interface ServerTimeManager {
6 | /**
7 | * Gets the time that the player specified was last seen switching servers
8 | * @param player The player to check
9 | * @return The time that they last switched servers, in milliseconds since midnight, January 1, 1970, UTC
10 | */
11 | long getLastServerChange(AdaptedPlayer player);
12 | }
13 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/commands/IBaseCommand.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.commands;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.utils.common.Messages;
5 |
6 | import java.util.List;
7 |
8 | @SuppressWarnings("unused")
9 | public interface IBaseCommand {
10 |
11 | String getName();
12 |
13 | ImmutableList getAliases();
14 |
15 | ImmutableList getSubCommands();
16 |
17 | String getPermission();
18 |
19 | boolean showInTabComplete();
20 |
21 | Messages getMessages();
22 |
23 | void addSubCommand(ISubCommand subCommand);
24 |
25 | void execute(ICommandSender sender, String[] args);
26 |
27 | List autoComplete(ICommandSender sender, String[] args);
28 | }
29 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/commands/ICommandSender.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.commands;
2 |
3 | import net.kyori.adventure.audience.Audience;
4 | import us.ajg0702.queue.api.util.Handle;
5 |
6 | import java.util.UUID;
7 |
8 | @SuppressWarnings("BooleanMethodIsAlwaysInverted")
9 | public interface ICommandSender extends Handle, Audience {
10 | boolean hasPermission(String permission);
11 | boolean isPlayer();
12 |
13 | /**
14 | * @throws IllegalStateException if the sender is not a player
15 | */
16 | UUID getUniqueId() throws IllegalStateException;
17 | }
18 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/commands/ISubCommand.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.commands;
2 |
3 | public interface ISubCommand extends IBaseCommand {
4 | }
5 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/communication/ComResponse.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.communication;
2 |
3 | import com.google.common.io.ByteArrayDataInput;
4 |
5 | import java.util.UUID;
6 |
7 | public class ComResponse {
8 | private String from;
9 | private String response;
10 | private String identifier;
11 | private String noneMessage;
12 |
13 | private ComResponse(String from, String response) {
14 | this.from = from;
15 | this.response = response;
16 | }
17 |
18 | public static ComResponse from(String from) {
19 | return new ComResponse(from, null);
20 | }
21 | public static ComResponse from(String from, ByteArrayDataInput in) {
22 | String id = in.readUTF();
23 | String response = in.readUTF();
24 | String noneMessage = in.readUTF();
25 |
26 | if(id.equalsIgnoreCase("null")) id = null;
27 | if(response.equalsIgnoreCase("null")) response = null;
28 | if(noneMessage.equalsIgnoreCase("null")) noneMessage = null;
29 |
30 | return from(from)
31 | .id(id)
32 | .with(response)
33 | .noneMessage(noneMessage);
34 | }
35 | public ComResponse id(String id) {
36 | this.identifier = id;
37 | return this;
38 | }
39 | public ComResponse id(UUID id) {
40 | this.identifier = String.valueOf(id);
41 | return this;
42 | }
43 | public ComResponse with(String response) {
44 | this.response = response;
45 | return this;
46 | }
47 | public ComResponse with(boolean response) {
48 | this.response = String.valueOf(response);
49 | return this;
50 | }
51 | public ComResponse with(Integer response) {
52 | this.response = String.valueOf(response);
53 | return this;
54 | }
55 |
56 | public ComResponse noneMessage(String message) {
57 | this.noneMessage = message;
58 | return this;
59 | }
60 |
61 | public String getIdentifier() {
62 | return identifier;
63 | }
64 |
65 | public String getFrom() {
66 | return from;
67 | }
68 |
69 | public String getNoneMessage() {
70 | return noneMessage;
71 | }
72 |
73 | public String getResponse() {
74 | return response;
75 | }
76 |
77 | @Override
78 | public String toString() {
79 | return "ComResponse{" +
80 | "from='" + from + '\'' +
81 | ", response='" + response + '\'' +
82 | ", identifier='" + identifier + '\'' +
83 | ", noneMessage='" + noneMessage + '\'' +
84 | '}';
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/AutoQueueOnKickEvent.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 |
5 | /**
6 | * Called before AjQueue auto-queues a player for a server. (on player kick)
7 | * Use Case: View/Change the server that the player is auto-queued for.
8 | * If canceled, the player will not be queued to any server.
9 | * If you cancel this event, it is up to you to send a message telling the player why they were not auto-queued.
10 | */
11 | @SuppressWarnings("unused")
12 | public class AutoQueueOnKickEvent implements Event, Cancellable {
13 | private final AdaptedPlayer player;
14 | private String targetServer;
15 |
16 | private boolean cancelled = false;
17 |
18 | public AutoQueueOnKickEvent(AdaptedPlayer player, String targetServer) {
19 | this.player = player;
20 | this.targetServer = targetServer;
21 | }
22 |
23 | /**
24 | * @return the player that is being re-queued
25 | */
26 | public AdaptedPlayer getPlayer() {
27 | return player;
28 | }
29 |
30 | /**
31 | * @return The name of the server AjQueue will queue the player for.
32 | */
33 | public String getTargetServer() {
34 | return targetServer;
35 | }
36 |
37 | /**
38 | * Set the name of the server AjQueue will queue the player for.
39 | * @param targetServer The name of the server to queue the player for.
40 | */
41 | public void setTargetServer(String targetServer) {
42 | this.targetServer = targetServer;
43 | }
44 |
45 | public boolean isCancelled() {
46 | return cancelled;
47 | }
48 |
49 | public void setCancelled(boolean cancelled) {
50 | this.cancelled = cancelled;
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/Cancellable.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events;
2 |
3 | public interface Cancellable {
4 | /**
5 | * Whether this event is canceled.
6 | * @return True if canceled. False if not.
7 | */
8 | boolean isCancelled();
9 |
10 | /**
11 | * Allows you to cancel or un-cancel this event
12 | * @param cancelled True to cancel the event, false to un-cancel
13 | */
14 | void setCancelled(boolean cancelled);
15 | }
16 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/Event.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events;
2 |
3 | public interface Event {
4 | }
5 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/PositionChangeEvent.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events;
2 |
3 | import org.jetbrains.annotations.Nullable;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.players.QueuePlayer;
6 | import us.ajg0702.queue.api.queues.QueueServer;
7 |
8 | /**
9 | * Called when someone is added or removed from a queue that the player is in, causing the player's position to change
10 | */
11 | public class PositionChangeEvent implements Event {
12 | private final QueuePlayer player;
13 | private final int position;
14 |
15 | public PositionChangeEvent(QueuePlayer player) {
16 | this.player = player;
17 | position = player.getPosition();
18 | }
19 |
20 | /**
21 | * Gets the QueuePlayer object that represents this player
22 | * @return the QueuePlayer object
23 | */
24 | public QueuePlayer getQueuePlayer() {
25 | return player;
26 | }
27 |
28 | /**
29 | * Gets the AdaptedPlayer that this event is about. May return null!
30 | * @return The AdaptedPlayer that this event is about. Returns null if the player is offline.
31 | */
32 | public @Nullable AdaptedPlayer getPlayer() {
33 | return player.getPlayer();
34 | }
35 |
36 | /**
37 | * Gets the player's new position in the queue
38 | * @return The player's new position. 1 being 1st, 2 being 2nd, etc
39 | */
40 | public int getPosition() {
41 | return position;
42 | }
43 |
44 | /**
45 | * Gets the queue that this event is from
46 | * @return The QueueServer that the player is in that their position changed
47 | */
48 | public QueueServer getQueue() {
49 | return player.getQueueServer();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/PreConnectEvent.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import us.ajg0702.queue.api.players.QueuePlayer;
5 | import us.ajg0702.queue.api.server.AdaptedServer;
6 |
7 | /**
8 | * Called before AjQueue attempts to connect a player to an AdaptedServer (via Bungee or Velocity)
9 | * You can use setTargetServer to provide a custom AdaptedServer object for the player to connect to.
10 | * If canceled, the player will not be connected to the target server.
11 | * If you cancel this event, it is up to you to send a message telling the player why they were not connected.
12 | */
13 | @SuppressWarnings("unused")
14 | public class PreConnectEvent implements Event, Cancellable {
15 | private @NotNull AdaptedServer targetServer;
16 | private final @NotNull QueuePlayer queuePlayer;
17 |
18 | private boolean cancelled = false;
19 |
20 | public PreConnectEvent(@NotNull AdaptedServer targetServer, @NotNull QueuePlayer queuePlayer) {
21 | this.targetServer = targetServer;
22 | this.queuePlayer = queuePlayer;
23 | }
24 |
25 | /**
26 | * Set the target server to connect the player to. (Override default behavior with a custom server)
27 | *
28 | * @param targetServer the target server (AdaptedServer)
29 | */
30 | public void setTargetServer(@NotNull AdaptedServer targetServer) {
31 | this.targetServer = targetServer;
32 | }
33 |
34 | /**
35 | * @return The target server that the player is trying to connect to
36 | */
37 | public @NotNull AdaptedServer getTargetServer() {
38 | return targetServer;
39 | }
40 |
41 | /**
42 | * @return The player that is being connected to the server
43 | */
44 | public @NotNull QueuePlayer getPlayer() {
45 | return queuePlayer;
46 | }
47 |
48 | public boolean isCancelled() {
49 | return cancelled;
50 | }
51 |
52 | public void setCancelled(boolean cancelled) {
53 | this.cancelled = cancelled;
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/PreQueueEvent.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 |
6 | /**
7 | * Called after all checks are made, right before a player is actually added to the queue.
8 | * If canceled, the player will not be added to the queue.
9 | * If you cancel this event, it is up to you to send a message telling the player why they were not added to the queue.
10 | */
11 | public class PreQueueEvent implements Event, Cancellable {
12 | private final AdaptedPlayer player;
13 | private final QueueServer target;
14 |
15 | private boolean cancelled = false;
16 |
17 | public PreQueueEvent(AdaptedPlayer player, QueueServer target) {
18 | this.player = player;
19 | this.target = target;
20 | }
21 |
22 | /**
23 | * Gets the player that is joining the queue
24 | * @return
25 | */
26 | public AdaptedPlayer getPlayer() {
27 | return player;
28 | }
29 |
30 | /**
31 | * Gets the target QueueServer that the player is trying to queue for
32 | * @return The QueueServer that the player is trying to queue for
33 | */
34 | public QueueServer getTarget() {
35 | return target;
36 | }
37 |
38 | public boolean isCancelled() {
39 | return cancelled;
40 | }
41 |
42 | public void setCancelled(boolean cancelled) {
43 | this.cancelled = cancelled;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/PriorityCalculationEvent.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 |
5 | /**
6 | * Event that is called when priorities are calculated.
7 | * You can provide dynamic priorities for your players based on your own criteria
8 | * instead of just permissions
9 | *
10 | * Just listen to this event, and use the addPriority method to add a priority.
11 | * If it is higher than a player's other priorities, it will be used.
12 | *
13 | * If running ajQueue (not ajQueuePlus), then any number bigger than 0 will count as priority
14 | */
15 | public class PriorityCalculationEvent implements Event {
16 | private final AdaptedPlayer player;
17 | private int highestPriority;
18 |
19 | public PriorityCalculationEvent(AdaptedPlayer player, int highestPriority) {
20 | this.player = player;
21 | this.highestPriority = highestPriority;
22 | }
23 |
24 | /**
25 | * Gets the current highest priority
26 | * @return The highest priority number
27 | */
28 | public int getHighestPriority() {
29 | return highestPriority;
30 | }
31 |
32 | /**
33 | * Adds a priority. Does nothing if the priority is lower than the player already has
34 | * @param priority the priority to add
35 | */
36 | public void addPriority(int priority) {
37 | if(priority < highestPriority) return; // do nothing if this isnt going to change the highest priority
38 | highestPriority = priority;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/SuccessfulSendEvent.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.players.QueuePlayer;
5 | import us.ajg0702.queue.api.server.AdaptedServer;
6 |
7 | /**
8 | * Called after a player is successfully sent to a server.
9 | */
10 | public class SuccessfulSendEvent implements Event {
11 | private final QueuePlayer player;
12 | private final AdaptedServer server;
13 |
14 | public SuccessfulSendEvent(QueuePlayer player, AdaptedServer server) {
15 | this.player = player;
16 | this.server = server;
17 | }
18 |
19 | /**
20 | * Gets the player that was sent
21 | * @return the player that was sent
22 | */
23 | public AdaptedPlayer getPlayer() {
24 | return player.getPlayer();
25 | }
26 |
27 | /**
28 | * Gets the server that the player was sent to
29 | * @return The server that the player was sent to
30 | */
31 | public AdaptedServer getServer() {
32 | return server;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/events/utils/EventReceiver.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.events.utils;
2 |
3 | @FunctionalInterface
4 | public interface EventReceiver {
5 | void execute(E event);
6 | }
7 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/players/AdaptedPlayer.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.players;
2 |
3 | import net.kyori.adventure.audience.Audience;
4 | import net.kyori.adventure.text.Component;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.jetbrains.annotations.Nullable;
7 | import us.ajg0702.queue.api.server.AdaptedServer;
8 | import us.ajg0702.queue.api.util.Handle;
9 |
10 | import java.util.List;
11 | import java.util.UUID;
12 |
13 | /**
14 | * Represents a cross-platform player
15 | */
16 | @SuppressWarnings("unused")
17 | public interface AdaptedPlayer extends Handle, Audience {
18 |
19 | /**
20 | * Check if the plauer is currently connected
21 | * @return True if connected, false if not
22 | */
23 | @SuppressWarnings("BooleanMethodIsAlwaysInverted")
24 | boolean isConnected();
25 |
26 | /**
27 | * Send a player a message from a Component
28 | * @param message The message to send
29 | */
30 | void sendMessage(@NotNull Component message);
31 |
32 | /**
33 | * Sends an actionbar message to the player
34 | * @param message The message to send
35 | */
36 | void sendActionBar(@NotNull Component message);
37 |
38 | /**
39 | * Send a player a message from a string
40 | * Converted to Component internally
41 | * @param message The message to send
42 | */
43 | void sendMessage(String message);
44 |
45 | /**
46 | * Checks if the player has a certain permission
47 | * @param permission The permission to check
48 | * @return True if they have the permission, false if not
49 | */
50 | boolean hasPermission(String permission);
51 |
52 | /**
53 | * Gets the name of the server the player is currently on
54 | * @return The name of the server
55 | */
56 | String getServerName();
57 |
58 | /**
59 | * Gets the server that the player is currently connected to
60 | * @return The server that the player is currently connected to.
61 | */
62 | AdaptedServer getCurrentServer();
63 |
64 | /**
65 | * Gets the player's unique id (UUID)
66 | * @return The player's uuid
67 | */
68 | UUID getUniqueId();
69 |
70 | /**
71 | * Sends the player to a different server.
72 | * Does not use the queue.
73 | */
74 | void connect(AdaptedServer server);
75 |
76 | /**
77 | * Returns the version this player is running.
78 | * @return the version
79 | */
80 | int getProtocolVersion();
81 |
82 | /**
83 | * Gets the player's username
84 | * @return the player's username
85 | */
86 | @Nullable String getName();
87 |
88 | /**
89 | * Kick a player from the proxy
90 | * @param reason The reason to kick them with
91 | */
92 | void kick(Component reason);
93 |
94 | List getPermissions();
95 |
96 | default boolean equals(AdaptedPlayer other) {
97 | return this.getUniqueId().equals(other.getUniqueId());
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/players/QueuePlayer.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.players;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 | import us.ajg0702.queue.api.server.AdaptedServer;
6 |
7 | import javax.annotation.Nullable;
8 | import java.util.UUID;
9 |
10 | public interface QueuePlayer {
11 |
12 | /**
13 | * Returns the player's UUID
14 | * @return the player's UUID
15 | */
16 | UUID getUniqueId();
17 |
18 | /**
19 | * Gets the server or group this player is queued for
20 | * @return The QueueServer this player is queued for
21 | */
22 | QueueServer getQueueServer();
23 |
24 | /**
25 | * Gets the player's position in the queue
26 | * @return The player's position. 1 being 1st, 2 being 2nd, etc
27 | */
28 | default int getPosition() {
29 | return getQueueServer().getPosition(this);
30 | }
31 |
32 | /**
33 | * Get the player this represents.
34 | * Can be null because the player could not be online
35 | * @return The player if they are online, null otherwise
36 | */
37 | @Nullable AdaptedPlayer getPlayer();
38 |
39 | /**
40 | * Sets the player that this represents.
41 | * Will throw IllegalArgumentException if the player's uuid does not match the original.
42 | * @param player The player to add
43 | */
44 | void setPlayer(AdaptedPlayer player);
45 |
46 | /**
47 | * Gets the highest priority level the player has.
48 | * In free ajQueue, no priority is 0 and priority is 1
49 | * @return The priority level of this player for this server
50 | */
51 | int getPriority();
52 |
53 | /**
54 | * Gets if this player has priority
55 | */
56 | boolean hasPriority();
57 |
58 | /**
59 | * Gets the player's username
60 | * @return the player's username
61 | */
62 | String getName();
63 |
64 | /**
65 | * Returns the number of miliseconds since this player was online
66 | * @return The number of miliseconds since this player was online
67 | */
68 | long getTimeSinceOnline();
69 |
70 | /**
71 | * Gets the max number of seconds this player is allowed to be offline before getting removed from the queue.
72 | * @return the max number of seconds this player can be offline before being removed from the queue
73 | */
74 | int getMaxOfflineTime();
75 |
76 | /**
77 | * Gets the server that the player was in when they joined the queue
78 | * @return the server that the player was in when they joined the queue
79 | */
80 | AdaptedServer getInitialServer();
81 |
82 | /**
83 | * Attempts a connection to the provided AdaptedServer, calling PreConnectEvent before AdaptedPlayer.connect(...)
84 | */
85 | void connect(@NotNull AdaptedServer server);
86 | }
87 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/premium/Logic.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.premium;
2 |
3 | import us.ajg0702.queue.api.AjQueueAPI;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.players.QueuePlayer;
6 | import us.ajg0702.queue.api.queues.QueueServer;
7 | import us.ajg0702.queue.api.server.AdaptedServer;
8 | import us.ajg0702.utils.common.Config;
9 |
10 | @SuppressWarnings({"SameReturnValue", "unused"})
11 |
12 | public interface Logic {
13 | /**
14 | * Returns if the plugin is premium or not
15 | * @return True if premium, false if not
16 | */
17 | boolean isPremium();
18 |
19 | /**
20 | * The priority logic that is executed if the plugin is premium.
21 | *
22 | * @param queueServer The server/group name that is being queued for
23 | * @param player The player that is being queued
24 | * @param server The server/group name that is being queued for
25 | */
26 | QueuePlayer priorityLogic(QueueServer queueServer, AdaptedPlayer player, AdaptedServer server);
27 |
28 | /**
29 | * The logic for checking if a player has been disconnected for too long
30 | * @param player The player to check
31 | * @return true if the player has been disconnected for too long and should be removed from the queue
32 | */
33 | boolean playerDisconnectedTooLong(QueuePlayer player);
34 |
35 | /**
36 | * Gets the permissionGetter. Only available on ajQueuePlus
37 | * @return the permission getter
38 | */
39 | PermissionGetter getPermissionGetter();
40 |
41 | int getHighestPriority(QueueServer queueServer, AdaptedServer server, AdaptedPlayer player);
42 |
43 | static int getUnJoinablePriorities(QueueServer queueServer, AdaptedServer server, AdaptedPlayer player) {
44 | Config config = AjQueueAPI.getInstance().getConfig();
45 | int highest = 0;
46 |
47 | int whitelistedPriority = config.getInt("give-whitelisted-players-priority");
48 | int bypassPausedPriority = config.getInt("give-pausedbypass-players-priority");
49 | int fulljoinPriority = config.getInt("give-fulljoin-players-priority");
50 |
51 | if(whitelistedPriority > 0) {
52 | if(server.isWhitelisted() && server.getWhitelistedPlayers().contains(player.getUniqueId())) {
53 | highest = whitelistedPriority;
54 | }
55 | }
56 |
57 | if(bypassPausedPriority > 0) {
58 | if(queueServer.isPaused() && (player.hasPermission("ajqueue.bypasspaused"))) {
59 | highest = Math.max(highest, bypassPausedPriority);
60 | }
61 | }
62 |
63 | if(fulljoinPriority > 0) {
64 | boolean hasMakeRoom = player.hasPermission("ajqueue.make-room") && AjQueueAPI.getInstance().getConfig().getBoolean("enable-make-room-permission");
65 | if(
66 | (server.isFull() && (server.canJoinFull(player) || hasMakeRoom)) ||
67 | (queueServer.isManuallyFull() && (AdaptedServer.canJoinFull(player, queueServer.getName()) || hasMakeRoom))) {
68 | highest = Math.max(highest, fulljoinPriority);
69 | }
70 | }
71 |
72 |
73 | return highest;
74 | }
75 |
76 | boolean hasAnyBypass(AdaptedPlayer player, String server);
77 | }
78 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/premium/LogicGetter.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.premium;
2 |
3 | import us.ajg0702.queue.api.AliasManager;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.premium.Logic;
6 | import us.ajg0702.utils.common.Config;
7 |
8 | import java.util.List;
9 |
10 | @SuppressWarnings("unused")
11 | public interface LogicGetter {
12 | Logic constructLogic();
13 | AliasManager constructAliasManager(Config config);
14 | List getPermissions(AdaptedPlayer player);
15 | PermissionGetter getPermissionGetter();
16 | }
17 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/premium/PermissionGetter.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.premium;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.premium.PermissionHook;
5 |
6 | public interface PermissionGetter {
7 | PermissionHook getSelected();
8 |
9 | int getMaxOfflineTime(AdaptedPlayer player);
10 |
11 | int getPriority(AdaptedPlayer player);
12 |
13 | int getServerPriotity(String server, AdaptedPlayer player);
14 |
15 | boolean hasContextBypass(AdaptedPlayer player, String server);
16 |
17 | boolean hasUniqueFullBypass(AdaptedPlayer player, String server);
18 | }
19 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/premium/PermissionHook.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.premium;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 |
5 | import java.util.List;
6 |
7 | public interface PermissionHook {
8 | String getName();
9 | boolean canUse();
10 | List getPermissions(AdaptedPlayer player);
11 | }
12 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/premium/PermissionHookRegistry.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.premium;
2 |
3 | import java.util.Collection;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | public class PermissionHookRegistry {
8 | private final Map hooks = new HashMap<>();
9 |
10 | public void register(PermissionHook... permissionHooks) {
11 | for (PermissionHook hook : permissionHooks) {
12 | if(hooks.containsKey(hook.getName())) {
13 | throw new IllegalArgumentException("Hook " + hook.getName() + " is already registered!");
14 | }
15 | }
16 | for (PermissionHook hook : permissionHooks) {
17 | hooks.put(hook.getName(), hook);
18 | }
19 | }
20 |
21 | public Collection getRegisteredHooks() {
22 | return hooks.values();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/queueholders/QueueHolder.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.queueholders;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.players.QueuePlayer;
5 | import us.ajg0702.queue.api.queues.QueueServer;
6 |
7 | import java.util.List;
8 | import java.util.UUID;
9 |
10 | public abstract class QueueHolder {
11 |
12 | private final QueueServer queueServer;
13 |
14 | public QueueHolder(QueueServer queueServer) {
15 | this.queueServer = queueServer;
16 | }
17 |
18 | /**
19 | * Returns the identifier of this QueueHolder
20 | * Used by the server owner in order to tell ajQueue to use this QueueHolder
21 | * @return a string that is very unlikely to be re-used by another QueueHolder
22 | */
23 | public abstract String getIdentifier();
24 |
25 |
26 | /**
27 | * Adds a player to the end of the queue
28 | * NOTE: Do not manually call this! Use the QueueManager to add players to queues
29 | * @param player The QueuePlayer to add
30 | */
31 | public abstract void addPlayer(QueuePlayer player);
32 |
33 | /**
34 | * Adds a player to the specified position in the queue
35 | * NOTE: Do not manually call this! Use the QueueManager to add players to queues
36 | * @param player The QueuePlayer to add
37 | * @param position The position to add them to
38 | */
39 | public abstract void addPlayer(QueuePlayer player, int position);
40 |
41 | public void removePlayer(AdaptedPlayer player) {
42 | removePlayer(player.getUniqueId());
43 | }
44 |
45 | public void removePlayer(UUID uuid) {
46 | QueuePlayer player = findPlayer(uuid);
47 | if(player == null) return;
48 | removePlayer(player);
49 | }
50 |
51 | /**
52 | * Removes a player from the queue
53 | * @param player The player to remove
54 | */
55 | public abstract void removePlayer(QueuePlayer player);
56 |
57 | /**
58 | * Finds the player with this uuid in this queue and returns the representative QueuePlayer
59 | * @return The QueuePlayer representing the player, null if not found
60 | */
61 | public abstract QueuePlayer findPlayer(UUID uuid);
62 |
63 | /**
64 | * Finds the player with this username in this queue and returns the representative QueuePlayer
65 | * @return The QueuePlayer representing the player, null if not found
66 | */
67 | public abstract QueuePlayer findPlayer(String name);
68 |
69 | public QueuePlayer findPlayer(AdaptedPlayer player) {
70 | return findPlayer(player.getUniqueId());
71 | }
72 |
73 | /**
74 | * Returns the size of the queue
75 | * @return The number of players in the queue
76 | */
77 | public abstract int getQueueSize();
78 |
79 | public abstract int getPosition(QueuePlayer player);
80 |
81 | /**
82 | * Get all players that are in the queue
83 | * @return a list of players in the queue
84 | */
85 | public abstract List getAllPlayers();
86 | }
87 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/queueholders/QueueHolderRegistry.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.queueholders;
2 |
3 | import us.ajg0702.queue.api.AjQueueAPI;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 |
6 | import java.lang.reflect.InvocationTargetException;
7 | import java.util.Arrays;
8 | import java.util.Map;
9 | import java.util.concurrent.ConcurrentHashMap;
10 |
11 | public class QueueHolderRegistry {
12 |
13 | private Map> holders = new ConcurrentHashMap<>();
14 |
15 | /**
16 | * Register a QueueHolder that can be used
17 | * @param holder The QueueHolder to register
18 | */
19 | public void register(String identifier, Class extends QueueHolder> holder) {
20 | holders.put(identifier, holder);
21 | }
22 |
23 | public QueueHolder getQueueHolder(QueueServer queueServer) {
24 | String queueHolderName = AjQueueAPI.getInstance().getConfig().getString("queue-holder");
25 | QueueHolder queueHolder = getQueueHolder(queueHolderName, queueServer);
26 | if(queueHolder == null) {
27 | AjQueueAPI.getInstance().getLogger().warn("Invalid queue-holder '" + queueHolderName + "'! Using the default one");
28 | return getQueueHolder("default", queueServer);
29 | }
30 | return queueHolder;
31 | }
32 |
33 | public QueueHolder getQueueHolder(String identifier, QueueServer queueServer) {
34 | Class extends QueueHolder> holder = holders.get(identifier);
35 | if(holder == null) return null;
36 | try {
37 | return holder.getConstructor(QueueServer.class).newInstance(queueServer);
38 | } catch(NoSuchMethodException e) {
39 | throw new IllegalArgumentException("QueueHolder " + identifier + " is missing the required constructor!");
40 | } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
41 | throw new RuntimeException(e);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/queues/Balancer.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.queues;
2 |
3 | import org.jetbrains.annotations.Nullable;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.server.AdaptedServer;
6 |
7 | public interface Balancer {
8 | AdaptedServer getIdealServer(@Nullable AdaptedPlayer player);
9 | }
10 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/server/AdaptedServerInfo.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.server;
2 |
3 | import us.ajg0702.queue.api.util.Handle;
4 |
5 | public interface AdaptedServerInfo extends Handle {
6 |
7 | /**
8 | * Gets the name of the server
9 | * @return The name of the server
10 | */
11 | String getName();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/server/AdaptedServerPing.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.server;
2 |
3 | import net.kyori.adventure.text.Component;
4 | import us.ajg0702.queue.api.util.Handle;
5 |
6 | @SuppressWarnings("unused")
7 | public interface AdaptedServerPing extends Handle {
8 | /**
9 | * Gets the component of the description (aka MOTD)
10 | * @return A compoent of the description
11 | */
12 | Component getDescriptionComponent();
13 |
14 | /**
15 | * Gets the description (aka MOTD) stripped of any color or styling
16 | * @return The description, but no colors
17 | */
18 | String getPlainDescription();
19 |
20 | /**
21 | * Gets the number of players currently online
22 | * @return The number of players online
23 | */
24 | int getPlayerCount();
25 |
26 | /**
27 | * Gets the maximum number of players that can join.
28 | * @return The maximum number of players that can join
29 | */
30 | int getMaxPlayers();
31 |
32 | /**
33 | * Temporarly adds one player to the player count
34 | */
35 | void addPlayer();
36 |
37 | /**
38 | * Returns an epoch timestamp of when this ping was sent.
39 | * @return A long of an epoch timestamp
40 | */
41 | long getFetchedTime();
42 | }
43 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/spigot/AjQueueSpigotAPI.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.spigot;
2 |
3 | import java.util.UUID;
4 | import java.util.concurrent.Future;
5 |
6 | /**
7 | * An API that is usable from the spigot-side
8 | */
9 | public abstract class AjQueueSpigotAPI {
10 |
11 | public static AjQueueSpigotAPI INSTANCE;
12 |
13 | /**
14 | * Gets the instance of the ajQueue spigot API
15 | * @return the ajQueue API
16 | */
17 | @SuppressWarnings("unused")
18 | public static AjQueueSpigotAPI getInstance() {
19 | return INSTANCE;
20 | }
21 |
22 | public abstract Future isInQueue(UUID player);
23 |
24 | /**
25 | * Adds a player to a queue (bypassing any permission checks that would prevent it)
26 | * @param player The player to be added
27 | * @param queueName The server or group to add the player to
28 | * @return True if adding was successful, false if not.
29 | */
30 | public abstract Future addToQueue(UUID player, String queueName);
31 |
32 | /**
33 | * Emulate the player running the queue command for a certain server, including any permission checks
34 | * @param player The player to sudo the command for
35 | * @param queueName The queue to send the player to
36 | */
37 | public abstract void sudoQueue(UUID player, String queueName);
38 |
39 | /**
40 | * Gets the name of the queue that the player is in
41 | * @param player the player
42 | * @return the name of the queue that the player is in
43 | */
44 | public abstract Future> getQueueName(UUID player);
45 |
46 | /**
47 | * Gets the position of the player in their queue
48 | * @param player The player
49 | * @return The position of the player in their queue
50 | */
51 | public abstract Future> getPosition(UUID player);
52 |
53 | /**
54 | * Gets the total number of players who are in queue with the player
55 | * @param player The player
56 | * @return The number of player in the queue that the player is in.
57 | */
58 | public abstract Future> getTotalPositions(UUID player);
59 |
60 | /**
61 | * Gets the number of players in a specific queue
62 | * @param queueName The name of the queue
63 | * @return The number of players in that queue.
64 | */
65 | public abstract Future getPlayersInQueue(String queueName);
66 |
67 | /**
68 | * Gets the status string for the queue specified (e.g. full, restarting, etc)
69 | * This is the display status, which is meant to be shown to players (and is pulled from the messages file)
70 | * @param queueName the name of the queue
71 | * @return The status string for the queue you specified.
72 | */
73 | public abstract Future getServerStatusString(String queueName);
74 |
75 | /**
76 | * Gets the status string for the queue specified (e.g. full, restarting, etc)
77 | * This is the display status, which is meant to be shown to players (and is pulled from the messages file)
78 | * @param queueName the name of the queue
79 | * @param player the player to check with
80 | * @return The status string for the queue you specified.
81 | */
82 | public abstract Future getServerStatusString(String queueName, UUID player);
83 |
84 | /**
85 | * Gets the estimated time until the player is sent to the server
86 | * @param player The player to get
87 | * @return The estimated time until the player is sent to the server
88 | */
89 | public abstract Future> getEstimatedTime(UUID player);
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/spigot/MessagedResponse.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.spigot;
2 |
3 | public class MessagedResponse {
4 | private final T response;
5 | private final String none;
6 |
7 | public MessagedResponse(T response, String none) {
8 | this.response = response;
9 | this.none = none;
10 | }
11 |
12 | /**
13 | * Gets the response from the method.
14 | * @return The response. Null if there is a "none" message
15 | */
16 | public T getResponse() {
17 | return response;
18 | }
19 |
20 | /**
21 | * Gets the "none" message
22 | * @return The none message. null if there is a response.
23 | */
24 | public String getNone() {
25 | return none;
26 | }
27 |
28 | /**
29 | * Gets either the response (as a string) or the none message, whichever is available
30 | * @return A string
31 | */
32 | public String getEither() {
33 | if(response == null) return none;
34 | return String.valueOf(response);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/util/Handle.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.util;
2 |
3 | public interface Handle {
4 | Object getHandle();
5 | }
6 |
--------------------------------------------------------------------------------
/api/src/main/java/us/ajg0702/queue/api/util/QueueLogger.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.api.util;
2 |
3 | import us.ajg0702.utils.common.UtilsLogger;
4 |
5 | public interface QueueLogger extends UtilsLogger {
6 | void warn(String message);
7 | void warning(String message);
8 | void info(String message);
9 | void error(String message);
10 | void severe(String message);
11 |
12 | void warn(String message, Throwable t);
13 | void warning(String message, Throwable t);
14 | void info(String message, Throwable t);
15 | void error(String message, Throwable t);
16 | void severe(String message, Throwable t);
17 | }
18 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | java
3 | id("com.github.johnrengelman.shadow").version("6.1.0")
4 | `maven-publish`
5 | }
6 |
7 | repositories {
8 | maven { url = uri("https://repo.ajg0702.us/releases/") }
9 | maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
10 |
11 | mavenCentral()
12 | }
13 |
14 | allprojects {
15 | version = "2.7.0"
16 | group = "us.ajg0702"
17 |
18 | plugins.apply("java")
19 | java {
20 | sourceCompatibility = JavaVersion.VERSION_1_8
21 | }
22 |
23 | tasks.withType().configureEach {
24 | useJUnitPlatform()
25 |
26 | ignoreFailures = false
27 | failFast = true
28 | maxParallelForks = (Runtime.getRuntime().availableProcessors() - 1).takeIf { it > 0 } ?: 1
29 |
30 | reports.html.required.set(false)
31 | reports.junitXml.required.set(false)
32 | }
33 |
34 |
35 | }
36 |
37 |
38 | dependencies {
39 | testImplementation("junit:junit:4.12")
40 |
41 | implementation(project(":free"))
42 | }
43 |
44 |
45 | publishing {
46 | publications {
47 | create("mavenJava") {
48 | artifact(tasks["shadowJar"])
49 | }
50 | }
51 |
52 | repositories {
53 |
54 | val mavenUrl = "https://repo.ajg0702.us/releases"
55 |
56 | if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
57 | maven {
58 | url = uri(mavenUrl)
59 | name = "ajRepo"
60 |
61 | credentials {
62 | username = "plugins"
63 | password = System.getenv("REPO_TOKEN")
64 | }
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/common/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `java-library`
3 | `maven-publish`
4 | }
5 |
6 | group = "us.ajg0702.queue.common"
7 |
8 | repositories {
9 | //mavenLocal()
10 | maven { url = uri("https://repo.ajg0702.us/releases/") }
11 | mavenCentral()
12 | }
13 |
14 | dependencies {
15 | testImplementation("junit:junit:4.12")
16 |
17 | compileOnly("net.kyori:adventure-api:4.15.0")
18 | compileOnly("net.kyori:adventure-text-serializer-plain:4.15.0")
19 |
20 | compileOnly("com.google.guava:guava:30.1.1-jre")
21 | compileOnly("us.ajg0702:ajUtils:1.2.25")
22 |
23 | compileOnly("org.slf4j:slf4j-log4j12:1.7.29")
24 |
25 | compileOnly("org.spongepowered:configurate-yaml:4.0.0")
26 |
27 | implementation(project(":api"))
28 | }
29 |
30 | publishing {
31 | publications {
32 | create("mavenJava") {
33 | artifact(tasks["jar"])
34 | }
35 | }
36 |
37 | repositories {
38 |
39 | val mavenUrl = "https://repo.ajg0702.us/releases"
40 |
41 | if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
42 | maven {
43 | url = uri(mavenUrl)
44 | name = "ajRepo"
45 |
46 | credentials {
47 | username = "plugins"
48 | password = System.getenv("REPO_TOKEN")
49 | }
50 | }
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/BaseCommand.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import us.ajg0702.queue.api.commands.IBaseCommand;
6 | import us.ajg0702.queue.api.commands.ICommandSender;
7 | import us.ajg0702.queue.api.commands.ISubCommand;
8 | import us.ajg0702.utils.common.Messages;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | import java.util.Locale;
13 |
14 | public class BaseCommand implements IBaseCommand {
15 | @Override
16 | public String getName() {
17 | return null;
18 | }
19 |
20 | @Override
21 | public ImmutableList getAliases() {
22 | return null;
23 | }
24 |
25 | @SuppressWarnings("unused")
26 | @Override
27 | public ImmutableList getSubCommands() {
28 | return null;
29 | }
30 |
31 | @Override
32 | public String getPermission() {
33 | return null;
34 | }
35 |
36 | @Override
37 | public boolean showInTabComplete() {
38 | return true;
39 | }
40 |
41 | @Override
42 | public Messages getMessages() {
43 | return null;
44 | }
45 |
46 | @SuppressWarnings("unused")
47 | @Override
48 | public void addSubCommand(ISubCommand subCommand) {
49 |
50 | }
51 |
52 | @Override
53 | public void execute(ICommandSender sender, String[] args) {
54 | sender.sendMessage(Component.text("Unimplemented command"));
55 | }
56 |
57 | @SuppressWarnings("BooleanMethodIsAlwaysInverted")
58 | public boolean checkPermission(ICommandSender sender) {
59 | if(getPermission() != null && !sender.hasPermission(getPermission())) {
60 | sender.sendMessage(getMessages().getComponent("noperm"));
61 | return false;
62 | }
63 | return true;
64 | }
65 |
66 | @Override
67 | public List autoComplete(ICommandSender sender, String[] args) {
68 | return null;
69 | }
70 |
71 | public List filterCompletion(List in, String current) {
72 | List out = new ArrayList<>(in);
73 | out.removeIf(t -> !t.toLowerCase(Locale.ROOT).contains(current.toLowerCase(Locale.ROOT)));
74 | return out;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/SubCommand.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands;
2 |
3 | import us.ajg0702.queue.api.commands.ISubCommand;
4 |
5 | public class SubCommand extends BaseCommand implements ISubCommand {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/SlashServer/SlashServerCommand.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.SlashServer;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.commands.IBaseCommand;
5 | import us.ajg0702.queue.api.commands.ICommandSender;
6 | import us.ajg0702.queue.commands.BaseCommand;
7 | import us.ajg0702.queue.common.QueueMain;
8 | import us.ajg0702.utils.common.Messages;
9 |
10 | import java.util.Collections;
11 | import java.util.List;
12 |
13 | public class SlashServerCommand extends BaseCommand {
14 |
15 | final QueueMain main;
16 | final String server;
17 | final String command;
18 |
19 | private IBaseCommand moveCommand;
20 |
21 |
22 | public SlashServerCommand(QueueMain main, String server) {
23 | this.main = main;
24 | this.server = server;
25 | this.command = server;
26 | }
27 | public SlashServerCommand(QueueMain main, String command, String server) {
28 | this.main = main;
29 | this.server = server;
30 | this.command = command;
31 | }
32 |
33 | @Override
34 | public String getName() {
35 | return command;
36 | }
37 |
38 | @Override
39 | public ImmutableList getAliases() {
40 | return ImmutableList.of();
41 | }
42 |
43 | @Override
44 | public String getPermission() {
45 | return main.getConfig().getBoolean("require-permission") ? "ajqueue.queue."+server : null;
46 | }
47 |
48 | @Override
49 | public Messages getMessages() {
50 | return main.getMessages();
51 | }
52 |
53 | @Override
54 | public void execute(ICommandSender sender, String[] args) {
55 | if(!sender.isPlayer()) {
56 | sender.sendMessage(getMessages().getComponent("errors.player-only"));
57 | return;
58 | }
59 | if(moveCommand == null) {
60 | moveCommand = main.getPlatformMethods().getCommands().get(0);
61 | }
62 | moveCommand.execute(sender, new String[]{server});
63 | }
64 |
65 | @Override
66 | public List autoComplete(ICommandSender sender, String[] args) {
67 | return Collections.emptyList();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/listqueues/ListCommand.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.listqueues;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import us.ajg0702.queue.api.commands.ICommandSender;
6 | import us.ajg0702.queue.api.commands.ISubCommand;
7 | import us.ajg0702.queue.api.players.AdaptedPlayer;
8 | import us.ajg0702.queue.api.queues.QueueServer;
9 | import us.ajg0702.queue.commands.BaseCommand;
10 | import us.ajg0702.queue.common.QueueMain;
11 | import us.ajg0702.utils.common.Messages;
12 |
13 | import java.util.Collections;
14 | import java.util.List;
15 |
16 | public class ListCommand extends BaseCommand {
17 |
18 | private final QueueMain main;
19 |
20 | public ListCommand(QueueMain main) {
21 | this.main = main;
22 | }
23 |
24 | @Override
25 | public String getName() {
26 | return "listqueues";
27 | }
28 |
29 | @Override
30 | public ImmutableList getAliases() {
31 | return ImmutableList.of("listq");
32 | }
33 |
34 | @Override
35 | public ImmutableList getSubCommands() {
36 | return ImmutableList.builder().build();
37 | }
38 |
39 | @Override
40 | public String getPermission() {
41 | return "ajqueue.listqueues";
42 | }
43 |
44 | @Override
45 | public Messages getMessages() {
46 | return main.getMessages();
47 | }
48 |
49 | @Override
50 | public void execute(ICommandSender sender, String[] args) {
51 | if(!checkPermission(sender)) return;
52 |
53 |
54 | AdaptedPlayer spp = null;
55 | if(sender.isPlayer()) {
56 | spp = main.getPlatformMethods().senderToPlayer(sender);
57 | }
58 |
59 |
60 | Component m = main.getMessages().getComponent("commands.listqueues.header");
61 | for(QueueServer s : main.getQueueManager().getServers()) {
62 | String color = "&a";
63 | if(!s.isOnline()) {
64 | color = "&c";
65 | } else if(!s.isJoinable(spp)) {
66 | color = "&e";
67 | }
68 |
69 | m = m.append(Component.text("\n"));
70 | m = m.append(main.getMessages().getComponent("commands.listqueues.format",
71 | "COLOR:" + Messages.color(color),
72 | "NAME:" + s.getAlias(),
73 | "COUNT:" + s.getQueue().size(),
74 | "STATUS:" + Messages.color(main.getMessages().getRawString("placeholders.status."+s.getStatus(spp)))
75 | ));
76 | }
77 | sender.sendMessage(m);
78 | }
79 |
80 | @Override
81 | public List autoComplete(ICommandSender sender, String[] args) {
82 | return Collections.emptyList();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/Kick.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.commands.ICommandSender;
5 | import us.ajg0702.queue.api.players.QueuePlayer;
6 | import us.ajg0702.queue.api.queues.QueueServer;
7 | import us.ajg0702.queue.commands.SubCommand;
8 | import us.ajg0702.queue.common.QueueMain;
9 | import us.ajg0702.utils.common.Messages;
10 |
11 | import java.util.ArrayList;
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class Kick extends SubCommand {
16 |
17 | final QueueMain main;
18 | public Kick(QueueMain main) {
19 | this.main = main;
20 | }
21 |
22 | @Override
23 | public String getName() {
24 | return "kick";
25 | }
26 |
27 | @Override
28 | public ImmutableList getAliases() {
29 | return ImmutableList.of();
30 | }
31 |
32 | @Override
33 | public String getPermission() {
34 | return "ajqueue.manage.kick";
35 | }
36 |
37 | @Override
38 | public Messages getMessages() {
39 | return main.getMessages();
40 | }
41 |
42 | @Override
43 | public void execute(ICommandSender sender, String[] args) {
44 | if(!checkPermission(sender)) return;
45 |
46 | if(args.length < 1) {
47 | sender.sendMessage(getMessages().getComponent("commands.kick.usage"));
48 | return;
49 | }
50 |
51 | List kickPlayers;
52 |
53 | if(args.length == 1) {
54 | kickPlayers = main.getQueueManager().findPlayerInQueuesByName(args[0]);
55 | } else {
56 | QueueServer queue = main.getQueueManager().findServer(args[1]);
57 | if(queue == null) {
58 | sender.sendMessage(getMessages().getComponent("commands.kick.unknown-server", "QUEUE:"+args[1]));
59 | return;
60 | }
61 | kickPlayers = Collections.singletonList(queue.findPlayer(args[0]));
62 | }
63 |
64 | if(kickPlayers.isEmpty()) {
65 | sender.sendMessage(getMessages().getComponent("commands.kick.no-player", "PLAYER:"+args[0]));
66 | return;
67 | }
68 |
69 | for(QueuePlayer player : kickPlayers) {
70 | player.getQueueServer().removePlayer(player);
71 | }
72 |
73 | sender.sendMessage(getMessages().getComponent(
74 | "commands.kick.success",
75 | "PLAYER:"+args[0],
76 | "NUM:"+kickPlayers.size(),
77 | "s:"+ (kickPlayers.size() == 1 ? "" : "s")
78 | ));
79 | }
80 |
81 | @Override
82 | public List autoComplete(ICommandSender sender, String[] args) {
83 | if(args.length == 1) {
84 | return filterCompletion(main.getPlatformMethods().getPlayerNames(false), args[0]);
85 | }
86 | if(args.length == 2) {
87 | return filterCompletion(main.getQueueManager().getServerNames(), args[1]);
88 | }
89 | return new ArrayList<>();
90 | }
91 | }
92 |
93 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/KickAll.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.commands.ICommandSender;
5 | import us.ajg0702.queue.api.players.QueuePlayer;
6 | import us.ajg0702.queue.api.queues.QueueServer;
7 | import us.ajg0702.queue.commands.SubCommand;
8 | import us.ajg0702.queue.common.QueueMain;
9 | import us.ajg0702.utils.common.Messages;
10 |
11 | import java.util.ArrayList;
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class KickAll extends SubCommand {
16 |
17 | final QueueMain main;
18 | public KickAll(QueueMain main) {
19 | this.main = main;
20 | }
21 |
22 | @Override
23 | public String getName() {
24 | return "kickall";
25 | }
26 |
27 | @Override
28 | public ImmutableList getAliases() {
29 | return ImmutableList.of();
30 | }
31 |
32 | @Override
33 | public String getPermission() {
34 | return "ajqueue.manage.kickall";
35 | }
36 |
37 | @Override
38 | public Messages getMessages() {
39 | return main.getMessages();
40 | }
41 |
42 | @Override
43 | public void execute(ICommandSender sender, String[] args) {
44 | if(!checkPermission(sender)) return;
45 |
46 | if(args.length < 1) {
47 | sender.sendMessage(getMessages().getComponent("commands.kickall.usage"));
48 | return;
49 | }
50 |
51 | QueueServer server = main.getQueueManager().findServer(args[0]);
52 | List kickPlayers = new ArrayList<>(server.getQueue());
53 |
54 | for(QueuePlayer player : kickPlayers) {
55 | player.getQueueServer().removePlayer(player);
56 | }
57 |
58 | sender.sendMessage(getMessages().getComponent(
59 | "commands.kickall.success",
60 | "SERVER:"+args[0],
61 | "NUM:"+kickPlayers.size(),
62 | "s:"+ (kickPlayers.size() == 1 ? "" : "s")
63 | ));
64 | }
65 |
66 | @Override
67 | public List autoComplete(ICommandSender sender, String[] args) {
68 | if(args.length == 1) {
69 | return filterCompletion(main.getQueueManager().getServerNames(), args[0]);
70 | }
71 | return Collections.emptyList();
72 | }
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/Pause.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.commands.ICommandSender;
5 | import us.ajg0702.queue.api.queues.QueueServer;
6 | import us.ajg0702.queue.commands.SubCommand;
7 | import us.ajg0702.queue.common.QueueMain;
8 | import us.ajg0702.utils.common.Messages;
9 |
10 | import java.util.ArrayList;
11 | import java.util.Arrays;
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class Pause extends SubCommand {
16 |
17 | final QueueMain main;
18 | public Pause(QueueMain main) {
19 | this.main = main;
20 | }
21 |
22 | @Override
23 | public String getName() {
24 | return "pause";
25 | }
26 |
27 | @Override
28 | public ImmutableList getAliases() {
29 | return ImmutableList.of();
30 | }
31 |
32 | @Override
33 | public String getPermission() {
34 | return "ajqueue.manage.pause";
35 | }
36 |
37 | @Override
38 | public Messages getMessages() {
39 | return main.getMessages();
40 | }
41 |
42 | @Override
43 | public void execute(ICommandSender sender, String[] args) {
44 | if(!checkPermission(sender)) return;
45 |
46 | if(args.length < 1) {
47 | sender.sendMessage(getMessages().getComponent("commands.pause.more-args"));
48 | return;
49 | }
50 |
51 | List servers;
52 | QueueServer queueServer = main.getQueueManager().findServer(args[0]);
53 | if(queueServer == null && !args[0].equalsIgnoreCase("all")) {
54 | sender.sendMessage(getMessages().getComponent("commands.pause.no-server", "SERVER:"+args[0]));
55 | return;
56 | } else if(queueServer == null && args[0].equalsIgnoreCase("all")) {
57 | servers = main.getQueueManager().getServers();
58 | } else {
59 | servers = Collections.singletonList(queueServer);
60 | }
61 |
62 | for(QueueServer server : servers) {
63 | if(args.length == 1) {
64 | server.setPaused(!server.isPaused());
65 | } else {
66 | server.setPaused(args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true"));
67 | }
68 | sender.sendMessage(getMessages().getComponent("commands.pause.success",
69 | "SERVER:"+server.getName(),
70 | "PAUSED:"+getMessages().getString("commands.pause.paused."+server.isPaused())
71 | ));
72 | }
73 | }
74 |
75 | @Override
76 | public List autoComplete(ICommandSender sender, String[] args) {
77 | if(args.length == 1) {
78 | List servers = new ArrayList<>(main.getQueueManager().getServerNames());
79 | servers.add("all");
80 | return filterCompletion(servers, args[0]);
81 | }
82 | if(args.length == 2) {
83 | return filterCompletion(Arrays.asList("on", "off", "true", "false"), args[1]);
84 | }
85 | return Collections.emptyList();
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/PauseQueueServer.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.commands.ICommandSender;
5 | import us.ajg0702.queue.api.commands.ISubCommand;
6 | import us.ajg0702.queue.api.players.AdaptedPlayer;
7 | import us.ajg0702.queue.commands.SubCommand;
8 | import us.ajg0702.queue.common.QueueMain;
9 | import us.ajg0702.queue.common.utils.Debug;
10 | import us.ajg0702.utils.common.Messages;
11 |
12 | import java.util.ArrayList;
13 | import java.util.Arrays;
14 | import java.util.Collections;
15 | import java.util.List;
16 | import java.util.concurrent.CopyOnWriteArrayList;
17 |
18 | public class PauseQueueServer extends SubCommand {
19 |
20 | public static final List pausedPlayers = new CopyOnWriteArrayList<>();
21 |
22 | final QueueMain main;
23 | public PauseQueueServer(QueueMain main) {
24 | this.main = main;
25 | }
26 |
27 | @Override
28 | public String getName() {
29 | return "pausequeueserver";
30 | }
31 |
32 | @Override
33 | public ImmutableList getAliases() {
34 | return ImmutableList.of("pauseqs");
35 | }
36 |
37 | @Override
38 | public ImmutableList getSubCommands() {
39 | return ImmutableList.of();
40 | }
41 |
42 | @Override
43 | public String getPermission() {
44 | return "ajqueue.manage.pausequeueserver";
45 | }
46 |
47 | @Override
48 | public boolean showInTabComplete() {
49 | return true;
50 | }
51 |
52 | @Override
53 | public Messages getMessages() {
54 | return main.getMessages();
55 | }
56 |
57 | @Override
58 | public void execute(ICommandSender sender, String[] args) {
59 | if(!checkPermission(sender)) return;
60 |
61 | if(!sender.isPlayer()) {
62 | sender.sendMessage(getMessages().getComponent("errors.player-only"));
63 | return;
64 | }
65 |
66 | AdaptedPlayer player = main.getPlatformMethods().getPlayer(sender.getUniqueId());
67 | if(pausedPlayers.contains(player)) {
68 | pausedPlayers.remove(player);
69 | sender.sendMessage(getMessages().getComponent("commands.pausequeueserver.unpaused"));
70 | return;
71 | }
72 |
73 | pausedPlayers.add(player);
74 | sender.sendMessage(getMessages().getComponent("commands.pausequeueserver.paused"));
75 | }
76 |
77 | @Override
78 | public List autoComplete(ICommandSender sender, String[] args) {
79 | return Collections.emptyList();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/QueueList.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import net.kyori.adventure.text.PatternReplacementResult;
6 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
7 | import us.ajg0702.queue.api.commands.ICommandSender;
8 | import us.ajg0702.queue.api.players.QueuePlayer;
9 | import us.ajg0702.queue.api.queues.QueueServer;
10 | import us.ajg0702.queue.commands.SubCommand;
11 | import us.ajg0702.queue.common.QueueMain;
12 | import us.ajg0702.utils.common.Messages;
13 |
14 | import java.util.Collections;
15 | import java.util.List;
16 | import java.util.regex.Pattern;
17 |
18 | public class QueueList extends SubCommand {
19 |
20 | final QueueMain main;
21 | public QueueList(QueueMain main) {
22 | this.main = main;
23 | }
24 |
25 | @Override
26 | public String getName() {
27 | return "list";
28 | }
29 |
30 | @Override
31 | public ImmutableList getAliases() {
32 | return ImmutableList.of();
33 | }
34 |
35 | @Override
36 | public String getPermission() {
37 | return "ajqueue.manage.list";
38 | }
39 |
40 | @Override
41 | public Messages getMessages() {
42 | return main.getMessages();
43 | }
44 |
45 | @Override
46 | public void execute(ICommandSender sender, String[] args) {
47 | if(!checkPermission(sender)) return;
48 | int total = 0;
49 | for(QueueServer server : main.getQueueManager().getServers()) {
50 |
51 | Component msg = getMessages().getComponent("list.format",
52 | "SERVER:"+server.getName()
53 | );
54 | Component playerList = Component.empty();
55 | List players = server.getQueue();
56 | boolean none = true;
57 | for(QueuePlayer p : players) {
58 | playerList = playerList.append(getMessages().getComponent("list.playerlist",
59 | "NAME:" + p.getName()
60 | ));
61 | none = false;
62 | }
63 | if(none) {
64 | playerList = playerList.append(getMessages().getComponent("list.none"));
65 | playerList = playerList.append(Component.text(", "));
66 | }
67 | Component finalPlayerList = playerList;
68 | msg = msg.replaceText(b -> b.match(Pattern.compile("\\{LIST}")).replacement(finalPlayerList));
69 | char[] commaCountString = PlainTextComponentSerializer.plainText().serialize(msg).toCharArray();
70 | int commas = 0;
71 | for(Character fChar : commaCountString) {
72 | if(fChar == ',') commas++;
73 | }
74 |
75 | int finalCommas = commas;
76 | msg = msg.replaceText(b -> b.match(",(?!.*,)").replacement("").condition((r, c, re) -> {
77 | if(c == finalCommas) {
78 | return PatternReplacementResult.REPLACE;
79 | }
80 | return PatternReplacementResult.CONTINUE;
81 | }));
82 | total += players.size();
83 | msg = msg.replaceText(b -> b.match(Pattern.compile("\\{COUNT}")).replacement(players.size()+""));
84 | sender.sendMessage(msg);
85 | }
86 | sender.sendMessage(getMessages().getComponent("list.total", "TOTAL:"+total));
87 | }
88 |
89 | @Override
90 | public java.util.List autoComplete(ICommandSender sender, String[] args) {
91 | return Collections.emptyList();
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/Reload.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import net.kyori.adventure.text.format.NamedTextColor;
6 | import org.spongepowered.configurate.ConfigurateException;
7 | import us.ajg0702.queue.api.commands.ICommandSender;
8 | import us.ajg0702.queue.commands.SubCommand;
9 | import us.ajg0702.queue.common.QueueMain;
10 | import us.ajg0702.utils.common.Messages;
11 |
12 | import java.util.Collections;
13 | import java.util.List;
14 |
15 | public class Reload extends SubCommand {
16 |
17 | final QueueMain main;
18 | public Reload(QueueMain main) {
19 | this.main = main;
20 | }
21 |
22 | @Override
23 | public String getName() {
24 | return "reload";
25 | }
26 |
27 | @Override
28 | public ImmutableList getAliases() {
29 | return ImmutableList.of();
30 | }
31 |
32 | @Override
33 | public String getPermission() {
34 | return "ajqueue.manage.reload";
35 | }
36 |
37 | @Override
38 | public Messages getMessages() {
39 | return main.getMessages();
40 | }
41 |
42 | @Override
43 | public void execute(ICommandSender sender, String[] args) {
44 | if(!checkPermission(sender)) return;
45 | main.getMessages().reload();
46 | try {
47 | main.getConfig().reload();
48 | } catch (ConfigurateException e) {
49 | sender.sendMessage(Component.text("An error occurred while reloading. Check the console").color(NamedTextColor.RED));
50 | e.printStackTrace();
51 | return;
52 | }
53 | main.setTimeBetweenPlayers();
54 | main.getTaskManager().rescheduleTasks();
55 | main.getQueueManager().reloadServers();
56 | main.getMessages().reload();
57 | main.getSlashServerManager().reload();
58 |
59 | main.getUpdater().setEnabled(main.getConfig().getBoolean("enable-updater"));
60 |
61 | sender.sendMessage(getMessages().getComponent("commands.reload"));
62 | }
63 |
64 | @Override
65 | public List autoComplete(ICommandSender sender, String[] args) {
66 | return Collections.emptyList();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/Update.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.commands.ICommandSender;
5 | import us.ajg0702.queue.commands.SubCommand;
6 | import us.ajg0702.queue.common.QueueMain;
7 | import us.ajg0702.utils.common.Messages;
8 | import us.ajg0702.utils.common.Updater;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | public class Update extends SubCommand {
14 |
15 | final QueueMain main;
16 | public Update(QueueMain main) {
17 | this.main = main;
18 | }
19 |
20 | @Override
21 | public String getName() {
22 | return "update";
23 | }
24 |
25 | @Override
26 | public ImmutableList getAliases() {
27 | return ImmutableList.of();
28 | }
29 |
30 | @Override
31 | public String getPermission() {
32 | return "ajqueue.manage.update";
33 | }
34 |
35 | @Override
36 | public Messages getMessages() {
37 | return main.getMessages();
38 | }
39 |
40 | @Override
41 | public void execute(ICommandSender sender, String[] args) {
42 | if(!checkPermission(sender)) return;
43 | Updater updater = main.getUpdater();
44 | if(updater.isAlreadyDownloaded()) {
45 | sender.sendMessage(getMessages().getComponent("updater.already-downloaded"));
46 | return;
47 | }
48 | if(!updater.isUpdateAvailable()) {
49 | sender.sendMessage(getMessages().getComponent("updater.no-update"));
50 | return;
51 | }
52 | if(updater.downloadUpdate()) {
53 | sender.sendMessage(getMessages().getComponent("updater.success"));
54 | } else {
55 | sender.sendMessage(getMessages().getComponent("updater.fail"));
56 | }
57 | }
58 |
59 | @Override
60 | public List autoComplete(ICommandSender sender, String[] args) {
61 | return new ArrayList<>();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/debug/ISP.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage.debug;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import us.ajg0702.queue.api.commands.ICommandSender;
6 | import us.ajg0702.queue.commands.SubCommand;
7 | import us.ajg0702.queue.common.QueueMain;
8 | import us.ajg0702.utils.common.Messages;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | public class ISP extends SubCommand {
14 |
15 | final QueueMain main;
16 | public ISP(QueueMain main) {
17 | this.main = main;
18 | }
19 |
20 | @Override
21 | public String getName() {
22 | return "isp";
23 | }
24 |
25 | @Override
26 | public ImmutableList getAliases() {
27 | return ImmutableList.of();
28 | }
29 |
30 | @Override
31 | public boolean showInTabComplete() {
32 | return false;
33 | }
34 |
35 | @Override
36 | public String getPermission() {
37 | return null;
38 | }
39 |
40 | @Override
41 | public Messages getMessages() {
42 | return main.getMessages();
43 | }
44 |
45 | @Override
46 | public void execute(ICommandSender sender, String[] args) {
47 | if(!checkPermission(sender)) return;
48 | sender.sendMessage(Component.text(main.getLogic().isPremium()));
49 | }
50 |
51 | @Override
52 | public List autoComplete(ICommandSender sender, String[] args) {
53 | return new ArrayList<>();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/debug/PermissionList.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage.debug;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import net.kyori.adventure.text.format.NamedTextColor;
6 | import us.ajg0702.queue.api.commands.ICommandSender;
7 | import us.ajg0702.queue.commands.SubCommand;
8 | import us.ajg0702.queue.common.QueueMain;
9 | import us.ajg0702.utils.common.Messages;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 | import java.util.Locale;
14 |
15 | public class PermissionList extends SubCommand {
16 |
17 | final QueueMain main;
18 | public PermissionList(QueueMain main) {
19 | this.main = main;
20 | }
21 |
22 | @Override
23 | public String getName() {
24 | return "permissionlist";
25 | }
26 |
27 | @Override
28 | public ImmutableList getAliases() {
29 | return ImmutableList.of("permissionslist", "listpermissions", "listpermission");
30 | }
31 |
32 | @Override
33 | public boolean showInTabComplete() {
34 | return false;
35 | }
36 |
37 | @Override
38 | public String getPermission() {
39 | return null;
40 | }
41 |
42 | @Override
43 | public Messages getMessages() {
44 | return main.getMessages();
45 | }
46 |
47 | @Override
48 | public void execute(ICommandSender sender, String[] args) {
49 | if(!checkPermission(sender)) return;
50 | if(!sender.isPlayer()) {
51 | sender.sendMessage(
52 | Component.text("You need to run this as a player with priority!")
53 | .color(NamedTextColor.RED)
54 | );
55 | return;
56 | }
57 |
58 | List permissions = main.getLogicGetter()
59 | .getPermissions(main.getPlatformMethods().senderToPlayer(sender));
60 | if(permissions == null) {
61 | sender.sendMessage(Component.text("no permission handler"));
62 | return;
63 | }
64 |
65 | permissions.forEach(s -> {
66 | if(!s.toLowerCase(Locale.ROOT).contains("ajqueue")) return;
67 | sender.sendMessage(Component.text(s));
68 | });
69 | sender.sendMessage(
70 | Component.text(
71 | "Using: "+main.getLogicGetter().getPermissionGetter().getSelected().getName())
72 | .color(NamedTextColor.GOLD)
73 | );
74 | }
75 |
76 | @Override
77 | public List autoComplete(ICommandSender sender, String[] args) {
78 | return new ArrayList<>();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/debug/Protocol.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage.debug;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import us.ajg0702.queue.api.commands.ICommandSender;
6 | import us.ajg0702.queue.commands.SubCommand;
7 | import us.ajg0702.queue.common.QueueMain;
8 | import us.ajg0702.utils.common.Messages;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | public class Protocol extends SubCommand {
14 |
15 | final QueueMain main;
16 | public Protocol(QueueMain main) {
17 | this.main = main;
18 | }
19 |
20 | @Override
21 | public String getName() {
22 | return "protocol";
23 | }
24 |
25 | @Override
26 | public ImmutableList getAliases() {
27 | return ImmutableList.of();
28 | }
29 |
30 | @Override
31 | public boolean showInTabComplete() {
32 | return false;
33 | }
34 |
35 | @Override
36 | public String getPermission() {
37 | return null;
38 | }
39 |
40 | @Override
41 | public Messages getMessages() {
42 | return main.getMessages();
43 | }
44 |
45 | @Override
46 | public void execute(ICommandSender sender, String[] args) {
47 | if(!checkPermission(sender)) return;
48 | if(!sender.isPlayer()) return;
49 | sender.sendMessage(Component.text(main.getPlatformMethods().senderToPlayer(sender).getProtocolVersion()));
50 | }
51 |
52 | @Override
53 | public List autoComplete(ICommandSender sender, String[] args) {
54 | return new ArrayList<>();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/debug/Tasks.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage.debug;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import us.ajg0702.queue.api.commands.ICommandSender;
6 | import us.ajg0702.queue.commands.SubCommand;
7 | import us.ajg0702.queue.common.QueueMain;
8 | import us.ajg0702.utils.common.Messages;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | public class Tasks extends SubCommand {
14 |
15 | final QueueMain main;
16 | public Tasks(QueueMain main) {
17 | this.main = main;
18 | }
19 |
20 | @Override
21 | public String getName() {
22 | return "tasks";
23 | }
24 |
25 | @Override
26 | public ImmutableList getAliases() {
27 | return ImmutableList.of();
28 | }
29 |
30 | @Override
31 | public String getPermission() {
32 | return "ajqueue.manage.tasks";
33 | }
34 |
35 | @Override
36 | public boolean showInTabComplete() {
37 | return false;
38 | }
39 |
40 | @Override
41 | public Messages getMessages() {
42 | return main.getMessages();
43 | }
44 |
45 | @Override
46 | public void execute(ICommandSender sender, String[] args) {
47 | if(!checkPermission(sender)) return;
48 | sender.sendMessage(Component.text(main.getTaskManager().taskStatus()));
49 | }
50 |
51 | @Override
52 | public List autoComplete(ICommandSender sender, String[] args) {
53 | return new ArrayList<>();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/debug/Version.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage.debug;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import net.kyori.adventure.text.Component;
5 | import us.ajg0702.queue.api.commands.ICommandSender;
6 | import us.ajg0702.queue.commands.SubCommand;
7 | import us.ajg0702.queue.common.QueueMain;
8 | import us.ajg0702.utils.common.Messages;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | public class Version extends SubCommand {
14 |
15 | final QueueMain main;
16 | final Component message;
17 | public Version(QueueMain main) {
18 | this.main = main;
19 | message = main.getMessages().toComponent(
20 | "&a" + (main.isPremium() ? "ajQueuePlus" : "ajQueue") + " v&f" + main.getPlatformMethods().getPluginVersion() + " &aby &fajgeiss0702"
21 | );
22 | }
23 |
24 | @Override
25 | public String getName() {
26 | return "version";
27 | }
28 |
29 | @Override
30 | public ImmutableList getAliases() {
31 | return ImmutableList.of();
32 | }
33 |
34 | @Override
35 | public String getPermission() {
36 | return null;
37 | }
38 |
39 | @Override
40 | public Messages getMessages() {
41 | return main.getMessages();
42 | }
43 |
44 | @Override
45 | public void execute(ICommandSender sender, String[] args) {
46 | if(!checkPermission(sender)) return;
47 | sender.sendMessage(message);
48 | }
49 |
50 | @Override
51 | public List autoComplete(ICommandSender sender, String[] args) {
52 | return new ArrayList<>();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/manage/debug/Whitelist.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.manage.debug;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.commands.ICommandSender;
5 | import us.ajg0702.queue.api.queues.QueueServer;
6 | import us.ajg0702.queue.api.server.AdaptedServer;
7 | import us.ajg0702.queue.commands.SubCommand;
8 | import us.ajg0702.queue.common.QueueMain;
9 | import us.ajg0702.utils.common.Messages;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class Whitelist extends SubCommand {
15 | final QueueMain main;
16 | public Whitelist(QueueMain main) {
17 | this.main = main;
18 | }
19 |
20 | @Override
21 | public String getName() {
22 | return "whitelist";
23 | }
24 |
25 | @Override
26 | public ImmutableList getAliases() {
27 | return ImmutableList.of();
28 | }
29 |
30 | @Override
31 | public String getPermission() {
32 | return null;
33 | }
34 |
35 | @Override
36 | public boolean showInTabComplete() {
37 | return false;
38 | }
39 |
40 | @Override
41 | public Messages getMessages() {
42 | return main.getMessages();
43 | }
44 |
45 | @Override
46 | public void execute(ICommandSender sender, String[] args) {
47 | if(!checkPermission(sender)) return;
48 | if(args.length < 1) {
49 | sender.sendMessage(main.getMessages().toComponent("Not enough args!"));
50 | return;
51 | }
52 | AdaptedServer server = main.getPlatformMethods().getServer(args[0]);
53 | if(server == null) {
54 | sender.sendMessage(main.getMessages().toComponent("Server not found"));
55 | return;
56 | }
57 | sender.sendMessage(main.getMessages().toComponent("Yours: "+ main.getPlatformMethods().senderToPlayer(sender).getUniqueId().toString()));
58 | server.getWhitelistedPlayers().forEach(uuid -> sender.sendMessage(main.getMessages().toComponent(""+uuid)));
59 | }
60 |
61 | @Override
62 | public List autoComplete(ICommandSender sender, String[] args) {
63 | return new ArrayList<>();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/commands/commands/send/SendAlias.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.commands.commands.send;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.commands.IBaseCommand;
5 | import us.ajg0702.queue.api.commands.ICommandSender;
6 | import us.ajg0702.queue.commands.BaseCommand;
7 | import us.ajg0702.queue.common.QueueMain;
8 | import us.ajg0702.utils.common.Messages;
9 |
10 | import java.util.Collections;
11 | import java.util.List;
12 |
13 | public class SendAlias extends BaseCommand {
14 |
15 | final QueueMain main;
16 |
17 | private final IBaseCommand sendCommand;
18 |
19 |
20 | public SendAlias(QueueMain main) {
21 | this.main = main;
22 | sendCommand = main.getPlatformMethods().getCommands().get(3).getSubCommands().get(9);
23 | }
24 |
25 | @Override
26 | public String getName() {
27 | return "send";
28 | }
29 |
30 | @Override
31 | public ImmutableList getAliases() {
32 | return ImmutableList.of();
33 | }
34 |
35 | @Override
36 | public String getPermission() {
37 | return sendCommand.getPermission();
38 | }
39 |
40 | @Override
41 | public Messages getMessages() {
42 | return main.getMessages();
43 | }
44 |
45 | @Override
46 | public void execute(ICommandSender sender, String[] args) {
47 | if(!checkPermission(sender)) return;
48 | sendCommand.execute(sender, args);
49 | }
50 |
51 | @Override
52 | public List autoComplete(ICommandSender sender, String[] args) {
53 | if(!checkPermission(sender)) return Collections.emptyList();
54 | return sendCommand.autoComplete(sender, args);
55 | }
56 |
57 | }
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/DefaultQueueHolder.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import us.ajg0702.queue.api.players.QueuePlayer;
5 | import us.ajg0702.queue.api.queueholders.QueueHolder;
6 | import us.ajg0702.queue.api.queues.QueueServer;
7 |
8 | import java.util.List;
9 | import java.util.UUID;
10 | import java.util.concurrent.CopyOnWriteArrayList;
11 |
12 | public class DefaultQueueHolder extends QueueHolder {
13 |
14 | List queue = new CopyOnWriteArrayList<>();
15 |
16 | public DefaultQueueHolder(QueueServer queueServer) {
17 | super(queueServer);
18 | }
19 |
20 | @Override
21 | public String getIdentifier() {
22 | return "default";
23 | }
24 |
25 | @Override
26 | public void addPlayer(QueuePlayer player) {
27 | queue.add(player);
28 | }
29 |
30 | @Override
31 | public void addPlayer(QueuePlayer player, int position) {
32 | queue.add(position, player);
33 | }
34 |
35 | @Override
36 | public void removePlayer(QueuePlayer player) {
37 | queue.remove(player);
38 | }
39 |
40 | @Override
41 | public QueuePlayer findPlayer(UUID uuid) {
42 | for(QueuePlayer queuePlayer : queue) {
43 | if(queuePlayer.getUniqueId().toString().equals(uuid.toString())) {
44 | return queuePlayer;
45 | }
46 | }
47 | return null;
48 | }
49 |
50 | @Override
51 | public QueuePlayer findPlayer(String name) {
52 | for(QueuePlayer queuePlayer : queue) {
53 | if(queuePlayer.getName().equalsIgnoreCase(name)) {
54 | return queuePlayer;
55 | }
56 | }
57 | return null;
58 | }
59 |
60 | @Override
61 | public int getQueueSize() {
62 | return queue.size();
63 | }
64 |
65 | @Override
66 | public int getPosition(QueuePlayer player) {
67 | return queue.indexOf(player) + 1;
68 | }
69 |
70 | @Override
71 | public List getAllPlayers() {
72 | return ImmutableList.copyOf(queue);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/ProtocolNameManagerImpl.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common;
2 |
3 | import us.ajg0702.queue.api.PlatformMethods;
4 | import us.ajg0702.queue.api.ProtocolNameManager;
5 | import us.ajg0702.utils.common.Config;
6 | import us.ajg0702.utils.common.Messages;
7 |
8 | import java.util.HashMap;
9 | import java.util.List;
10 |
11 | public class ProtocolNameManagerImpl implements ProtocolNameManager {
12 |
13 | private final Messages messages;
14 | private final PlatformMethods platformMethods;
15 | public ProtocolNameManagerImpl(Messages messages, PlatformMethods platformMethods) {
16 | this.messages = messages;
17 | this.platformMethods = platformMethods;
18 | }
19 |
20 | @Override
21 | public String getProtocolName(int protocol) {
22 | String setName = messages.getRawString("protocol-names." + protocol);
23 |
24 | if(setName == null) return platformMethods.getProtocolName(protocol);
25 |
26 | return setName;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/ServerTimeManagerImpl.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import us.ajg0702.queue.api.ServerTimeManager;
5 | import us.ajg0702.queue.api.players.AdaptedPlayer;
6 |
7 | import java.util.Map;
8 | import java.util.UUID;
9 | import java.util.concurrent.ConcurrentHashMap;
10 |
11 | public class ServerTimeManagerImpl implements ServerTimeManager {
12 |
13 | final Map serverSwitches = new ConcurrentHashMap<>();
14 |
15 |
16 | @Override
17 | public long getLastServerChange(AdaptedPlayer player) {
18 | if(player == null) return -1;
19 | Long r = serverSwitches.get(player.getUniqueId());
20 | return r == null ? -1 : r;
21 | }
22 |
23 | public void playerChanged(AdaptedPlayer player) {
24 | if(player == null) return;
25 | serverSwitches.put(player.getUniqueId(), System.currentTimeMillis());
26 | }
27 |
28 | public void removePlayer(AdaptedPlayer player) {
29 | if(player == null) return;
30 | serverSwitches.remove(player.getUniqueId());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/SlashServerManager.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common;
2 |
3 | import us.ajg0702.queue.api.Implementation;
4 | import us.ajg0702.queue.commands.commands.SlashServer.SlashServerCommand;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | public class SlashServerManager {
10 |
11 | private final List serverCommands = new ArrayList<>();
12 |
13 | private final QueueMain main;
14 | private final Implementation implementation;
15 | public SlashServerManager(QueueMain main) {
16 | this.main = main;
17 | this.implementation = this.main.getImplementation();
18 | reload();
19 | }
20 | public void reload() {
21 | serverCommands.forEach(implementation::unregisterCommand);
22 | serverCommands.clear();
23 |
24 | List slashServerServers = main.getConfig().getStringList("slash-servers");
25 | for(String rawServer : slashServerServers) {
26 | if(rawServer.contains(":") && main.isPremium()) {
27 | String[] parts = rawServer.split(":");
28 | String command = parts[0];
29 | String server = parts[1];
30 | SlashServerCommand slashServerCommand = new SlashServerCommand(main, command, server);
31 | serverCommands.add(slashServerCommand);
32 | implementation.registerCommand(slashServerCommand);
33 | } else {
34 | SlashServerCommand command = new SlashServerCommand(main, rawServer);
35 | serverCommands.add(command);
36 | implementation.registerCommand(command);
37 | }
38 |
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/CommunicationManager.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication;
2 |
3 | import us.ajg0702.queue.api.communication.ComResponse;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.common.QueueMain;
6 | import us.ajg0702.queue.common.communication.handlers.*;
7 | import us.ajg0702.queue.common.utils.MapBuilder;
8 |
9 | import java.io.ByteArrayInputStream;
10 | import java.io.DataInputStream;
11 | import java.io.IOException;
12 | import java.util.Map;
13 |
14 | public class CommunicationManager {
15 | private final QueueMain main;
16 | Map handlers;
17 |
18 | public CommunicationManager(QueueMain main) {
19 | this.main = main;
20 |
21 | handlers = new MapBuilder<>(
22 | "ack", new AckHandler(main),
23 |
24 | "queue", new QueueHandler(main),
25 | "massqueue", new MassQueueHandler(main),
26 | "leavequeue", new LeaveQueueHandler(main),
27 |
28 | "queuename", new QueueNameHandler(main),
29 | "position", new PositionHandler(main),
30 | "positionof", new PositionOfHandler(main),
31 | "estimated_time", new EstimatedTimeHandler(main),
32 | "inqueue", new InQueueHandler(main),
33 | "queuedfor", new QueuedForHandler(main),
34 | "status", new StatusHandler(main),
35 | "playerstatus", new PlayerStatusHandler(main),
36 | "serverqueue", new ServerQueueHandler(main)
37 | );
38 | }
39 |
40 | public void handle(AdaptedPlayer receivingPlayer, byte[] data) throws IOException {
41 | DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
42 | String subChannel = in.readUTF();
43 |
44 | MessageHandler handler = handlers.get(subChannel);
45 |
46 | if(handler == null) {
47 | main.getLogger().warn("Invalid sub-channel " + subChannel);
48 | return;
49 | }
50 |
51 | ComResponse response = handler.handleMessage(receivingPlayer, in.readUTF());
52 |
53 | if(response == null) return;
54 | if(!receivingPlayer.isConnected()) return;
55 |
56 | main.getPlatformMethods().sendPluginMessage(
57 | receivingPlayer,
58 | s(response.getFrom()),
59 | s(response.getIdentifier()),
60 | s(response.getResponse()),
61 | s(response.getNoneMessage())
62 | );
63 | }
64 |
65 | private String s(String s) {
66 | return s + "";
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/MessageHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication;
2 |
3 | import us.ajg0702.queue.api.communication.ComResponse;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.common.QueueMain;
6 |
7 | public abstract class MessageHandler {
8 | protected final QueueMain main;
9 |
10 | public MessageHandler(QueueMain main) {
11 | this.main = main;
12 | }
13 |
14 | public abstract ComResponse handleMessage(AdaptedPlayer player, String data);
15 | }
16 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/AckHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.common.QueueMain;
5 | import us.ajg0702.queue.api.communication.ComResponse;
6 | import us.ajg0702.queue.common.communication.MessageHandler;
7 |
8 | public class AckHandler extends MessageHandler {
9 | public AckHandler(QueueMain main) {
10 | super(main);
11 | }
12 |
13 | @Override
14 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
15 | return ComResponse
16 | .from("ack")
17 | .with("yes, im here");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/EstimatedTimeHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.players.QueuePlayer;
5 | import us.ajg0702.queue.api.queues.QueueServer;
6 | import us.ajg0702.queue.common.QueueMain;
7 | import us.ajg0702.queue.api.communication.ComResponse;
8 | import us.ajg0702.queue.common.communication.MessageHandler;
9 | import us.ajg0702.utils.common.TimeUtils;
10 |
11 | public class EstimatedTimeHandler extends MessageHandler {
12 |
13 | public EstimatedTimeHandler(QueueMain main) {
14 | super(main);
15 | }
16 |
17 | @Override
18 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
19 | QueueServer server = main.getQueueManager().getSingleServer(player);
20 |
21 | int time;
22 | String timeString;
23 | if(server != null) {
24 | QueuePlayer queuePlayer = server.findPlayer(player);
25 | time = (int) Math.round(queuePlayer.getPosition() * main.getTimeBetweenPlayers());
26 | timeString = TimeUtils.timeString(
27 | time,
28 | main.getMessages().getString("format.time.mins"),
29 | main.getMessages().getString("format.time.secs")
30 | );
31 | } else {
32 | timeString = main.getMessages().getString("placeholders.estimated_time.none");
33 | }
34 | return ComResponse
35 | .from("estimated_time")
36 | .id(player.getUniqueId())
37 | .with(timeString);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/InQueueHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 | import us.ajg0702.queue.common.QueueMain;
6 | import us.ajg0702.queue.api.communication.ComResponse;
7 | import us.ajg0702.queue.common.communication.MessageHandler;
8 |
9 | public class InQueueHandler extends MessageHandler {
10 |
11 | public InQueueHandler(QueueMain main) {
12 | super(main);
13 | }
14 |
15 | @Override
16 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
17 | QueueServer server = main.getQueueManager().getSingleServer(player);
18 | return ComResponse
19 | .from("inqueue")
20 | .id(player.getUniqueId())
21 | .with(server != null);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/LeaveQueueHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.commands.IBaseCommand;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.commands.commands.PlayerSender;
6 | import us.ajg0702.queue.common.QueueMain;
7 | import us.ajg0702.queue.api.communication.ComResponse;
8 | import us.ajg0702.queue.common.communication.MessageHandler;
9 |
10 | public class LeaveQueueHandler extends MessageHandler {
11 | IBaseCommand leaveCommand;
12 |
13 | public LeaveQueueHandler(QueueMain main) {
14 | super(main);
15 | leaveCommand = main.getPlatformMethods().getCommands().get(1);
16 | }
17 |
18 | @Override
19 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
20 | String[] args = new String[1];
21 | args[0] = data;
22 | leaveCommand.execute(new PlayerSender(player), args);
23 | return null;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/MassQueueHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.commands.IBaseCommand;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.commands.commands.PlayerSender;
6 | import us.ajg0702.queue.common.QueueMain;
7 | import us.ajg0702.queue.api.communication.ComResponse;
8 | import us.ajg0702.queue.common.communication.MessageHandler;
9 |
10 | public class MassQueueHandler extends MessageHandler {
11 | private final IBaseCommand moveCommand;
12 |
13 | public MassQueueHandler(QueueMain main) {
14 | super(main);
15 | moveCommand = main.getPlatformMethods().getCommands().get(0);
16 | }
17 |
18 | @Override
19 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
20 | String[] parts = data.split(",");
21 | for(String part : parts) {
22 | String[] playerParts = part.split(":");
23 | if(playerParts.length < 2) continue;
24 | String playerName = playerParts[0];
25 | String targetServer = playerParts[1];
26 | AdaptedPlayer p = main.getPlatformMethods().getPlayer(playerName);
27 | String[] args = new String[1];
28 | args[0] = targetServer;
29 | moveCommand.execute(new PlayerSender(p), args);
30 | }
31 | return null;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/PlayerStatusHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.communication.ComResponse;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.queues.QueueServer;
6 | import us.ajg0702.queue.common.QueueMain;
7 | import us.ajg0702.queue.common.communication.MessageHandler;
8 |
9 | public class PlayerStatusHandler extends MessageHandler {
10 | public PlayerStatusHandler(QueueMain main) {
11 | super(main);
12 | }
13 |
14 | @Override
15 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
16 | QueueServer server = main.getQueueManager().findServer(data);
17 | if(server == null) {
18 | return ComResponse
19 | .from("playerstatus")
20 | .id(player.getUniqueId() + data)
21 | .with("invalid_server");
22 | }
23 | if(!player.isConnected() || player.getServerName() == null) return null;
24 | return ComResponse
25 | .from("playerstatus")
26 | .id(player.getUniqueId() + data)
27 | .with(
28 | main.getMessages().getRawString(
29 | "placeholders.status." + server.getStatus(player)
30 | )
31 | );
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/PositionHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 | import us.ajg0702.queue.common.QueueMain;
6 | import us.ajg0702.queue.api.communication.ComResponse;
7 | import us.ajg0702.queue.common.communication.MessageHandler;
8 |
9 | public class PositionHandler extends MessageHandler {
10 |
11 | public PositionHandler(QueueMain main) {
12 | super(main);
13 | }
14 |
15 | @Override
16 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
17 | QueueServer server = main.getQueueManager().getSingleServer(player);
18 | Integer pos = null;
19 | String noneMessage = null;
20 | if(server != null) {
21 | pos = server.getQueue().indexOf(server.findPlayer(player)) + 1;
22 | } else {
23 | noneMessage = main.getMessages().getString("placeholders.position.none");
24 | }
25 | return ComResponse
26 | .from("position")
27 | .id(player.getUniqueId())
28 | .with(pos)
29 | .noneMessage(noneMessage);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/PositionOfHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 | import us.ajg0702.queue.common.QueueMain;
6 | import us.ajg0702.queue.api.communication.ComResponse;
7 | import us.ajg0702.queue.common.communication.MessageHandler;
8 |
9 | public class PositionOfHandler extends MessageHandler {
10 |
11 |
12 | public PositionOfHandler(QueueMain main) {
13 | super(main);
14 | }
15 |
16 | @Override
17 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
18 | QueueServer server = main.getQueueManager().getSingleServer(player);
19 | Integer size = null;
20 | String noneMessage = null;
21 | if(server != null) {
22 | size = server.getQueue().size();
23 | } else {
24 | noneMessage = main.getMessages().getString("placeholders.position.none");
25 | }
26 | return ComResponse
27 | .from("positionof")
28 | .id(player.getUniqueId())
29 | .with(size)
30 | .noneMessage(noneMessage);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/QueueHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.commands.IBaseCommand;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.commands.commands.PlayerSender;
6 | import us.ajg0702.queue.common.QueueMain;
7 | import us.ajg0702.queue.api.communication.ComResponse;
8 | import us.ajg0702.queue.common.communication.MessageHandler;
9 |
10 | /**
11 | * Actually SudoQueue. Confusing naming is due to legacy support and will be removed next major revision.
12 | */
13 | public class QueueHandler extends MessageHandler {
14 | private final IBaseCommand moveCommand;
15 |
16 | public QueueHandler(QueueMain main) {
17 | super(main);
18 | moveCommand = main.getPlatformMethods().getCommands().get(0);
19 | }
20 |
21 | @Override
22 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
23 | String[] args = new String[1];
24 | args[0] = data;
25 | moveCommand.execute(new PlayerSender(player), args);
26 | return null;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/QueueNameHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 | import us.ajg0702.queue.common.QueueMain;
6 | import us.ajg0702.queue.api.communication.ComResponse;
7 | import us.ajg0702.queue.common.communication.MessageHandler;
8 |
9 | public class QueueNameHandler extends MessageHandler {
10 |
11 | public QueueNameHandler(QueueMain main) {
12 | super(main);
13 | }
14 |
15 | @Override
16 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
17 | QueueServer server = main.getQueueManager().getSingleServer(player);
18 | String name = null;
19 | String none = null;
20 | if(server != null) {
21 | name = server.getAlias();
22 | } else {
23 | none = main.getMessages().getString("placeholders.position.none");
24 | }
25 | return ComResponse
26 | .from("queuename")
27 | .id(player.getUniqueId())
28 | .with(name)
29 | .noneMessage(none);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/QueuedForHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 | import us.ajg0702.queue.common.QueueMain;
6 | import us.ajg0702.queue.api.communication.ComResponse;
7 | import us.ajg0702.queue.common.communication.MessageHandler;
8 |
9 | public class QueuedForHandler extends MessageHandler {
10 |
11 | public QueuedForHandler(QueueMain main) {
12 | super(main);
13 | }
14 |
15 | @Override
16 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
17 | QueueServer server = main.getQueueManager().findServer(data);
18 | if(server == null) {
19 | return ComResponse
20 | .from("queuedfor")
21 | .id(data)
22 | .with("invalid_server");
23 | }
24 | return ComResponse
25 | .from("queuedfor")
26 | .id(data)
27 | .with(server.getQueue().size());
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/ServerQueueHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.communication.ComResponse;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.queues.QueueServer;
6 | import us.ajg0702.queue.common.QueueMain;
7 | import us.ajg0702.queue.common.communication.MessageHandler;
8 |
9 | public class ServerQueueHandler extends MessageHandler {
10 | public ServerQueueHandler(QueueMain main) {
11 | super(main);
12 | }
13 |
14 | @Override
15 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
16 | QueueServer server = main.getQueueManager().findServer(data);
17 | if(server == null) {
18 | return ComResponse
19 | .from("serverqueue")
20 | .id(player.getUniqueId())
21 | .with("invalid_server");
22 | }
23 | return ComResponse
24 | .from("serverqueue")
25 | .id(player.getUniqueId())
26 | .with(main.getQueueManager().addToQueue(player, server));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/communication/handlers/StatusHandler.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.communication.handlers;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.api.queues.QueueServer;
5 | import us.ajg0702.queue.common.QueueMain;
6 | import us.ajg0702.queue.api.communication.ComResponse;
7 | import us.ajg0702.queue.common.communication.MessageHandler;
8 |
9 | public class StatusHandler extends MessageHandler {
10 | public StatusHandler(QueueMain main) {
11 | super(main);
12 | }
13 |
14 | @Override
15 | public ComResponse handleMessage(AdaptedPlayer player, String data) {
16 | QueueServer server = main.getQueueManager().findServer(data);
17 | if(server == null) {
18 | return ComResponse
19 | .from("status")
20 | .id(data)
21 | .with("invalid_server");
22 | }
23 | return ComResponse
24 | .from("status")
25 | .id(data)
26 | .with(
27 | main.getMessages().getRawString(
28 | "placeholders.status." + server.getStatus()
29 | )
30 | );
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/queues/balancers/DefaultBalancer.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.queues.balancers;
2 |
3 | import org.jetbrains.annotations.Nullable;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.queues.Balancer;
6 | import us.ajg0702.queue.api.queues.QueueServer;
7 | import us.ajg0702.queue.api.server.AdaptedServer;
8 | import us.ajg0702.queue.common.QueueMain;
9 | import us.ajg0702.utils.common.GenUtils;
10 |
11 | import java.util.List;
12 |
13 | public class DefaultBalancer implements Balancer {
14 |
15 | private final QueueServer server;
16 | private final QueueMain main;
17 | public DefaultBalancer(QueueServer server, QueueMain main) {
18 | this.server = server;
19 | this.main = main;
20 | }
21 |
22 | @Override
23 | public AdaptedServer getIdealServer(@Nullable AdaptedPlayer player) {
24 | AdaptedServer alreadyConnected;
25 | if(player == null) {
26 | alreadyConnected = null;
27 | } else {
28 | alreadyConnected = player.getCurrentServer();
29 | }
30 | List servers = server.getServers();
31 | AdaptedServer selected = null;
32 | int selectednum = 0;
33 | if(servers.size() == 1) {
34 | selected = servers.get(0);
35 | } else {
36 | for(AdaptedServer sv : servers) {
37 | if(!sv.isOnline()) continue;
38 | if(sv.equals(alreadyConnected)) continue;
39 | int online = sv.getPlayerCount();
40 | if(selected == null) {
41 | selected = sv;
42 | selectednum = online;
43 | continue;
44 | }
45 | if(!selected.isJoinable(player) && sv.isJoinable(player)) {
46 | selected = sv;
47 | selectednum = online;
48 | continue;
49 | }
50 | if(selectednum > online && sv.isJoinable(player)) {
51 | selected = sv;
52 | selectednum = online;
53 | }
54 | }
55 | }
56 | if(selected == null && servers.size() > 0) {
57 | selected = servers.get(0);
58 | }
59 | if(selected == null) {
60 | main.getLogger().warning("Unable to find ideal server, using random server from group.");
61 | int r = GenUtils.randomInt(0, server.getServers().size()-1);
62 | selected = server.getServers().get(r);
63 | }
64 | return selected;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/queues/balancers/FirstBalancer.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.queues.balancers;
2 |
3 | import org.jetbrains.annotations.Nullable;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.queues.Balancer;
6 | import us.ajg0702.queue.api.queues.QueueServer;
7 | import us.ajg0702.queue.api.server.AdaptedServer;
8 | import us.ajg0702.queue.common.QueueMain;
9 |
10 | public class FirstBalancer implements Balancer {
11 |
12 | private final QueueServer server;
13 | private final QueueMain main;
14 | public FirstBalancer(QueueServer server, QueueMain main) {
15 | this.server = server;
16 | this.main = main;
17 | }
18 |
19 | @Override
20 | public AdaptedServer getIdealServer(@Nullable AdaptedPlayer player) {
21 | AdaptedServer alreadyConnected;
22 | if(player == null) {
23 | alreadyConnected = null;
24 | } else {
25 | alreadyConnected = player.getCurrentServer();
26 | }
27 | for (AdaptedServer sv : server.getServers()) {
28 | if(!sv.isOnline()) continue;
29 | if(sv.equals(alreadyConnected)) continue;
30 | if(!sv.isJoinable(player)) continue;
31 | return sv;
32 | }
33 |
34 | // If all servers are unavailable, just select the first one
35 | return server.getServers().get(0);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/queues/balancers/MinigameBalancer.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.queues.balancers;
2 |
3 | import org.jetbrains.annotations.Nullable;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.api.queues.Balancer;
6 | import us.ajg0702.queue.api.queues.QueueServer;
7 | import us.ajg0702.queue.api.server.AdaptedServer;
8 | import us.ajg0702.queue.common.QueueMain;
9 |
10 | import java.util.ArrayList;
11 | import java.util.Comparator;
12 | import java.util.List;
13 |
14 | public class MinigameBalancer implements Balancer {
15 |
16 | private final QueueServer server;
17 | private final QueueMain main;
18 | public MinigameBalancer(QueueServer server, QueueMain main) {
19 | this.server = server;
20 | this.main = main;
21 | }
22 |
23 | @Override
24 | public AdaptedServer getIdealServer(@Nullable AdaptedPlayer player) {
25 | AdaptedServer alreadyConnected;
26 | if(player == null) {
27 | alreadyConnected = null;
28 | } else {
29 | alreadyConnected = player.getCurrentServer();
30 | }
31 | List servers = server.getServers();
32 | if(servers.size() == 1) {
33 | return servers.get(0);
34 | } else {
35 |
36 | List svs = new ArrayList<>(servers);
37 | svs.sort(Comparator.comparingInt(o -> ((AdaptedServer)o).getPlayerCount()).reversed());
38 |
39 | for(AdaptedServer si : svs) {
40 | if(!si.isOnline()) continue;
41 | if(si.equals(alreadyConnected)) continue;
42 | int online = si.getPlayerCount();
43 | int max = si.getMaxPlayers();
44 | if(online < max && si.isJoinable(player)) {
45 | return si;
46 | }
47 | }
48 | return svs.get(svs.size()-1);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/utils/Debug.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.utils;
2 |
3 | import us.ajg0702.queue.api.AjQueueAPI;
4 |
5 | public class Debug {
6 | public static void info(String message) {
7 | AjQueueAPI api = AjQueueAPI.getInstance();
8 | if(!api.getConfig().getBoolean("debug")) return;
9 | api.getLogger().info("[debug] "+message);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/utils/LogConverter.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.utils;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import us.ajg0702.queue.api.util.QueueLogger;
5 |
6 | import java.util.logging.LogRecord;
7 | import java.util.logging.Logger;
8 |
9 | public class LogConverter extends Logger {
10 | private final QueueLogger logger;
11 | public LogConverter(QueueLogger logger) {
12 | super("ajqueue-convert", null);
13 | this.logger = logger;
14 | }
15 |
16 | @Override
17 | public void log(@NotNull LogRecord logRecord) {
18 | String message = logRecord.getMessage();
19 | switch(logRecord.getLevel().getName()) {
20 | case "OFF":
21 | break;
22 | case "SEVERE":
23 | logger.error(message);
24 | break;
25 | case "WARNING":
26 | logger.warn(message);
27 | break;
28 | case "INFO":
29 | default:
30 | logger.info(message);
31 | break;
32 | }
33 | }
34 |
35 | @SuppressWarnings({"unused", "SameReturnValue"})
36 | public String logName() {
37 | return "%%__USER__%%";
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/utils/MapBuilder.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.utils;
2 |
3 | import java.util.LinkedHashMap;
4 |
5 | public class MapBuilder extends LinkedHashMap {
6 | @SuppressWarnings("unchecked")
7 | public MapBuilder(Object... entries) {
8 | for (int i = 0; i < entries.length; i += 2) {
9 | put((K) entries[i], (V) entries[i+1]);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/common/utils/QueueThreadFactory.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.common.utils;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 |
5 | import java.util.concurrent.ThreadFactory;
6 | import java.util.concurrent.atomic.AtomicInteger;
7 |
8 | public class QueueThreadFactory implements ThreadFactory {
9 | private final String name;
10 | private final AtomicInteger i = new AtomicInteger(0);
11 |
12 | public QueueThreadFactory(String name) {
13 | this.name = name;
14 | }
15 |
16 | @Override
17 | public Thread newThread(@NotNull Runnable runnable) {
18 | return new Thread(runnable, "AJQUEUE-" + name + "-" + i.incrementAndGet());
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/logic/FreeAliasManager.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic;
2 |
3 | import us.ajg0702.queue.api.AliasManager;
4 | import us.ajg0702.utils.common.Config;
5 |
6 | public class FreeAliasManager implements AliasManager {
7 | @SuppressWarnings("unused")
8 | final Config config;
9 | public FreeAliasManager(Config config) {
10 | this.config = config;
11 | }
12 |
13 | @Override
14 | public String getAlias(String server) {
15 | return server;
16 | }
17 |
18 | @Override
19 | public String getServer(String alias) {
20 | return alias;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/logic/FreeLogic.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic;
2 |
3 | import us.ajg0702.queue.api.events.PriorityCalculationEvent;
4 | import us.ajg0702.queue.api.premium.Logic;
5 | import us.ajg0702.queue.api.players.AdaptedPlayer;
6 | import us.ajg0702.queue.api.players.QueuePlayer;
7 | import us.ajg0702.queue.api.premium.PermissionGetter;
8 | import us.ajg0702.queue.api.queues.QueueServer;
9 | import us.ajg0702.queue.api.server.AdaptedServer;
10 | import us.ajg0702.queue.common.QueueMain;
11 |
12 | public class FreeLogic implements Logic {
13 | @Override
14 | public boolean isPremium() {
15 | return false;
16 | }
17 |
18 | @Override
19 | public QueuePlayer priorityLogic(QueueServer queueServer, AdaptedPlayer player, AdaptedServer server) {
20 | return null;
21 | }
22 |
23 | @Override
24 | public boolean playerDisconnectedTooLong(QueuePlayer player) {
25 | return player.getTimeSinceOnline() > player.getMaxOfflineTime()*1000L;
26 | }
27 |
28 | @Override
29 | public PermissionGetter getPermissionGetter() {
30 | return null;
31 | }
32 |
33 | @Override
34 | public int getHighestPriority(QueueServer queueServer, AdaptedServer server, AdaptedPlayer player) {
35 | int existingPriority = player.hasPermission("ajqueue.priority") ? 1 : 0;
36 |
37 | PriorityCalculationEvent event = new PriorityCalculationEvent(player, existingPriority);
38 |
39 | QueueMain.getInstance().call(event);
40 |
41 | return event.getHighestPriority() > 0 ? 1 : 0;
42 | }
43 |
44 | @Override
45 | public boolean hasAnyBypass(AdaptedPlayer player, String server) {
46 | return false;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/common/src/main/java/us/ajg0702/queue/logic/LogicGetterImpl.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic;
2 |
3 | import us.ajg0702.queue.api.AliasManager;
4 | import us.ajg0702.queue.api.premium.Logic;
5 | import us.ajg0702.queue.api.players.AdaptedPlayer;
6 | import us.ajg0702.queue.api.premium.LogicGetter;
7 | import us.ajg0702.queue.api.premium.PermissionGetter;
8 | import us.ajg0702.utils.common.Config;
9 |
10 | import java.util.List;
11 |
12 | public class LogicGetterImpl implements LogicGetter {
13 |
14 | @Override
15 | public Logic constructLogic() {
16 | return new FreeLogic();
17 | }
18 |
19 | @Override
20 | public AliasManager constructAliasManager(Config config) {
21 | return new FreeAliasManager(config);
22 | }
23 |
24 | @Override
25 | public List getPermissions(AdaptedPlayer player) {
26 | return null;
27 | }
28 |
29 | @Override
30 | public PermissionGetter getPermissionGetter() {
31 | return null;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/free/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `java-library`
3 | id("com.github.johnrengelman.shadow")
4 | `maven-publish`
5 | }
6 |
7 | group = "us.ajg0702.queue"
8 |
9 | repositories {
10 | //mavenLocal()
11 | maven { url = uri("https://repo.ajg0702.us/releases/") }
12 | maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
13 | mavenCentral()
14 | }
15 |
16 | dependencies {
17 | compileOnly("net.kyori:adventure-api:4.15.0")
18 | compileOnly("com.google.guava:guava:30.1.1-jre")
19 | compileOnly("org.spongepowered:configurate-yaml:4.0.0")
20 |
21 | implementation("us.ajg0702:ajUtils:1.2.25")
22 |
23 | implementation(project(":platforms:velocity"))
24 | implementation(project(":platforms:bungeecord"))
25 |
26 | implementation(project(":spigot"))
27 | }
28 |
29 | tasks.shadowJar {
30 | relocate("us.ajg0702.utils", "us.ajg0702.queue.libs.utils")
31 | relocate("org.bstats", "us.ajg0702.queue.libs.bstats")
32 | //relocate("net.kyori", "us.ajg0702.queue.libs.kyori")
33 | relocate("io.leangen.geantyref", "us.ajg0702.queue.libs.geantyref")
34 | relocate("org.spongepowered", "us.ajg0702.queue.libs.sponge")
35 | relocate("org.yaml", "us.ajg0702.queue.libs.yaml")
36 | archiveBaseName.set("ajQueue")
37 | archiveClassifier.set("")
38 | }
39 |
40 | publishing {
41 | publications {
42 | create("mavenJava") {
43 | artifact(tasks["jar"])
44 | }
45 | }
46 |
47 | repositories {
48 |
49 | val mavenUrl = "https://repo.ajg0702.us/releases"
50 |
51 | if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
52 | maven {
53 | url = uri(mavenUrl)
54 | name = "ajRepo"
55 |
56 | credentials {
57 | username = "plugins"
58 | password = System.getenv("REPO_TOKEN")
59 | }
60 | }
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajgeiss0702/ajQueue/9ac3f55ff36939c3b9a7e3a59cbf7a4f5092b97a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/libs/private/README.md:
--------------------------------------------------------------------------------
1 | This is where premium dependencies would go. Currently there is none required.
--------------------------------------------------------------------------------
/libs/public/AquaCoreAPI.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ajgeiss0702/ajQueue/9ac3f55ff36939c3b9a7e3a59cbf7a4f5092b97a/libs/public/AquaCoreAPI.jar
--------------------------------------------------------------------------------
/platforms/bungeecord/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `java-library`
3 | `maven-publish`
4 | }
5 |
6 | group = "us.ajg0702.queue.platforms.bungeecord"
7 |
8 | repositories {
9 | //mavenLocal()
10 | maven { url = uri("https://repo.ajg0702.us/releases/") }
11 | maven { url = uri("https://nexus.velocitypowered.com/repository/maven-public/") }
12 | maven { url = uri("https://repo.viaversion.com/") }
13 | mavenCentral()
14 | }
15 |
16 | dependencies {
17 | compileOnly("net.kyori:adventure-api:4.15.0")
18 | compileOnly("com.google.guava:guava:30.1.1-jre")
19 | compileOnly("us.ajg0702:ajUtils:1.2.25")
20 |
21 | compileOnly("net.md-5:bungeecord-api:1.16-R0.4")
22 |
23 | implementation("net.kyori:adventure-text-minimessage:4.15.0")
24 |
25 | implementation("net.kyori:adventure-platform-bungeecord:4.3.2")
26 | compileOnly("net.kyori:adventure-text-serializer-plain:4.15.0")
27 |
28 | compileOnly("com.viaversion:viaversion-api:4.3.1")
29 |
30 | implementation("org.bstats:bstats-bungeecord:3.0.0")
31 |
32 | implementation(project(":common"))
33 | implementation(project(":api"))
34 | }
35 |
36 |
37 | tasks.withType {
38 | from(sourceSets.main.get().java.srcDirs)
39 | filter(
40 | "tokens" to mapOf(
41 | "VERSION" to project.version.toString()
42 | )
43 | ).into("$buildDir/src")
44 | }
45 |
46 | tasks.jar {
47 | exclude("**/*.java")
48 | }
49 |
50 |
51 | publishing {
52 | publications {
53 | create("mavenJava") {
54 | artifact(tasks["jar"])
55 | }
56 | }
57 |
58 | repositories {
59 |
60 | val mavenUrl = "https://repo.ajg0702.us/releases"
61 |
62 | if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
63 | maven {
64 | url = uri(mavenUrl)
65 | name = "ajRepo"
66 |
67 | credentials {
68 | username = "plugins"
69 | password = System.getenv("REPO_TOKEN")
70 | }
71 | }
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/platforms/bungeecord/src/main/java/us/ajg0702/queue/platforms/bungeecord/BungeeLogger.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.bungeecord;
2 |
3 | import us.ajg0702.queue.api.util.QueueLogger;
4 |
5 | import java.util.logging.Level;
6 | import java.util.logging.Logger;
7 |
8 | public class BungeeLogger implements QueueLogger {
9 |
10 | private final Logger logger;
11 |
12 | protected BungeeLogger(Logger logger) {
13 | this.logger = logger;
14 | }
15 |
16 | @Override
17 | public void warn(String message) {
18 | logger.warning(message);
19 | }
20 |
21 | @Override
22 | public void warning(String message) {
23 | logger.warning(message);
24 | }
25 |
26 | @Override
27 | public void info(String message) {
28 | logger.info(message);
29 | }
30 |
31 | @Override
32 | public void error(String message) {
33 | logger.severe(message);
34 | }
35 |
36 | @Override
37 | public void severe(String message) {
38 | logger.severe(message);
39 | }
40 |
41 | @Override
42 | public void warn(String message, Throwable t) {
43 | logger.log(Level.WARNING, message, t);
44 | }
45 |
46 | @Override
47 | public void warning(String message, Throwable t) {
48 | logger.log(Level.WARNING, message, t);
49 | }
50 |
51 | @Override
52 | public void info(String message, Throwable t) {
53 | logger.log(Level.INFO, message, t);
54 | }
55 |
56 | @Override
57 | public void error(String message, Throwable t) {
58 | logger.log(Level.SEVERE, message, t);
59 | }
60 |
61 | @Override
62 | public void severe(String message, Throwable t) {
63 | logger.log(Level.SEVERE, message, t);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/platforms/bungeecord/src/main/java/us/ajg0702/queue/platforms/bungeecord/commands/BungeeCommand.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.bungeecord.commands;
2 |
3 |
4 | import net.md_5.bungee.api.CommandSender;
5 | import net.md_5.bungee.api.plugin.Command;
6 | import net.md_5.bungee.api.plugin.TabExecutor;
7 | import us.ajg0702.queue.commands.BaseCommand;
8 |
9 | public class BungeeCommand extends Command implements TabExecutor {
10 | final BaseCommand command;
11 | public BungeeCommand(BaseCommand command) {
12 | super(command.getName(), command.getPermission(), command.getAliases().toArray(new String[0]));
13 | this.command = command;
14 | }
15 |
16 | @Override
17 | public void execute(CommandSender sender, String[] args) {
18 | if(args.length == 1 && args[0].isEmpty()) {
19 | args = new String[]{};
20 | }
21 | command.execute(new BungeeSender(sender), args);
22 | }
23 |
24 | @Override
25 | public Iterable onTabComplete(CommandSender sender, String[] args) {
26 | return command.autoComplete(new BungeeSender(sender), args);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/platforms/bungeecord/src/main/java/us/ajg0702/queue/platforms/bungeecord/commands/BungeeSender.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.bungeecord.commands;
2 |
3 | import net.kyori.adventure.text.Component;
4 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
5 | import net.md_5.bungee.api.CommandSender;
6 | import net.md_5.bungee.api.connection.ProxiedPlayer;
7 | import org.jetbrains.annotations.NotNull;
8 | import us.ajg0702.queue.api.commands.ICommandSender;
9 | import us.ajg0702.queue.platforms.bungeecord.BungeeQueue;
10 |
11 | import java.util.UUID;
12 |
13 | public class BungeeSender implements ICommandSender {
14 |
15 | final CommandSender handle;
16 |
17 | public BungeeSender(CommandSender handle) {
18 | this.handle = handle;
19 | }
20 |
21 | @Override
22 | public boolean hasPermission(String permission) {
23 | if(permission == null) return true;
24 | return handle.hasPermission(permission);
25 | }
26 |
27 | @Override
28 | public boolean isPlayer() {
29 | return handle instanceof ProxiedPlayer;
30 | }
31 |
32 | @Override
33 | public UUID getUniqueId() throws IllegalStateException {
34 | if(!(handle instanceof ProxiedPlayer)) throw new IllegalStateException("Cannot get UUID of non-player!");
35 | return ((ProxiedPlayer) handle).getUniqueId();
36 | }
37 |
38 | @Override
39 | public void sendMessage(@NotNull Component message) {
40 | if(PlainTextComponentSerializer.plainText().serialize(message).isEmpty()) return;
41 | BungeeQueue.adventure().sender(handle).sendMessage(message);
42 | }
43 |
44 | @Override
45 | public CommandSender getHandle() {
46 | return handle;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/platforms/bungeecord/src/main/java/us/ajg0702/queue/platforms/bungeecord/server/BungeeServerInfo.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.bungeecord.server;
2 |
3 | import net.md_5.bungee.api.config.ServerInfo;
4 | import us.ajg0702.queue.api.server.AdaptedServerInfo;
5 |
6 | public class BungeeServerInfo implements AdaptedServerInfo {
7 |
8 | final ServerInfo handle;
9 | public BungeeServerInfo(ServerInfo handle) {
10 | this.handle = handle;
11 | }
12 |
13 | @Override
14 | public String getName() {
15 | return handle.getName();
16 | }
17 |
18 | @Override
19 | public ServerInfo getHandle() {
20 | return handle;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/platforms/bungeecord/src/main/java/us/ajg0702/queue/platforms/bungeecord/server/BungeeServerPing.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.bungeecord.server;
2 |
3 | import net.kyori.adventure.text.Component;
4 | import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
5 | import net.md_5.bungee.api.ServerPing;
6 | import net.md_5.bungee.api.chat.BaseComponent;
7 | import org.jetbrains.annotations.NotNull;
8 | import us.ajg0702.queue.api.server.AdaptedServerPing;
9 |
10 | public class BungeeServerPing implements AdaptedServerPing {
11 |
12 | final ServerPing handle;
13 | private final long sent;
14 |
15 | public BungeeServerPing(@NotNull ServerPing handle, long sent) {
16 | this.handle = handle;
17 | this.sent = sent;
18 | }
19 |
20 | @Override
21 | public Component getDescriptionComponent() {
22 | BaseComponent[] baseComponents = new BaseComponent[1];
23 | baseComponents[0] = handle.getDescriptionComponent();
24 | return BungeeComponentSerializer.get().deserialize(baseComponents);
25 | }
26 |
27 | @Override
28 | public String getPlainDescription() {
29 | BaseComponent desc = handle.getDescriptionComponent();
30 | if(desc == null) return null;
31 | return desc.toPlainText();
32 | }
33 |
34 | int add = 0;
35 |
36 | @Override
37 | public int getPlayerCount() {
38 | return handle.getPlayers().getOnline()+add;
39 | }
40 |
41 | @Override
42 | public int getMaxPlayers() {
43 | return handle.getPlayers().getMax();
44 | }
45 |
46 | @Override
47 | public void addPlayer() {
48 | add++;
49 | }
50 |
51 | @Override
52 | public long getFetchedTime() {
53 | return sent;
54 | }
55 |
56 | @Override
57 | public ServerPing getHandle() {
58 | return handle;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/platforms/bungeecord/src/main/resources/bungee.yml:
--------------------------------------------------------------------------------
1 | name: ajQueue
2 | version: "@VERSION@"
3 | main: us.ajg0702.queue.platforms.bungeecord.BungeeQueue
4 | author: ajgeiss0702
--------------------------------------------------------------------------------
/platforms/velocity/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `java-library`
3 | `maven-publish`
4 | }
5 |
6 | group = "us.ajg0702.queue.platforms.velocity"
7 |
8 | repositories {
9 | //mavenLocal()
10 | maven { url = uri("https://repo.ajg0702.us/releases/") }
11 | maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
12 | maven { url = uri("https://repo.viaversion.com/") }
13 | mavenCentral()
14 | }
15 |
16 | dependencies {
17 | compileOnly("net.kyori:adventure-api:4.15.0")
18 | compileOnly("com.google.guava:guava:30.1.1-jre")
19 | compileOnly("us.ajg0702:ajUtils:1.2.25")
20 |
21 | compileOnly("com.velocitypowered:velocity-api:3.1.1")
22 | annotationProcessor("com.velocitypowered:velocity-api:3.1.1")
23 | implementation("net.kyori:adventure-text-minimessage:4.15.0")
24 |
25 | compileOnly("com.viaversion:viaversion-api:4.3.1")
26 |
27 | implementation("org.bstats:bstats-velocity:3.0.0")
28 |
29 | implementation(project(":common"))
30 | implementation(project(":api"))
31 | }
32 |
33 |
34 | tasks.withType {
35 | from(sourceSets.main.get().java.srcDirs)
36 | filter(
37 | "tokens" to mapOf(
38 | "VERSION" to project.version.toString()
39 | )
40 | ).into("$buildDir/src")
41 | }
42 |
43 | tasks.jar {
44 | exclude("**/*.java")
45 | }
46 |
47 | tasks.compileJava {
48 | source = tasks.getByName("processResources").outputs.files.asFileTree
49 | }
50 |
51 |
52 | publishing {
53 | publications {
54 | create("mavenJava") {
55 | artifact(tasks["jar"])
56 | }
57 | }
58 |
59 | repositories {
60 |
61 | val mavenUrl = "https://repo.ajg0702.us/releases"
62 |
63 | if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
64 | maven {
65 | url = uri(mavenUrl)
66 | name = "ajRepo"
67 |
68 | credentials {
69 | username = "plugins"
70 | password = System.getenv("REPO_TOKEN")
71 | }
72 | }
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/platforms/velocity/src/main/java/us/ajg0702/queue/platforms/velocity/VelocityLogger.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.velocity;
2 |
3 |
4 | import org.slf4j.Logger;
5 | import us.ajg0702.queue.api.util.QueueLogger;
6 |
7 | public class VelocityLogger implements QueueLogger {
8 |
9 | private final Logger logger;
10 |
11 | protected VelocityLogger(Logger logger) {
12 | this.logger = logger;
13 | }
14 |
15 | @Override
16 | public void warn(String message) {
17 | logger.warn(message);
18 | }
19 |
20 | @Override
21 | public void warning(String message) {
22 | logger.warn(message);
23 | }
24 |
25 | @Override
26 | public void info(String message) {
27 | logger.info(message);
28 | }
29 |
30 | @Override
31 | public void error(String message) {
32 | logger.error(message);
33 | }
34 |
35 | @Override
36 | public void severe(String message) {
37 | logger.error(message);
38 | }
39 |
40 | @Override
41 | public void warn(String message, Throwable t) {
42 | logger.warn(message, t);
43 | }
44 |
45 | @Override
46 | public void warning(String message, Throwable t) {
47 | logger.warn(message, t);
48 | }
49 |
50 | @Override
51 | public void info(String message, Throwable t) {
52 | logger.info(message, t);
53 | }
54 |
55 | @Override
56 | public void error(String message, Throwable t) {
57 | logger.error(message, t);
58 | }
59 |
60 | @Override
61 | public void severe(String message, Throwable t) {
62 | logger.error(message, t);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/platforms/velocity/src/main/java/us/ajg0702/queue/platforms/velocity/commands/VelocityCommand.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.velocity.commands;
2 |
3 | import com.velocitypowered.api.command.RawCommand;
4 | import us.ajg0702.queue.commands.BaseCommand;
5 | import us.ajg0702.queue.common.QueueMain;
6 |
7 | import java.util.ArrayList;
8 | import java.util.Arrays;
9 | import java.util.List;
10 |
11 | public class VelocityCommand implements RawCommand {
12 |
13 | final QueueMain main;
14 | final BaseCommand command;
15 |
16 | public VelocityCommand(QueueMain main, BaseCommand command) {
17 | this.main = main;
18 | this.command = command;
19 | }
20 |
21 | @Override
22 | public void execute(Invocation invocation) {
23 | String[] args = new String[]{};
24 | if(!invocation.arguments().isEmpty()) {
25 | args = invocation.arguments().split(" ");
26 | }
27 | command.execute(new VelocitySender(invocation.source()), args);
28 | }
29 |
30 | @Override
31 | public List suggest(final Invocation invocation) {
32 | List args = new ArrayList<>(Arrays.asList(invocation.arguments().split(" ")));
33 | if(invocation.arguments().length() > 0 &&invocation.arguments().charAt(invocation.arguments().length()-1) == ' ') {
34 | args.add(" ");
35 | }
36 | return command.autoComplete(new VelocitySender(invocation.source()), args.toArray(new String[0]));
37 | }
38 |
39 | @Override
40 | public boolean hasPermission(final Invocation invocation) {
41 | String permission = command.getPermission();
42 | if(permission == null) return true;
43 | return invocation.source().hasPermission(permission);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/platforms/velocity/src/main/java/us/ajg0702/queue/platforms/velocity/commands/VelocitySender.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.velocity.commands;
2 |
3 | import com.velocitypowered.api.command.CommandSource;
4 | import com.velocitypowered.api.proxy.ConsoleCommandSource;
5 | import com.velocitypowered.api.proxy.Player;
6 | import net.kyori.adventure.text.Component;
7 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
8 | import org.jetbrains.annotations.NotNull;
9 | import us.ajg0702.queue.api.commands.ICommandSender;
10 |
11 | import java.util.UUID;
12 |
13 | public class VelocitySender implements ICommandSender {
14 |
15 | final CommandSource handle;
16 |
17 | public VelocitySender(CommandSource handle) {
18 | this.handle = handle;
19 | }
20 |
21 | @Override
22 | public boolean hasPermission(String permission) {
23 | if(permission == null) return true;
24 | return handle.hasPermission(permission);
25 | }
26 |
27 | @Override
28 | public boolean isPlayer() {
29 | return !(handle instanceof ConsoleCommandSource);
30 | }
31 |
32 | @Override
33 | public UUID getUniqueId() throws IllegalStateException {
34 | if(!(handle instanceof Player)) throw new IllegalStateException("Cannot get UUID of non-player!");
35 | return ((Player) handle).getUniqueId();
36 | }
37 |
38 | @Override
39 | public void sendMessage(@NotNull Component message) {
40 | if(PlainTextComponentSerializer.plainText().serialize(message).isEmpty()) return;
41 | handle.sendMessage(message);
42 | }
43 |
44 | @Override
45 | public CommandSource getHandle() {
46 | return handle;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/platforms/velocity/src/main/java/us/ajg0702/queue/platforms/velocity/server/VelocityServerInfo.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.velocity.server;
2 |
3 | import com.velocitypowered.api.proxy.server.ServerInfo;
4 | import us.ajg0702.queue.api.server.AdaptedServerInfo;
5 |
6 | public class VelocityServerInfo implements AdaptedServerInfo {
7 |
8 | private final ServerInfo handle;
9 |
10 | public VelocityServerInfo(ServerInfo handle) {
11 | this.handle = handle;
12 | }
13 |
14 | @Override
15 | public String getName() {
16 | return handle.getName();
17 | }
18 |
19 | @Override
20 | public ServerInfo getHandle() {
21 | return handle;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/platforms/velocity/src/main/java/us/ajg0702/queue/platforms/velocity/server/VelocityServerPing.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.platforms.velocity.server;
2 |
3 | import com.velocitypowered.api.proxy.server.ServerPing;
4 | import net.kyori.adventure.text.Component;
5 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
6 | import us.ajg0702.queue.api.server.AdaptedServerPing;
7 |
8 | public class VelocityServerPing implements AdaptedServerPing {
9 |
10 | private final ServerPing handle;
11 | private final long sent;
12 | public VelocityServerPing(ServerPing handle, long sent) {
13 | this.handle = handle;
14 | this.sent = sent;
15 | }
16 |
17 | @Override
18 | public Component getDescriptionComponent() {
19 | return handle.getDescriptionComponent();
20 | }
21 |
22 | @Override
23 | public String getPlainDescription() {
24 | Component description = handle.getDescriptionComponent();
25 | if(description == null) return null;
26 | return PlainTextComponentSerializer.plainText().serialize(description);
27 | }
28 |
29 | int add = 0;
30 |
31 | @Override
32 | public int getPlayerCount() {
33 | return handle.getPlayers().map(ServerPing.Players::getOnline).orElse(0)+add;
34 | }
35 |
36 | @Override
37 | public int getMaxPlayers() {
38 | return handle.getPlayers().map(ServerPing.Players::getMax).orElse(0);
39 | }
40 |
41 | @Override
42 | public void addPlayer() {
43 | add++;
44 | }
45 |
46 | @Override
47 | public long getFetchedTime() {
48 | return sent;
49 | }
50 |
51 | @Override
52 | public ServerPing getHandle() {
53 | return handle;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/premium/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `java-library`
3 | id("com.github.johnrengelman.shadow")
4 | `maven-publish`
5 | }
6 |
7 | group = "us.ajg0702.queue"
8 |
9 | repositories {
10 | //mavenLocal()
11 | maven { url = uri("https://repo.ajg0702.us/releases/") }
12 | maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
13 | // maven { url = uri("https://repo.techscode.com/repository/maven-releases/") }
14 | mavenCentral()
15 | }
16 |
17 | dependencies {
18 | implementation(project(":free"))
19 |
20 | compileOnly(project(":api"))
21 | compileOnly(project(":common"))
22 |
23 | compileOnly("com.google.guava:guava:30.1.1-jre")
24 |
25 | compileOnly("me.TechsCode:FakeUltraPerms:1.0.2")
26 |
27 | compileOnly("us.ajg0702:ajUtils:1.2.25")
28 |
29 | compileOnly("net.kyori:adventure-api:4.15.0")
30 |
31 | compileOnly(fileTree(mapOf("dir" to "../libs/private", "include" to listOf("*.jar"))))
32 | compileOnly(fileTree(mapOf("dir" to "../libs/public", "include" to listOf("*.jar"))))
33 |
34 | compileOnly("net.luckperms:api:5.4")
35 | }
36 |
37 | tasks.shadowJar {
38 | relocate("us.ajg0702.utils", "us.ajg0702.queue.libs.utils")
39 | relocate("org.bstats", "us.ajg0702.queue.libs.bstats")
40 | relocate("io.leangen.geantyref", "us.ajg0702.queue.libs.geantyref")
41 | relocate("org.spongepowered", "us.ajg0702.queue.libs.sponge")
42 | relocate("org.yaml", "us.ajg0702.queue.libs.yaml")
43 | archiveBaseName.set("ajQueuePlus")
44 | archiveClassifier.set("")
45 | }
46 |
47 | publishing {
48 | publications {
49 | create("mavenJava") {
50 | artifact(tasks["jar"])
51 | }
52 | }
53 |
54 | repositories {
55 |
56 | val mavenUrl = "https://repo.ajg0702.us/releases"
57 |
58 | if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
59 | maven {
60 | url = uri(mavenUrl)
61 | name = "ajRepo"
62 |
63 | credentials {
64 | username = "plugins"
65 | password = System.getenv("REPO_TOKEN")
66 | }
67 | }
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/premium/src/main/java/us/ajg0702/queue/logic/LogicGetterImpl.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic;
2 |
3 | import us.ajg0702.queue.api.AliasManager;
4 | import us.ajg0702.queue.api.premium.Logic;
5 | import us.ajg0702.queue.api.premium.LogicGetter;
6 | import us.ajg0702.queue.api.players.AdaptedPlayer;
7 | import us.ajg0702.queue.api.premium.PermissionGetter;
8 | import us.ajg0702.queue.common.QueueMain;
9 | import us.ajg0702.utils.common.Config;
10 |
11 | import java.util.List;
12 |
13 | public class LogicGetterImpl implements LogicGetter {
14 | PremiumLogic logic;
15 |
16 | @Override
17 | public Logic constructLogic() {
18 | if(logic == null) {
19 | logic = new PremiumLogic(QueueMain.getInstance());
20 | }
21 | return logic;
22 | }
23 |
24 | @Override
25 | public AliasManager constructAliasManager(Config config) {
26 | return new PremiumAliasManager(config);
27 | }
28 |
29 | @Override
30 | public List getPermissions(AdaptedPlayer player) {
31 | if(logic == null) return null;
32 | return logic.getPermissionGetter().getSelected().getPermissions(player);
33 | }
34 |
35 | @Override
36 | public PermissionGetter getPermissionGetter() {
37 | return logic.getPermissionGetter();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/premium/src/main/java/us/ajg0702/queue/logic/PremiumAliasManager.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic;
2 |
3 | import us.ajg0702.queue.api.AliasManager;
4 | import us.ajg0702.utils.common.Config;
5 |
6 | import java.util.List;
7 |
8 | public class PremiumAliasManager implements AliasManager {
9 |
10 | private final Config config;
11 |
12 | protected PremiumAliasManager(Config config) {
13 | this.config = config;
14 | }
15 |
16 | @Override
17 | public String getAlias(String server) {
18 | List aliasesraw = config.getStringList("server-aliases");
19 | for(String aliasraw : aliasesraw) {
20 | String realname = aliasraw.split(":")[0];
21 | if(!realname.equalsIgnoreCase(server)) continue;
22 | return aliasraw.split(":")[1];
23 | }
24 | return server;
25 | }
26 |
27 | @Override
28 | public String getServer(String alias) {
29 | List aliasesraw = config.getStringList("server-aliases");
30 | for(String aliasraw : aliasesraw) {
31 | String salias = aliasraw.split(":")[1];
32 | if(!alias.equalsIgnoreCase(salias)) continue;
33 | return aliasraw.split(":")[0];
34 | }
35 | return alias;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/premium/src/main/java/us/ajg0702/queue/logic/permissions/hooks/AquaCoreHook.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic.permissions.hooks;
2 |
3 | import me.activated.core.plugin.AquaCoreAPI;
4 | import us.ajg0702.queue.api.players.AdaptedPlayer;
5 | import us.ajg0702.queue.common.QueueMain;
6 | import us.ajg0702.queue.api.premium.PermissionHook;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | public class AquaCoreHook implements PermissionHook {
12 |
13 | private final QueueMain main;
14 | public AquaCoreHook(QueueMain main) {
15 | this.main = main;
16 | }
17 |
18 | @Override
19 | public String getName() {
20 | return "AquaCore";
21 | }
22 |
23 | @Override
24 | public boolean canUse() {
25 | if(!main.getPlatformMethods().hasPlugin("AquaProxy") ) return false;
26 | try {
27 | if(AquaCoreAPI.INSTANCE == null) {
28 | main.getLogger().warn("AquaCore is installed, but its INSTANCE returned null! Unable to hook into it.");
29 | return false;
30 | }
31 | } catch(NoClassDefFoundError e) {
32 | main.getLogger().warning("AquaCore seems to be installed, but its api doesnt seem to be!");
33 | return false;
34 | }
35 | return true;
36 | }
37 |
38 | @Override
39 | public List getPermissions(AdaptedPlayer player) {
40 | AquaCoreAPI api = AquaCoreAPI.INSTANCE;
41 |
42 | List permissions = new ArrayList<>();
43 |
44 | api.getPlayerData(player.getUniqueId()).getActiveGrants().forEach(grant -> {
45 | if(!grant.isActiveSomewhere() || grant.hasExpired()) return;
46 | permissions.addAll(grant.getRank().getAvailablePermissions());
47 | });
48 |
49 | return permissions;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/premium/src/main/java/us/ajg0702/queue/logic/permissions/hooks/BuiltInHook.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic.permissions.hooks;
2 |
3 | import us.ajg0702.queue.api.players.AdaptedPlayer;
4 | import us.ajg0702.queue.common.QueueMain;
5 | import us.ajg0702.queue.api.premium.PermissionHook;
6 |
7 | import java.util.ArrayList;
8 | import java.util.Arrays;
9 | import java.util.Collections;
10 | import java.util.List;
11 |
12 | public class BuiltInHook implements PermissionHook {
13 |
14 | private final QueueMain main;
15 | public BuiltInHook(QueueMain main) {
16 | this.main = main;
17 | }
18 |
19 | @Override
20 | public String getName() {
21 | return "Built-In";
22 | }
23 |
24 | @Override
25 | public boolean canUse() {
26 | return true;
27 | }
28 |
29 | @Override
30 | public List getPermissions(AdaptedPlayer player) {
31 | if(main.getConfig().getBoolean("plus-level-fallback")) {
32 | List hasPermissions = new ArrayList<>();
33 | for (String fallbackPermission : fallbackPermissions) {
34 | if(player.hasPermission(fallbackPermission)) {
35 | hasPermissions.add(fallbackPermission);
36 | }
37 | }
38 | if(!main.getPlatformMethods().getImplementationName().equals("velocity")) {
39 | hasPermissions.addAll(player.getPermissions());
40 | }
41 | return hasPermissions;
42 | }
43 |
44 |
45 | if(main.getPlatformMethods().getImplementationName().equals("velocity")) {
46 | return Collections.emptyList();
47 | }
48 |
49 | return player.getPermissions();
50 | }
51 |
52 | private final List fallbackPermissions = Arrays.asList(
53 | "ajqueue.priority.1",
54 | "ajqueue.priority.2",
55 | "ajqueue.priority.3",
56 | "ajqueue.priority.4",
57 | "ajqueue.priority.5",
58 | "ajqueue.priority.6",
59 | "ajqueue.priority.7",
60 | "ajqueue.priority.8",
61 | "ajqueue.priority.9",
62 | "ajqueue.priority.10",
63 | "ajqueue.stayqueued.15",
64 | "ajqueue.stayqueued.30",
65 | "ajqueue.stayqueued.60",
66 | "ajqueue.stayqueued.120"
67 | );
68 | }
69 |
--------------------------------------------------------------------------------
/premium/src/main/java/us/ajg0702/queue/logic/permissions/hooks/LuckPermsHook.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic.permissions.hooks;
2 |
3 | import net.luckperms.api.LuckPerms;
4 | import net.luckperms.api.LuckPermsProvider;
5 | import net.luckperms.api.context.Context;
6 | import net.luckperms.api.model.user.User;
7 | import net.luckperms.api.node.Node;
8 | import net.luckperms.api.node.NodeType;
9 | import net.luckperms.api.query.QueryOptions;
10 | import us.ajg0702.queue.api.players.AdaptedPlayer;
11 | import us.ajg0702.queue.api.premium.PermissionHook;
12 | import us.ajg0702.queue.common.QueueMain;
13 |
14 | import java.util.*;
15 |
16 | public class LuckPermsHook implements PermissionHook {
17 |
18 | private final QueueMain main;
19 | public LuckPermsHook(QueueMain main) {
20 | this.main = main;
21 | }
22 |
23 | @Override
24 | public String getName() {
25 | return "LuckPerms";
26 | }
27 |
28 | @Override
29 | public boolean canUse() {
30 | return main.getPlatformMethods().hasPlugin("LuckPerms");
31 | }
32 |
33 | @Override
34 | public List getPermissions(AdaptedPlayer player) {
35 | LuckPerms api = LuckPermsProvider.get();
36 |
37 | User user = api.getUserManager().getUser(player.getUniqueId());
38 |
39 | if(user == null) {
40 | main.getLogger().warn("LuckPerms doesnt seem to have data loaded for "+player.getName()+"! " +
41 | "Because of this I can't load priority permissions. Acting like "+player.getName()+" doesnt have any.");
42 | return Collections.emptyList();
43 | }
44 |
45 | SortedSet nodes = user.resolveDistinctInheritedNodes(QueryOptions.nonContextual());
46 |
47 | List perms = new ArrayList<>();
48 |
49 | for (Node node : nodes) {
50 | if (!node.getType().equals(NodeType.PERMISSION)) continue;
51 | if (!node.getValue()) continue;
52 | String permission = node.getKey();
53 |
54 |
55 | if(permission.equalsIgnoreCase("ajqueue.contextbypass")) {
56 | boolean skip = false;
57 | for(Context context : node.getContexts()) {
58 | if(context.getKey().equalsIgnoreCase("server")) {
59 | skip = true;
60 | perms.add("ajqueue.serverbypass."+context.getValue());
61 | }
62 | }
63 | if(skip) continue;
64 | }
65 |
66 | if(permission.toLowerCase(Locale.ROOT).startsWith("ajqueue.contextpriority.")) {
67 | boolean skip = false;
68 | int level;
69 | try {
70 | level = Integer.parseInt(permission.substring(0, 24));
71 | } catch(NumberFormatException e) {
72 | main.getLogger().warning("A non-number is in the priority permission "+permission);
73 | continue;
74 | }
75 | for(Context context : node.getContexts()) {
76 | if(context.getKey().equalsIgnoreCase("server")) {
77 | skip = true;
78 | perms.add("ajqueue.serverpriority."+context.getValue()+"."+level);
79 | }
80 | }
81 | if(skip) continue;
82 | }
83 |
84 |
85 | perms.add(permission);
86 | }
87 |
88 | return perms;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/premium/src/main/java/us/ajg0702/queue/logic/permissions/hooks/UltraPermissionsHook.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.logic.permissions.hooks;
2 |
3 | import me.TechsCode.UltraPermissions.UltraPermissions;
4 | import me.TechsCode.UltraPermissions.UltraPermissionsAPI;
5 | import me.TechsCode.UltraPermissions.storage.objects.User;
6 | import us.ajg0702.queue.api.players.AdaptedPlayer;
7 | import us.ajg0702.queue.common.QueueMain;
8 | import us.ajg0702.queue.api.premium.PermissionHook;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | import java.util.Optional;
13 |
14 | public class UltraPermissionsHook implements PermissionHook {
15 |
16 | private final QueueMain main;
17 | public UltraPermissionsHook(QueueMain main) {
18 | this.main = main;
19 | }
20 |
21 | @Override
22 | public String getName() {
23 | return "UltraPermissions";
24 | }
25 |
26 | @Override
27 | public boolean canUse() {
28 | if(!main.getPlatformMethods().hasPlugin("UltraPermissions") ) return false;
29 | if(UltraPermissions.getAPI() == null) {
30 | main.getLogger().warn("UltraPermissions is installed, but its getApi() method returned null! Unable to hook into it.");
31 | return false;
32 | }
33 | return true;
34 | }
35 |
36 | @Override
37 | public List getPermissions(AdaptedPlayer player) {
38 | UltraPermissionsAPI ultraPermissionsAPI = UltraPermissions.getAPI();
39 |
40 | Optional userOptional = ultraPermissionsAPI
41 | .getUsers()
42 | .uuid(player.getUniqueId());
43 | if(!userOptional.isPresent()) return new ArrayList<>();
44 | User user = userOptional.get();
45 |
46 | List permissions = new ArrayList<>();
47 | user.getPermissions().bungee().forEach(permission -> permissions.add(permission.getName()));
48 | return permissions;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "ajQueue"
2 |
3 | include(":api")
4 | include(":common")
5 |
6 | include(":spigot")
7 |
8 | include(":platforms:velocity")
9 | include(":platforms:bungeecord")
10 |
11 | include(":free")
12 | include(":premium")
--------------------------------------------------------------------------------
/spigot/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | `java-library`
3 | `maven-publish`
4 | }
5 |
6 | group = "us.ajg0702.queue.spigot"
7 |
8 | repositories {
9 | //mavenLocal()
10 |
11 |
12 | maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") }
13 |
14 | maven { url = uri("https://repo.codemc.io/repository/nms/") }
15 |
16 | maven { url = uri("https://repo.ajg0702.us/releases/") }
17 |
18 | mavenCentral()
19 | }
20 |
21 | dependencies {
22 | implementation("net.kyori:adventure-api:4.15.0")
23 | compileOnly(project(":api"))
24 | compileOnly("com.google.guava:guava:30.1.1-jre")
25 |
26 | compileOnly("org.spongepowered:configurate-yaml:4.1.2")
27 |
28 | compileOnly("us.ajg0702:ajUtils:1.2.25")
29 |
30 | compileOnly(group = "org.spigotmc", name = "spigot", version = "1.16.5-R0.1-SNAPSHOT")
31 | compileOnly("me.clip:placeholderapi:2.10.4")
32 | }
33 |
34 | tasks.withType {
35 | include("**/*.yml")
36 | filter(
37 | "tokens" to mapOf(
38 | "VERSION" to project.version.toString()
39 | )
40 | )
41 | }
42 |
43 | publishing {
44 | publications {
45 | create("mavenJava") {
46 | artifact(tasks["jar"])
47 | }
48 | }
49 |
50 | repositories {
51 |
52 | val mavenUrl = "https://repo.ajg0702.us/releases"
53 |
54 | if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
55 | maven {
56 | url = uri(mavenUrl)
57 | name = "ajRepo"
58 |
59 | credentials {
60 | username = "plugins"
61 | password = System.getenv("REPO_TOKEN")
62 | }
63 | }
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/Commands.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.command.Command;
6 | import org.bukkit.command.CommandExecutor;
7 | import org.bukkit.command.CommandSender;
8 | import org.bukkit.entity.Player;
9 | import org.jetbrains.annotations.NotNull;
10 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
11 |
12 | public class Commands implements CommandExecutor {
13 |
14 | final SpigotMain pl;
15 | public Commands(SpigotMain pl) {
16 | this.pl = pl;
17 | }
18 |
19 | @Override
20 | public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
21 | if(!pl.hasProxy() && pl.getAConfig().getBoolean("check-proxy-response")) {
22 | if(sender instanceof Player) pl.sendMessage((Player) sender, "ack", "");
23 | sender.sendMessage(
24 | color(
25 | "&c" +
26 | (sender.hasPermission("ajqueue.manage") ? "ajQueue" : "The queue plugin") +
27 | " must also be installed on the proxy!&7 If it has been installed on the proxy, make sure it loaded correctly and try again."
28 | )
29 | );
30 | return true;
31 | }
32 | Player player = null;
33 | if(sender instanceof Player) {
34 | player = (Player) sender;
35 | }
36 | if(command.getName().equals("leavequeue")) {
37 | if(player == null) return true;
38 | StringBuilder arg = new StringBuilder();
39 | for(String a : args) {
40 | arg.append(" ");
41 | arg.append(a);
42 | }
43 | pl.sendMessage(player, "leavequeue", arg.toString());
44 | return true;
45 | }
46 |
47 |
48 | // Queue command
49 |
50 |
51 | if(args.length < 1) return false;
52 |
53 | String serverName = args[0];
54 |
55 | boolean sudo = true;
56 |
57 | // /queue
58 | if(args.length > 1) {
59 | sudo = false;
60 | if(!sender.hasPermission("ajqueue.send")) {
61 | sender.sendMessage(color("&cYou do not have permission to do this!"));
62 | return true;
63 | }
64 | pl.getLogger().info("Sending "+args[0]+" to queue '" + args[1] + "'");
65 | Player playerToSend = Bukkit.getPlayer(args[0]);
66 | if(playerToSend == null) {
67 | sender.sendMessage(color("&cCannot find that player!"));
68 | return true;
69 | }
70 | player = playerToSend;
71 | serverName = args[1];
72 | }
73 |
74 | if(player == null) {
75 | sender.sendMessage("I need to know what player to send!");
76 | return true;
77 | }
78 |
79 | if(sudo) {
80 | if(pl.getAConfig().getBoolean("send-queue-commands-in-batches")) {
81 | pl.queuebatch.put(player, serverName);
82 | } else {
83 | AjQueueSpigotAPI.getInstance().sudoQueue(player.getUniqueId(), serverName);
84 | }
85 | } else {
86 | AjQueueSpigotAPI.getInstance().addToQueue(player.getUniqueId(), serverName);
87 | }
88 |
89 | return true;
90 | }
91 |
92 | public String color(String txt) {
93 | return ChatColor.translateAlternateColorCodes('&', txt);
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/QueueScoreboardActivator.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.Event;
5 | import org.bukkit.event.HandlerList;
6 | import org.jetbrains.annotations.NotNull;
7 |
8 | public class QueueScoreboardActivator extends Event {
9 | private static final HandlerList HANDLERS = new HandlerList();
10 |
11 | public @NotNull HandlerList getHandlers() {
12 | return HANDLERS;
13 | }
14 |
15 | public static HandlerList getHandlerList() {
16 | return HANDLERS;
17 | }
18 |
19 | final Player ply;
20 |
21 | public QueueScoreboardActivator(Player p) {
22 | this.ply = p;
23 | }
24 |
25 | public Player getPlayer() {
26 | return ply.getPlayer();
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/communication/ResponseKey.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.communication;
2 |
3 | import java.util.Objects;
4 |
5 | public class ResponseKey {
6 | private final String id;
7 | private final String from;
8 |
9 | public ResponseKey(String id, String from) {
10 | this.id = id;
11 | this.from = from;
12 | }
13 |
14 | @Override
15 | public boolean equals(Object o) {
16 | if (this == o) return true;
17 | if (o == null || getClass() != o.getClass()) return false;
18 | ResponseKey that = (ResponseKey) o;
19 | return id.equals(that.id) && from.equals(that.from);
20 | }
21 |
22 | @Override
23 | public int hashCode() {
24 | return Objects.hash(id, from);
25 | }
26 |
27 | @Override
28 | public String toString() {
29 | return "ResponseKey{" +
30 | "id='" + id + '\'' +
31 | ", from='" + from + '\'' +
32 | '}';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/communication/ResponseManager.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.communication;
2 |
3 | import us.ajg0702.queue.api.communication.ComResponse;
4 |
5 | import java.util.Map;
6 | import java.util.concurrent.ConcurrentHashMap;
7 | import java.util.function.Consumer;
8 |
9 |
10 | public class ResponseManager {
11 | private final Map> responseMap = new ConcurrentHashMap<>();
12 |
13 | public synchronized void awaitResponse(String id, String from, Consumer callback) {
14 | ResponseKey key = new ResponseKey(id, from);
15 | responseMap.merge(key, callback, (a, b) -> r -> {
16 | b.accept(r);
17 | a.accept(r);
18 | });
19 | }
20 |
21 | public void executeResponse(ComResponse response) {
22 | ResponseKey key = new ResponseKey(response.getIdentifier(), response.getFrom());
23 | Consumer callback = responseMap.get(key);
24 | if(callback == null) return;
25 | responseMap.remove(key);
26 | callback.accept(response);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/CachedPlaceholder.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders;
2 |
3 | import java.util.regex.Matcher;
4 |
5 | public class CachedPlaceholder {
6 | private final Matcher matcher;
7 | private final Placeholder placeholder;
8 |
9 | public CachedPlaceholder(Matcher matcher, Placeholder placeholder) {
10 | this.matcher = matcher;
11 | this.placeholder = placeholder;
12 | }
13 |
14 | public Matcher getMatcher() {
15 | return matcher;
16 | }
17 |
18 | public Placeholder getPlaceholder() {
19 | return placeholder;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/Placeholder.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders;
2 |
3 | import org.bukkit.OfflinePlayer;
4 | import org.bukkit.entity.Player;
5 | import us.ajg0702.queue.spigot.SpigotMain;
6 |
7 | import java.util.regex.Matcher;
8 | import java.util.regex.Pattern;
9 |
10 | public abstract class Placeholder {
11 |
12 | protected final SpigotMain plugin;
13 |
14 | private Pattern pattern;
15 |
16 | public Placeholder(SpigotMain plugin) {
17 | this.plugin = plugin;
18 | }
19 |
20 | public abstract String getRegex();
21 |
22 | public Pattern getPattern() {
23 | if(pattern == null) {
24 | pattern = Pattern.compile(getRegex());
25 | }
26 | return pattern;
27 | }
28 |
29 | public abstract String parse(Matcher matcher, OfflinePlayer p);
30 |
31 | public abstract void cleanCache(Player player);
32 | }
33 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/PlaceholderExpansion.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders;
2 |
3 | import org.bukkit.OfflinePlayer;
4 | import org.bukkit.entity.Player;
5 | import org.jetbrains.annotations.NotNull;
6 | import us.ajg0702.queue.spigot.SpigotMain;
7 | import us.ajg0702.queue.spigot.placeholders.placeholders.*;
8 |
9 | import java.util.ArrayList;
10 | import java.util.HashMap;
11 | import java.util.List;
12 | import java.util.Map;
13 | import java.util.regex.Matcher;
14 |
15 | public class PlaceholderExpansion extends me.clip.placeholderapi.expansion.PlaceholderExpansion {
16 |
17 | private final List placeholders = new ArrayList<>();
18 |
19 | private final SpigotMain plugin;
20 |
21 | @SuppressWarnings("deprecated")
22 | public PlaceholderExpansion(SpigotMain plugin) {
23 |
24 | this.plugin = plugin;
25 |
26 | placeholders.add(new EstimatedTime(plugin));
27 | placeholders.add(new InQueue(plugin));
28 | placeholders.add(new Position(plugin));
29 | placeholders.add(new PositionOf(plugin));
30 | placeholders.add(new Queued(plugin));
31 | placeholders.add(new QueuedFor(plugin));
32 | placeholders.add(new StatusPlayer(plugin));
33 | placeholders.add(new Status(plugin));
34 |
35 | }
36 |
37 | Map placeholderCache = new HashMap<>();
38 |
39 | @Override
40 | public String onRequest(OfflinePlayer p, @NotNull String params) {
41 |
42 | if(p == null || !p.isOnline()) {
43 | return "No player";
44 | }
45 |
46 | CachedPlaceholder cachedPlaceholder = placeholderCache.computeIfAbsent(params, s -> {
47 | for(Placeholder placeholder : placeholders) {
48 | Matcher matcher = placeholder.getPattern().matcher(params);
49 | if(!matcher.matches()) continue;
50 | return new CachedPlaceholder(matcher, placeholder);
51 | }
52 | return null;
53 | });
54 | if(cachedPlaceholder == null) return null;
55 |
56 | return cachedPlaceholder.getPlaceholder().parse(cachedPlaceholder.getMatcher(), p);
57 | }
58 |
59 |
60 |
61 | @Override
62 | public @NotNull String getIdentifier() {
63 | return "ajqueue";
64 | }
65 |
66 | @Override
67 | public @NotNull String getAuthor() {
68 | return "ajgeiss0702";
69 | }
70 |
71 | @Override
72 | public @NotNull String getVersion() {
73 | return plugin.getDescription().getVersion();
74 | }
75 |
76 | @Override
77 | public boolean persist(){
78 | return true;
79 | }
80 |
81 | @Override
82 | public boolean canRegister() {
83 | return true;
84 | }
85 |
86 | public void cleanCache(Player player) {
87 | placeholders.forEach(p -> p.cleanCache(player));
88 | }
89 | }
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/placeholders/EstimatedTime.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders.placeholders;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
7 | import us.ajg0702.queue.api.spigot.MessagedResponse;
8 | import us.ajg0702.queue.spigot.SpigotMain;
9 | import us.ajg0702.queue.spigot.placeholders.Placeholder;
10 |
11 | import java.util.Map;
12 | import java.util.UUID;
13 | import java.util.concurrent.ConcurrentHashMap;
14 | import java.util.concurrent.ExecutionException;
15 | import java.util.concurrent.TimeUnit;
16 | import java.util.concurrent.TimeoutException;
17 | import java.util.logging.Level;
18 | import java.util.regex.Matcher;
19 |
20 | public class EstimatedTime extends Placeholder {
21 | public EstimatedTime(SpigotMain plugin) {
22 | super(plugin);
23 | }
24 |
25 | private final Map cache = new ConcurrentHashMap<>();
26 | private final Map lastFetch = new ConcurrentHashMap<>();
27 |
28 | @Override
29 | public String getRegex() {
30 | return "estimated_time";
31 | }
32 |
33 | @Override
34 | public String parse(Matcher matcher, OfflinePlayer p) {
35 |
36 | if(System.currentTimeMillis() - lastFetch.getOrDefault(p.getUniqueId(), 0L) > 2000) {
37 | lastFetch.put(p.getUniqueId(), System.currentTimeMillis());
38 | plugin.getScheduler().runTaskAsynchronously(() -> {
39 | if(!p.isOnline()) return;
40 | try {
41 | MessagedResponse response = AjQueueSpigotAPI.getInstance()
42 | .getEstimatedTime(p.getUniqueId())
43 | .get(30, TimeUnit.SECONDS);
44 |
45 | cache.put(p.getUniqueId(), response.getEither());
46 | } catch (InterruptedException | ExecutionException e) {
47 | throw new RuntimeException(e);
48 | } catch (TimeoutException | IllegalArgumentException ignored) {}
49 | });
50 | }
51 |
52 | return cache.getOrDefault(p.getUniqueId(), "...");
53 | }
54 |
55 | @Override
56 | public void cleanCache(Player player) {
57 | cache.remove(player.getUniqueId());
58 | lastFetch.remove(player.getUniqueId());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/placeholders/InQueue.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders.placeholders;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
7 | import us.ajg0702.queue.spigot.SpigotMain;
8 | import us.ajg0702.queue.spigot.placeholders.Placeholder;
9 |
10 | import java.util.Map;
11 | import java.util.UUID;
12 | import java.util.concurrent.ConcurrentHashMap;
13 | import java.util.concurrent.ExecutionException;
14 | import java.util.concurrent.TimeUnit;
15 | import java.util.concurrent.TimeoutException;
16 | import java.util.logging.Level;
17 | import java.util.regex.Matcher;
18 |
19 | public class InQueue extends Placeholder {
20 | public InQueue(SpigotMain plugin) {
21 | super(plugin);
22 | }
23 |
24 | private final Map cache = new ConcurrentHashMap<>();
25 | private final Map lastFetch = new ConcurrentHashMap<>();
26 |
27 | @Override
28 | public String getRegex() {
29 | return "inqueue";
30 | }
31 |
32 | @Override
33 | public String parse(Matcher matcher, OfflinePlayer p) {
34 |
35 | if(System.currentTimeMillis() - lastFetch.getOrDefault(p.getUniqueId(), 0L) > 2000) {
36 | lastFetch.put(p.getUniqueId(), System.currentTimeMillis());
37 | plugin.getScheduler().runTaskAsynchronously(() -> {
38 | if(!p.isOnline()) return;
39 | try {
40 | Boolean response = AjQueueSpigotAPI.getInstance()
41 | .isInQueue(p.getUniqueId())
42 | .get(30, TimeUnit.SECONDS);
43 |
44 | cache.put(p.getUniqueId(), response + "");
45 | } catch (InterruptedException | ExecutionException e) {
46 | throw new RuntimeException(e);
47 | } catch (TimeoutException | IllegalArgumentException ignored) {}
48 | });
49 | }
50 |
51 | return cache.getOrDefault(p.getUniqueId(), "...");
52 | }
53 |
54 | @Override
55 | public void cleanCache(Player player) {
56 | cache.remove(player.getUniqueId());
57 | lastFetch.remove(player.getUniqueId());
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/placeholders/Position.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders.placeholders;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
7 | import us.ajg0702.queue.api.spigot.MessagedResponse;
8 | import us.ajg0702.queue.spigot.SpigotMain;
9 | import us.ajg0702.queue.spigot.placeholders.Placeholder;
10 |
11 | import java.util.Map;
12 | import java.util.UUID;
13 | import java.util.concurrent.ConcurrentHashMap;
14 | import java.util.concurrent.ExecutionException;
15 | import java.util.concurrent.TimeUnit;
16 | import java.util.concurrent.TimeoutException;
17 | import java.util.logging.Level;
18 | import java.util.regex.Matcher;
19 |
20 | public class Position extends Placeholder {
21 | public Position(SpigotMain plugin) {
22 | super(plugin);
23 | }
24 |
25 | private final Map cache = new ConcurrentHashMap<>();
26 | private final Map lastFetch = new ConcurrentHashMap<>();
27 |
28 | @Override
29 | public String getRegex() {
30 | return "position";
31 | }
32 |
33 | @Override
34 | public String parse(Matcher matcher, OfflinePlayer p) {
35 |
36 | if(System.currentTimeMillis() - lastFetch.getOrDefault(p.getUniqueId(), 0L) > 2000) {
37 | lastFetch.put(p.getUniqueId(), System.currentTimeMillis());
38 | plugin.getScheduler().runTaskAsynchronously(() -> {
39 | if(!p.isOnline()) return;
40 | try {
41 | MessagedResponse response = AjQueueSpigotAPI.getInstance()
42 | .getPosition(p.getUniqueId())
43 | .get(30, TimeUnit.SECONDS);
44 |
45 | cache.put(p.getUniqueId(), response.getEither());
46 | } catch (InterruptedException | ExecutionException e) {
47 | throw new RuntimeException(e);
48 | } catch (TimeoutException | IllegalArgumentException ignored) {}
49 | });
50 | }
51 |
52 | return cache.getOrDefault(p.getUniqueId(), "...");
53 | }
54 |
55 | @Override
56 | public void cleanCache(Player player) {
57 | cache.remove(player.getUniqueId());
58 | lastFetch.remove(player.getUniqueId());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/placeholders/PositionOf.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders.placeholders;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
7 | import us.ajg0702.queue.api.spigot.MessagedResponse;
8 | import us.ajg0702.queue.spigot.SpigotMain;
9 | import us.ajg0702.queue.spigot.placeholders.Placeholder;
10 |
11 | import java.util.Map;
12 | import java.util.UUID;
13 | import java.util.concurrent.ConcurrentHashMap;
14 | import java.util.concurrent.ExecutionException;
15 | import java.util.concurrent.TimeUnit;
16 | import java.util.concurrent.TimeoutException;
17 | import java.util.logging.Level;
18 | import java.util.regex.Matcher;
19 |
20 | public class PositionOf extends Placeholder {
21 | public PositionOf(SpigotMain plugin) {
22 | super(plugin);
23 | }
24 |
25 | private final Map cache = new ConcurrentHashMap<>();
26 | private final Map lastFetch = new ConcurrentHashMap<>();
27 |
28 | @Override
29 | public String getRegex() {
30 | return "of";
31 | }
32 |
33 | @Override
34 | public String parse(Matcher matcher, OfflinePlayer p) {
35 |
36 | if(System.currentTimeMillis() - lastFetch.getOrDefault(p.getUniqueId(), 0L) > 2000) {
37 | lastFetch.put(p.getUniqueId(), System.currentTimeMillis());
38 | plugin.getScheduler().runTaskAsynchronously(() -> {
39 | if(!p.isOnline()) return;
40 | try {
41 | MessagedResponse response = AjQueueSpigotAPI.getInstance()
42 | .getTotalPositions(p.getUniqueId())
43 | .get(30, TimeUnit.SECONDS);
44 |
45 | cache.put(p.getUniqueId(), response.getEither());
46 | } catch (InterruptedException | ExecutionException e) {
47 | throw new RuntimeException(e);
48 | } catch (TimeoutException | IllegalArgumentException ignored) {}
49 | });
50 | }
51 |
52 | return cache.getOrDefault(p.getUniqueId(), "...");
53 | }
54 |
55 | @Override
56 | public void cleanCache(Player player) {
57 | cache.remove(player.getUniqueId());
58 | cache.remove(player.getUniqueId());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/placeholders/Queued.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders.placeholders;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
7 | import us.ajg0702.queue.api.spigot.MessagedResponse;
8 | import us.ajg0702.queue.spigot.SpigotMain;
9 | import us.ajg0702.queue.spigot.placeholders.Placeholder;
10 |
11 | import java.util.Map;
12 | import java.util.UUID;
13 | import java.util.logging.Level;
14 | import java.util.concurrent.ConcurrentHashMap;
15 | import java.util.concurrent.ExecutionException;
16 | import java.util.concurrent.TimeUnit;
17 | import java.util.concurrent.TimeoutException;
18 | import java.util.regex.Matcher;
19 |
20 | public class Queued extends Placeholder {
21 | public Queued(SpigotMain plugin) {
22 | super(plugin);
23 | }
24 |
25 | private final Map cache = new ConcurrentHashMap<>();
26 | private final Map lastFetch = new ConcurrentHashMap<>();
27 |
28 | @Override
29 | public String getRegex() {
30 | return "queued";
31 | }
32 |
33 | @Override
34 | public String parse(Matcher matcher, OfflinePlayer p) {
35 |
36 | if(System.currentTimeMillis() - lastFetch.getOrDefault(p.getUniqueId(), 0L) > 2000) {
37 | lastFetch.put(p.getUniqueId(), System.currentTimeMillis());
38 | plugin.getScheduler().runTaskAsynchronously(() -> {
39 | if(!p.isOnline()) return;
40 | try {
41 | MessagedResponse response = AjQueueSpigotAPI.getInstance()
42 | .getQueueName(p.getUniqueId())
43 | .get(30, TimeUnit.SECONDS);
44 |
45 | cache.put(p.getUniqueId(), response.getEither());
46 | } catch (InterruptedException | ExecutionException e) {
47 | throw new RuntimeException(e);
48 | } catch (TimeoutException | IllegalArgumentException ignored) {}
49 | });
50 | }
51 |
52 | return cache.getOrDefault(p.getUniqueId(), "...");
53 | }
54 |
55 | @Override
56 | public void cleanCache(Player player) {
57 | cache.remove(player.getUniqueId());
58 | cache.remove(player.getUniqueId());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/placeholders/QueuedFor.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders.placeholders;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
7 | import us.ajg0702.queue.spigot.SpigotMain;
8 | import us.ajg0702.queue.spigot.placeholders.Placeholder;
9 |
10 | import java.util.Map;
11 | import java.util.concurrent.ConcurrentHashMap;
12 | import java.util.concurrent.ExecutionException;
13 | import java.util.concurrent.TimeUnit;
14 | import java.util.concurrent.TimeoutException;
15 | import java.util.logging.Level;
16 | import java.util.regex.Matcher;
17 |
18 | public class QueuedFor extends Placeholder {
19 | public QueuedFor(SpigotMain plugin) {
20 | super(plugin);
21 | }
22 |
23 | private final String invalidMessage = "Invalid queue name";
24 |
25 | private final Map cache = new ConcurrentHashMap<>();
26 | private final Map lastFetch = new ConcurrentHashMap<>();
27 |
28 | @Override
29 | public String getRegex() {
30 | return "queuedfor_(.*)";
31 | }
32 |
33 | @Override
34 | public String parse(Matcher matcher, OfflinePlayer p) {
35 | String queue = matcher.group(1);
36 | String cached = cache.getOrDefault(queue, "...");
37 |
38 | if(System.currentTimeMillis() - lastFetch.getOrDefault(queue, 0L) > 2000) {
39 | lastFetch.put(queue, System.currentTimeMillis());
40 | plugin.getScheduler().runTaskAsynchronously(() -> {
41 | if (!p.isOnline()) return;
42 | try {
43 | Integer response = AjQueueSpigotAPI.getInstance()
44 | .getPlayersInQueue(queue)
45 | .get(30, TimeUnit.SECONDS);
46 |
47 | cache.put(queue, response + "");
48 | } catch (InterruptedException e) {
49 | throw new RuntimeException(e);
50 | } catch (ExecutionException e) {
51 | if (e.getCause() instanceof IllegalArgumentException) {
52 | cache.put(queue, invalidMessage);
53 | } else {
54 | throw new RuntimeException(e);
55 | }
56 | } catch (TimeoutException ignored) {
57 | }
58 | });
59 | }
60 |
61 | return cached;
62 | }
63 |
64 | @Override
65 | public void cleanCache(Player player) {}
66 | }
67 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/placeholders/Status.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders.placeholders;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
7 | import us.ajg0702.queue.spigot.SpigotMain;
8 | import us.ajg0702.queue.spigot.placeholders.Placeholder;
9 |
10 | import java.util.Map;
11 | import java.util.concurrent.ConcurrentHashMap;
12 | import java.util.concurrent.ExecutionException;
13 | import java.util.concurrent.TimeUnit;
14 | import java.util.concurrent.TimeoutException;
15 | import java.util.logging.Level;
16 | import java.util.regex.Matcher;
17 |
18 | public class Status extends Placeholder {
19 | public Status(SpigotMain plugin) {
20 | super(plugin);
21 | }
22 |
23 | private final String invalidMessage = "Invalid queue name";
24 |
25 | private final Map cache = new ConcurrentHashMap<>();
26 | private final Map lastFetch = new ConcurrentHashMap<>();
27 |
28 | @Override
29 | public String getRegex() {
30 | return "status_(.*)";
31 | }
32 |
33 | @Override
34 | public String parse(Matcher matcher, OfflinePlayer p) {
35 | String queue = matcher.group(1);
36 | String cached = cache.getOrDefault(queue, "...");
37 |
38 | if(System.currentTimeMillis() - lastFetch.getOrDefault(queue, 0L) > 2000) {
39 | lastFetch.put(queue, System.currentTimeMillis());
40 |
41 | plugin.getScheduler().runTaskAsynchronously(() -> {
42 | if (!p.isOnline()) return;
43 | try {
44 | String response = AjQueueSpigotAPI.getInstance()
45 | .getServerStatusString(queue)
46 | .get(30, TimeUnit.SECONDS);
47 |
48 | cache.put(queue, response);
49 | } catch (InterruptedException e) {
50 | throw new RuntimeException(e);
51 | } catch (ExecutionException e) {
52 | if (e.getCause() instanceof IllegalArgumentException) {
53 | cache.put(queue, invalidMessage);
54 | } else {
55 | throw new RuntimeException(e);
56 | }
57 | } catch (TimeoutException | IllegalArgumentException ignored) {
58 | }
59 | });
60 | }
61 |
62 | return cached;
63 | }
64 |
65 | @Override
66 | public void cleanCache(Player player) {}
67 | }
68 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/placeholders/placeholders/StatusPlayer.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.placeholders.placeholders;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 | import us.ajg0702.queue.api.spigot.AjQueueSpigotAPI;
7 | import us.ajg0702.queue.api.spigot.MessagedResponse;
8 | import us.ajg0702.queue.spigot.SpigotMain;
9 | import us.ajg0702.queue.spigot.placeholders.Placeholder;
10 | import us.ajg0702.queue.spigot.utils.UUIDStringKey;
11 |
12 | import java.util.Map;
13 | import java.util.UUID;
14 | import java.util.concurrent.ConcurrentHashMap;
15 | import java.util.concurrent.ExecutionException;
16 | import java.util.concurrent.TimeUnit;
17 | import java.util.concurrent.TimeoutException;
18 | import java.util.logging.Level;
19 | import java.util.regex.Matcher;
20 |
21 | public class StatusPlayer extends Placeholder {
22 | public StatusPlayer(SpigotMain plugin) {
23 | super(plugin);
24 | }
25 |
26 | private final Map cache = new ConcurrentHashMap<>();
27 | private final Map lastFetch = new ConcurrentHashMap<>();
28 |
29 | @Override
30 | public String getRegex() {
31 | return "status_(.*)_player";
32 | }
33 |
34 | @Override
35 | public String parse(Matcher matcher, OfflinePlayer p) {
36 | String queue = matcher.group(1);
37 | UUIDStringKey key = new UUIDStringKey(p.getUniqueId(), queue);
38 |
39 | if(!p.isOnline()) return "You aren't online!?!";
40 |
41 | if(System.currentTimeMillis() - lastFetch.getOrDefault(key, 0L) > 2000) {
42 | lastFetch.put(key, System.currentTimeMillis());
43 |
44 | plugin.getScheduler().runTaskAsynchronously(() -> {
45 | if (!p.isOnline()) return;
46 | try {
47 | String response = AjQueueSpigotAPI.getInstance()
48 | .getServerStatusString(queue, p.getUniqueId())
49 | .get(30, TimeUnit.SECONDS);
50 |
51 | cache.put(key, response);
52 | } catch (InterruptedException | ExecutionException e) {
53 | throw new RuntimeException(e);
54 | } catch (TimeoutException | IllegalArgumentException ignored) {
55 | }
56 | });
57 | }
58 |
59 | return cache.getOrDefault(key, "...");
60 | }
61 |
62 | @Override
63 | public void cleanCache(Player player) {
64 | cache.entrySet().removeIf(entry -> entry.getKey().getUuid().equals(player.getUniqueId()));
65 | lastFetch.entrySet().removeIf(entry -> entry.getKey().getUuid().equals(player.getUniqueId()));
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/utils/UUIDStringKey.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.utils;
2 |
3 | import java.util.Objects;
4 | import java.util.UUID;
5 |
6 | public class UUIDStringKey {
7 |
8 | private final UUID uuid;
9 | private final String string;
10 |
11 | public UUIDStringKey(UUID uuid, String string) {
12 | this.uuid = uuid;
13 | this.string = string;
14 | }
15 |
16 | public UUID getUuid() {
17 | return uuid;
18 | }
19 |
20 | public String getString() {
21 | return string;
22 | }
23 |
24 | @Override
25 | public boolean equals(Object o) {
26 | if (this == o) return true;
27 | if (!(o instanceof UUIDStringKey)) return false;
28 | UUIDStringKey that = (UUIDStringKey) o;
29 | return uuid.equals(that.uuid) && string.equals(that.string);
30 | }
31 |
32 | @Override
33 | public int hashCode() {
34 | return Objects.hash(uuid, string);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/spigot/src/main/java/us/ajg0702/queue/spigot/utils/VersionSupport.java:
--------------------------------------------------------------------------------
1 | package us.ajg0702.queue.spigot.utils;
2 |
3 | import net.md_5.bungee.api.ChatMessageType;
4 | import net.md_5.bungee.api.chat.TextComponent;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.entity.Player;
7 |
8 | public class VersionSupport {
9 |
10 | public static String getVersion() {
11 | return Bukkit.getVersion().split("\\(MC: ")[1].split("\\)")[0];
12 | }
13 | public static int getMinorVersion() {
14 | return Integer.parseInt(getVersion().split("\\.")[1]);
15 | }
16 |
17 | /**
18 | * Send the player an actionbar message
19 | * @param ply The {@link org.bukkit.entity.Player Player} to send the actionbar to
20 | * @param message The message to send in the actionbar.
21 | */
22 | public static void sendActionBar(Player ply, String message) {
23 | // Use spigot version if available, otherwise use packets.
24 | if(getMinorVersion() >= 11) {
25 | ply.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
26 | } else if(getMinorVersion() >= 8) {
27 | ActionBar.send(ply, message);
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/spigot/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | main: us.ajg0702.queue.spigot.SpigotMain
2 | version: "@VERSION@"
3 | api-version: 1.13
4 | author: ajgeiss0702
5 | name: ajQueue
6 | folia-supported: true
7 | softdepend: [PlaceholderAPI]
8 | commands:
9 | queue:
10 | aliases: [server, move, joinq, joinqueue]
11 | description: Queue for a server
12 | leavequeue:
13 | aliases: [leaveq]
14 | description: Leaves a queue
--------------------------------------------------------------------------------
/spigot/src/main/resources/spigot-config.yml:
--------------------------------------------------------------------------------
1 | # This is the config for the spigot side.
2 | # You can find more settings in the config of bungee.
3 |
4 |
5 | # Should we send queue requests from commands in batches?
6 | # Enable this if you have issues with players sometimes not executing commands correctly
7 | # Note though that it could delay queue commands by up to 1 second!
8 | send-queue-commands-in-batches: false
9 |
10 | # Should we take over the server MOTD to tell the proxy if the server is whitelisted?
11 | # If you disable this, ajQueue will not be able to tell if the server is whitelisted!
12 | take-over-motd-for-whitelist: true
13 |
14 | # Should we check if the proxy responds to plugin messages?
15 | # For some reason this seems to fail for some people,
16 | # so disable this if ajqueue says its not installed on the proxy when it actually is
17 | check-proxy-response: true
18 |
19 |
20 |
21 | # Dont touch this
22 | config-version: 3
--------------------------------------------------------------------------------
/update.md:
--------------------------------------------------------------------------------
1 | # Update checklist
2 |
3 | This is for me when releasing updates, because otherwise I forget things
4 |
5 | 1. Update version in build.gradle.kts & commit
6 | 2. Create tag for update (e.g. 2.6.0)
7 | 3. Push tag & ver bump commit (ensure to select checkbox to push tag)
8 | 4. Merge dev -> master
9 | 5. Create release (draft release notes in release)
10 | * Use github compare for reference: https://github.com/ajgeiss0702/ajQueue/compare/2.5.0...2.6.0
11 | 6. Double-check release notes
12 | 7. Release ajQueuePlus on Spigot & Polymart (copy-paste release notes from github release)
13 | 8. Release ajQueue (free) on
14 | * Modrinth
15 | * Hangar
16 | * Polymart
17 |
18 | All plugin pages:
19 | - Spigot (+)
20 | - Spigot (free)
21 | - Polymart (+)
22 | - Polymart (free)
23 | - Modrinth (free)
24 | - Hangar (free)
--------------------------------------------------------------------------------