mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-21 18:16:03 +01:00
chore: sync up with the main recode
This commit is contained in:
parent
9030ff5363
commit
a8c2e13900
32
.autorc
32
.autorc
@ -1,32 +0,0 @@
|
||||
{
|
||||
"baseBranch": "spigot",
|
||||
"plugins": [
|
||||
[
|
||||
"gradle",
|
||||
{
|
||||
"gradleCommand": "./gradlew",
|
||||
"gradleOptions": [""]
|
||||
}
|
||||
],
|
||||
[
|
||||
"exec",
|
||||
{
|
||||
"canary": "./gradlew build discord"
|
||||
}
|
||||
],
|
||||
["conventional-commits", { "preset": "angular" }],
|
||||
"released",
|
||||
["upload-assets", ["./build/libs/*.jar"]]
|
||||
],
|
||||
"owner": "sekwah41",
|
||||
"repo": "Advanced-Portals",
|
||||
"name": "Sekwah",
|
||||
"email": "contact@sekwah.com",
|
||||
"onlyPublishWithReleaseLabel": true,
|
||||
"shipit": {
|
||||
"onlyGraduateWithReleaseLabel": true
|
||||
},
|
||||
"canary": {
|
||||
"message": "📦 Published PR to [discord](https://discord.sekwah.com/) as canary version: %v"
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
# What Changed
|
||||
Whatever changed here
|
||||
|
||||
## Release Notes
|
||||
If anything should be commented in the changelog release notes.
|
||||
|
||||
**NOTE:** Please remove this unless something important needs to be shared.
|
||||
It's just to save time looking up what is needed in the event we need to.
|
46
.github/workflows/gradle.yml
vendored
46
.github/workflows/gradle.yml
vendored
@ -1,46 +0,0 @@
|
||||
name: Release
|
||||
|
||||
on: [push, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
restore-keys: ${{ runner.os }}-gradle
|
||||
- name: Cache Node packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
|
||||
restore-keys: ${{ runner.os }}-node
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: 8
|
||||
- name: Use Node.js 18.x
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 18.x
|
||||
- name: Prepare repository
|
||||
run: |
|
||||
git fetch --unshallow --tags
|
||||
yarn install --immutable
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- name: Create Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CURSE_API: ${{ secrets.CURSE_API }}
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
run: |
|
||||
yarn auto shipit
|
||||
|
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,27 +1,18 @@
|
||||
*.class
|
||||
.gradle
|
||||
.idea
|
||||
/build/
|
||||
/target/
|
||||
.gradle/
|
||||
.idea/
|
||||
*/build/
|
||||
|
||||
# Package Files #
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
node_modules/
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
.env
|
||||
out/
|
||||
|
||||
logs/
|
||||
classes/
|
||||
run/
|
||||
|
||||
|
||||
.yarn/*
|
||||
!.yarn/cache
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
894
.yarn/releases/yarn-4.3.1.cjs
vendored
894
.yarn/releases/yarn-4.3.1.cjs
vendored
File diff suppressed because one or more lines are too long
@ -1,3 +0,0 @@
|
||||
nodeLinker: node-modules
|
||||
|
||||
yarnPath: .yarn/releases/yarn-4.3.1.cjs
|
356
CHANGELOG.md
356
CHANGELOG.md
@ -1,356 +0,0 @@
|
||||
# v1.0.0 (Sat Jul 27 2024)
|
||||
|
||||
#### 💥 Breaking Change
|
||||
|
||||
- fix!: disable proxy detection to avoid vulnerabilities (see full commit for more info) [#436](https://github.com/sekwah41/Advanced-Portals/pull/436) ([@sekwah41](https://github.com/sekwah41))
|
||||
- fix: stop portal packets still being forwarded to the client [#436](https://github.com/sekwah41/Advanced-Portals/pull/436) ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
---
|
||||
|
||||
# v0.11.0 (Wed Jul 24 2024)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- FIX: Remove HAS_WARPED Metadata when logging into a new server [#397](https://github.com/sekwah41/Advanced-Portals/pull/397) ([@TreemanKing](https://github.com/TreemanKing))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- [@TreemanKing](https://github.com/TreemanKing)
|
||||
|
||||
---
|
||||
|
||||
# v0.10.1 (Wed Jul 24 2024)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- feat: add custom warp message config (messages.yml) [#388](https://github.com/sekwah41/Advanced-Portals/pull/388) ([@TreemanKing](https://github.com/TreemanKing))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- [@TreemanKing](https://github.com/TreemanKing)
|
||||
|
||||
---
|
||||
|
||||
# v0.10.0 (Wed Jul 17 2024)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- feat: trigger a release for the older version ([@sekwah41](https://github.com/sekwah41))
|
||||
- feat: add multi destination randomisation ([@Galster-dev](https://github.com/Galster-dev))
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore: force changes [#433](https://github.com/sekwah41/Advanced-Portals/pull/433) ([@sekwah41](https://github.com/sekwah41))
|
||||
- feat: add link to re-code progress [#432](https://github.com/sekwah41/Advanced-Portals/pull/432) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore: disable freeze for now ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore: update yarn stuff ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore: try updating auto ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): update actions/setup-java action to v4 [#405](https://github.com/sekwah41/Advanced-Portals/pull/405) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): bump semver from 5.7.1 to 5.7.2 [#425](https://github.com/sekwah41/Advanced-Portals/pull/425) ([@dependabot[bot]](https://github.com/dependabot[bot]))
|
||||
- chore(deps): update actions/cache action to v4 [#409](https://github.com/sekwah41/Advanced-Portals/pull/409) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- fix: something in the old metrics class was triggering certain antivirus [#411](https://github.com/sekwah41/Advanced-Portals/pull/411) ([@sekwah41](https://github.com/sekwah41))
|
||||
- style: Fix Typo [#396](https://github.com/sekwah41/Advanced-Portals/pull/396) ([@TreemanKing](https://github.com/TreemanKing))
|
||||
- fix: Add Selector Alias (Wand) in Help Message [#387](https://github.com/sekwah41/Advanced-Portals/pull/387) ([@TreemanKing](https://github.com/TreemanKing))
|
||||
- fix: add author for velocity plugin [#386](https://github.com/sekwah41/Advanced-Portals/pull/386) ([@TreemanKing](https://github.com/TreemanKing))
|
||||
- Point to documentation in README [#369](https://github.com/sekwah41/Advanced-Portals/pull/369) ([@omentic](https://github.com/omentic))
|
||||
- chore(deps): Update Deps to v10.45.0 [#364](https://github.com/sekwah41/Advanced-Portals/pull/364) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps [#361](https://github.com/sekwah41/Advanced-Portals/pull/361) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.14 [#359](https://github.com/sekwah41/Advanced-Portals/pull/359) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.90.Final [#358](https://github.com/sekwah41/Advanced-Portals/pull/358) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps to v10.43.0 [#353](https://github.com/sekwah41/Advanced-Portals/pull/353) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps [#352](https://github.com/sekwah41/Advanced-Portals/pull/352) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.89.Final [#351](https://github.com/sekwah41/Advanced-Portals/pull/351) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.88.Final [#349](https://github.com/sekwah41/Advanced-Portals/pull/349) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps to v10.42.0 [#348](https://github.com/sekwah41/Advanced-Portals/pull/348) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps to v10.38.5 [#347](https://github.com/sekwah41/Advanced-Portals/pull/347) ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
|
||||
#### Authors: 6
|
||||
|
||||
- [@dependabot[bot]](https://github.com/dependabot[bot])
|
||||
- [@Galster-dev](https://github.com/Galster-dev)
|
||||
- [@renovate[bot]](https://github.com/renovate[bot])
|
||||
- [@TreemanKing](https://github.com/TreemanKing)
|
||||
- JJ ([@omentic](https://github.com/omentic))
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.3 (Sat Jan 21 2023)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore: small readme change to force an update [#344](https://github.com/sekwah41/Advanced-Portals/pull/344) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore: switch base branch ([@sekwah41](https://github.com/sekwah41))
|
||||
- fix: detect new velocity setting location [#343](https://github.com/sekwah41/Advanced-Portals/pull/343) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore: add mc task for easier running [#343](https://github.com/sekwah41/Advanced-Portals/pull/343) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.80.Final ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.12 ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.11 ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps to v10.37.4 ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.78.Final ([@renovate[bot]](https://github.com/renovate[bot]))
|
||||
- chore(deps): Update Deps to v10.37.1 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.37.0 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.77.Final ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.76.Final ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency gradle to v7.4.2 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.36.5 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.34.1 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.34.0 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.33.1 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): update actions/setup-java action to v3 [#322](https://github.com/sekwah41/Advanced-Portals/pull/322) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 3
|
||||
|
||||
- [@renovate[bot]](https://github.com/renovate[bot])
|
||||
- Mend Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.2 (Thu Feb 24 2022)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- fix: Removes the false positive warning from McAntiMalware [#318](https://github.com/sekwah41/Advanced-Portals/pull/318) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.9 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps [#316](https://github.com/sekwah41/Advanced-Portals/pull/316) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency gradle to v7.3.3 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.1 (Fri Dec 17 2021)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- fix: Error in position checks for portal creation [#310](https://github.com/sekwah41/Advanced-Portals/pull/310) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Update release support flags ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.0 (Wed Dec 15 2021)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- feat: WorldEdit Integration, fix logic error [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
|
||||
- feat: Added WorldEdit Integration [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
|
||||
- feat: Adds ability to configure warp message [#302](https://github.com/sekwah41/Advanced-Portals/pull/302) ([@maldahleh](https://github.com/maldahleh))
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore(deps): Update Velocity to 3.1.0 [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
|
||||
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency gradle to v7.3.1 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- docs: Update changelog ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Allow manual triggering ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): Update Deps to v10.32.3 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency gradle to v7.3 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.70.Final ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(ci): Update to list 1.17 as supported automatically ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.69.Final ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.32.1 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.32.0 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency com.velocitypowered:velocity-api to v1.1.9 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 4
|
||||
|
||||
- [@JOO200](https://github.com/JOO200)
|
||||
- Mohammed Al-Dahleh ([@maldahleh](https://github.com/maldahleh))
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.8.0 (Wed Sep 01 2021)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- feat: Allow the ability to disable the proxy warning message [#292](https://github.com/sekwah41/Advanced-Portals/pull/292) ([@maldahleh](https://github.com/maldahleh))
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(ci): Update rennovate config ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Mohammed Al-Dahleh ([@maldahleh](https://github.com/maldahleh))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.7.2 (Wed Jul 14 2021)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- fix: Issue where portal events activate too early in survival [#280](https://github.com/sekwah41/Advanced-Portals/pull/280) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): update dependency com.velocitypowered:velocity-api to v1.1.9 [#278](https://github.com/sekwah41/Advanced-Portals/pull/278) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): update dependency gradle to v7.1.1 [#277](https://github.com/sekwah41/Advanced-Portals/pull/277) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.7.1 (Wed Jun 30 2021)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- fix: Access to portal warp command locked behind wrong perm [#275](https://github.com/sekwah41/Advanced-Portals/pull/275) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): update dependency gradle to v7 [#271](https://github.com/sekwah41/Advanced-Portals/pull/271) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.7.0 (Sun Jun 27 2021)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- feat: Added missing commands from tab complete [#270](https://github.com/sekwah41/Advanced-Portals/pull/270) ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore(deps): update dependency net.md-5:bungeecord-api to v1.16-r0.4 [#269](https://github.com/sekwah41/Advanced-Portals/pull/269) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(ci): removed verbose mode for release ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): update dependency com.google.code.gson:gson to v2.8.7 [#262](https://github.com/sekwah41/Advanced-Portals/pull/262) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): update dependency gradle to v6.9 [#267](https://github.com/sekwah41/Advanced-Portals/pull/267) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): update dependency com.velocitypowered:velocity-api to v1.1.8 [#266](https://github.com/sekwah41/Advanced-Portals/pull/266) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.6.1 (Sun Jun 27 2021)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore(ci): Remove isDevBranch remains [#265](https://github.com/sekwah41/Advanced-Portals/pull/265) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Fix forgotten sha in build gradle [#264](https://github.com/sekwah41/Advanced-Portals/pull/264) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Update version-bumping task order [#263](https://github.com/sekwah41/Advanced-Portals/pull/263) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): pin dependencies [#261](https://github.com/sekwah41/Advanced-Portals/pull/261) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- fix: Spigot 1.17 error message [#260](https://github.com/sekwah41/Advanced-Portals/pull/260) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Swapping build pipeline ([@sekwah41](https://github.com/sekwah41))
|
||||
- ci: Fixed java version ([@sekwah41](https://github.com/sekwah41))
|
||||
- ci: Fix changelog reference ([@sekwah41](https://github.com/sekwah41))
|
||||
- ci: Updated build pipelines to newer module ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
For the release changelogs see [CHANGELOG.md](CHANGELOG.md)
|
||||
For the snapshot changelogs see [SNAPSHOT_CHANGELOG.md](SNAPSHOT_CHANGELOG.md)
|
||||
|
||||
## 0.6.0 (2021-05-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **proxy:** Added a ForceEnableProxySupport config option ([99c810e](https://github.com/sekwah41/Advanced-Portals/commit/99c810e1beeee743734ec451ffe5df312eec8726))
|
||||
* **proxy:** Added Velocity support ([b243b4d](https://github.com/sekwah41/Advanced-Portals/commit/b243b4d889b8039cb800d981d44d85da06ff62d5))
|
||||
* **proxy:** Modern forwarding will be automatically detected. ([f3c8f73](https://github.com/sekwah41/Advanced-Portals/commit/f3c8f73975857a4e5d31a6a21111eee8b7888bdd))
|
||||
* Added configurable proxy teleport delay ([a1121ad](https://github.com/sekwah41/Advanced-Portals/commit/a1121adc10addfcce515d1358d1274232109fdfd))
|
||||
|
||||
### 0.5.12
|
||||
|
||||
* Added support for Velocity.
|
||||
* Also fixed some issues with entity teleporting.
|
||||
|
||||
### 0.5.11
|
||||
|
||||
* Missing changelogs
|
||||
|
||||
### 0.5.10
|
||||
|
||||
* Missing changelogs
|
||||
|
||||
### 0.5.10
|
||||
|
||||
* Added fix for command portals spam triggering if they didn't teleport you out.
|
||||
* Made portals not activate if you were teleported into them by another portal (to allow linking zones like a star trek warp pad)
|
||||
|
||||
### 0.5.9
|
||||
|
||||
* Missing changelogs
|
||||
|
||||
### 0.5.8
|
||||
|
||||
* Missing changelogs
|
||||
|
||||
### 0.5.7
|
||||
|
||||
|
||||
* Extra checks added by @tmantti to fix slow connections to new servers from activating the destination location too quick.
|
||||
|
||||
### 0.5.6
|
||||
* Fixed packet exploit affecting destinations (only effecting versions 0.5.0 to 0.5.5).
|
||||
|
||||
### 0.5.5
|
||||
* Added support for 1.16
|
||||
* Reworked chat menus to better use Spigot API
|
||||
* Changed edit menu to have Activate instead of Teleport to destination
|
||||
* Compat code changed. You must now use Spigot rather than CraftBukkit.
|
||||
|
||||
### 0.5.4
|
||||
* Added bungee backup methods to ensure bungee and desti work correctly together
|
||||
* Fixed protection region issue
|
||||
* Reworked the warp command and fixed the surrounding permissions
|
||||
* Disabling gateway beams is now enabled for placing the blocks as well as by a few other means
|
||||
|
||||
### 0.5.3
|
||||
|
||||
* Fixed destination bug.
|
||||
|
||||
### 0.5.2
|
||||
|
||||
* Fixed issue with bungee destinations.
|
||||
|
||||
### 0.5.1
|
||||
|
||||
* Fixed warp permission info
|
||||
|
||||
### 0.5.0
|
||||
|
||||
* Added command:
|
||||
* Fix for bungee warps
|
||||
|
||||
### 0.4.0
|
||||
|
||||
* Individual portal cooldown added
|
||||
* Bungee improvements
|
||||
|
||||
### Earlier
|
||||
|
||||
* See github releases and spigot pages for more info.
|
@ -1,7 +1,7 @@
|
||||
REM Use this file for testing cases for different versions, just drag the version you want to test the plugin in and it will start.
|
||||
@ECHO OFF
|
||||
:A
|
||||
java -Xmx4096M -DIReallyKnowWhatIAmDoingISwear=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar %1
|
||||
java -Xmx4096M -DIReallyKnowWhatIAmDoingISwear=true -jar %1
|
||||
REM Could add a 32 bit test part but noone uses 32 bit anymore
|
||||
GOTO A
|
||||
PAUSE
|
||||
PAUSE.
|
||||
|
180
LICENSE.md
180
LICENSE.md
@ -1,63 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
4. Combined Works.
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
d) Do one of the following:
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
5. Combined Libraries.
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
4. Combined Works.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
69
README.md
69
README.md
@ -1,44 +1,8 @@
|
||||
![Advanced Portals](https://i.imgur.com/UIF6cQR.png)
|
||||
![Advanced portals](https://i.imgur.com/UIF6cQR.png)
|
||||
|
||||
[![Discord](https://img.shields.io/discord/168282484037910528.svg?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/fAJ3xJg)
|
||||
[![](https://img.shields.io/github/contributors/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/graphs/contributors)
|
||||
[![](https://img.shields.io/github/issues/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/issues)
|
||||
[![](https://img.shields.io/github/issues-pr/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/pulls)
|
||||
[![](https://img.shields.io/github/forks/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/network/members)
|
||||
[![](https://img.shields.io/github/stars/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/stargazers)
|
||||
[![](https://img.shields.io/github/license/sekwah41/Advanced-Portals.svg?logo=github&style=for-the-badge)](https://github.com/sekwah41/Advanced-Portals/blob/master/LICENSE.md)
|
||||
Need to write a new readme for this.
|
||||
|
||||
Advanced Portals
|
||||
==============
|
||||
An advanced portals plugin for bukkit made by sekwah41 designed to have a wide range of features which are easy to use. It adds a bunch of commands to create and edit portals and destinations. This plugin not only enable normal teleportation but also cross server teleportation for networks using bungee.
|
||||
|
||||
The recode is actively being worked on and should be available relatively soon.
|
||||
https://github.com/sekwah41/Advanced-Portals/issues/360
|
||||
|
||||
# Usage
|
||||
|
||||
Check out the [Tutorial](https://advancedportals.sekwah.com/docs/intro), [List of Commands](https://advancedportals.sekwah.com/docs/commands), and [List of Portal Tags](https://advancedportals.sekwah.com/docs/portal-tags).
|
||||
|
||||
# Download
|
||||
|
||||
- [Bukkit](https://dev.bukkit.org/projects/advanced-portals)
|
||||
- [Spigot](https://www.spigotmc.org/resources/advanced-portals.14356/)
|
||||
- [Curseforge](https://www.curseforge.com/minecraft/bukkit-plugins/advanced-portals)
|
||||
- [Modrinth](https://modrinth.com/plugin/advanced-portals)
|
||||
- [Github](https://github.com/sekwah41/Advanced-Portals/releases)
|
||||
|
||||
# Recode
|
||||
|
||||
We are currently slowly working on a complete re-code of the plugin with a full API.
|
||||
For now maintaining the current 1.13+ spigot versions is our main priority.
|
||||
|
||||
# Usage Data
|
||||
|
||||
Usage stats can be found here https://bstats.org/plugin/bukkit/AdvancedPortals
|
||||
|
||||
# API
|
||||
|
||||
The api isn't implemented in this version, sorry for any inconvenience. Check the recode tree for possibly a working recode at some point.
|
||||
Also I will set up release please to work with the below types for pretty changelogs.
|
||||
|
||||
The re-code is based off a mix of the original version, and the original re-code that was abandoned [see here](https://github.com/sekwah41/Advanced-Portals/tree/recode/src/main/java/com/sekwah/advancedportals).
|
||||
|
||||
@ -47,10 +11,6 @@ Part of this are currently a mess in terms of package organising, though any API
|
||||
The goal of this rewrite is to make it easier to port to other platforms as well as add extra tags.
|
||||
|
||||
# Contributing
|
||||
|
||||
Don't worry about updating the file numbers in `bungee.yml`, `plugin.yml` and `AdvancedPortalsPlugin.java`.
|
||||
They will be updated automatically before builds.
|
||||
|
||||
Please ensure that your commits are in the following style for PR's
|
||||
|
||||
https://www.conventionalcommits.org/en/v1.0.0/
|
||||
@ -58,29 +18,6 @@ https://www.conventionalcommits.org/en/v1.0.0/
|
||||
Also if you could, please run `pre-commit run --files ...` or `pre-commit run --all-files` to ensure that the code is formatted correctly.
|
||||
You will need to have clang-format installed for this to work.
|
||||
|
||||
## Types available
|
||||
* **build**: Changes that affect the build system or external dependencies
|
||||
* **ci**: Changes to our CI configuration files and scripts
|
||||
* **docs**: Documentation only changes
|
||||
* **feat**: A new feature
|
||||
* **fix**: A bug fix
|
||||
* **perf**: A code change that improves performance
|
||||
* **refactor**: A code change that neither fixes a bug nor adds a feature
|
||||
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
|
||||
<!---
|
||||
We don't currently do tests. But in case.
|
||||
* **test**: Adding missing tests or correcting existing tests
|
||||
-->
|
||||
|
||||
## Scopes available
|
||||
Scopes are only needed if relating to specific features just to make them easier to find.
|
||||
_I'll expand the list as I work more on the project._
|
||||
* **proxy** (Proxy specific features and issues)
|
||||
|
||||
https://www.conventionalcommits.org/en/v1.0.0/
|
||||
|
||||
Accepted tags mostly follow the Angular style and are meant to only loosely be followed.
|
||||
When commits close an issue refer in the commit description in the following style (Refs #1, #2, #3)
|
||||
## Types available
|
||||
* **build**: Changes that affect the build system or external dependencies
|
||||
* **ci**: Changes to our CI configuration files and scripts
|
||||
|
@ -1,51 +0,0 @@
|
||||
main: com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 1.0.0
|
||||
author: sekwah41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
commands:
|
||||
portal:
|
||||
description: The main command for the advanced portals
|
||||
aliases: [portals, aportals, advancedportals]
|
||||
usage: /<command>
|
||||
destination:
|
||||
description: Can be used to access portal destinations.
|
||||
aliases: [desti]
|
||||
usage: /<command>
|
||||
permissions:
|
||||
advancedportals.*:
|
||||
description: Gives access to all commands
|
||||
default: op
|
||||
children:
|
||||
advancedportals.createportal: true
|
||||
advancedportals.portal: true
|
||||
advancedportals.build: true
|
||||
advancedportals.desti: true
|
||||
advancedportals.createportal:
|
||||
description: Allows you to create portals
|
||||
default: op
|
||||
advancedportals.createportal.commandlevel.*:
|
||||
description: Gives access to all level raisers
|
||||
default: false
|
||||
children:
|
||||
advancedportals.createportal.commandlevel.op: true
|
||||
advancedportals.createportal.commandlevel.perms: true
|
||||
advancedportals.createportal.commandlevel.console: true
|
||||
advancedportals.createportal.commandlevel.op:
|
||||
description: Allows you to increase the users level temporaily to op
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.perms:
|
||||
description: Allows you to increase the users level temporaily to have all perms
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.console:
|
||||
description: Executes command in the console
|
||||
default: false
|
||||
advancedportals.portal:
|
||||
description: Allows use of portal commands
|
||||
default: op
|
||||
advancedportals.build:
|
||||
description: Allows you to build in the portal regions
|
||||
default: op
|
||||
advancedportals.desti:
|
||||
description: Gives access to all desti commands
|
||||
default: op
|
428
build.gradle
428
build.gradle
@ -1,57 +1,9 @@
|
||||
import com.google.gson.Gson
|
||||
import org.apache.commons.codec.Charsets
|
||||
import org.apache.http.HttpEntity
|
||||
import org.apache.http.HttpResponse
|
||||
import org.apache.http.client.HttpClient
|
||||
import org.apache.http.client.config.CookieSpecs
|
||||
import org.apache.http.client.config.RequestConfig
|
||||
import org.apache.http.client.methods.CloseableHttpResponse
|
||||
import org.apache.http.client.methods.HttpGet
|
||||
import org.apache.http.client.methods.HttpPost
|
||||
import org.apache.http.entity.ContentType
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder
|
||||
import org.apache.http.impl.client.CloseableHttpClient
|
||||
import org.apache.http.impl.client.HttpClientBuilder
|
||||
import org.apache.http.impl.client.HttpClients
|
||||
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.nio.file.StandardOpenOption
|
||||
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.apache.httpcomponents:httpmime:4.5.14"
|
||||
classpath "com.google.code.gson:gson:2.10.1"
|
||||
classpath "org.apache.httpcomponents:httpclient:4.5.14"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'dev.s7a.gradle.minecraft.server' version '1.2.0'
|
||||
id 'net.researchgate.release' version '2.8.1'
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'idea'
|
||||
|
||||
def branch = System.getenv("GITHUB_REF");
|
||||
if (branch != null) {
|
||||
branch = branch.replace('refs/heads/', '')
|
||||
}
|
||||
def isCanary = version.toString().contains('canary')
|
||||
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {url "https://plugins.gradle.org/m2/"}
|
||||
@ -101,26 +53,12 @@ apply from: 'env-variables.gradle'
|
||||
|
||||
archivesBaseName = "Advanced-Portals"
|
||||
group = 'com.sekwah.advancedportals'
|
||||
def versionString = (file('./version.txt').text + (isRelease ? "" : "-${snapshotName}${shaRef}")).replaceAll('\n', '').replaceAll('\r', '')
|
||||
setVersion(versionString)
|
||||
println "Version: ${getVersion()}"
|
||||
|
||||
description = ""
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
String getPluginData(String tag) {
|
||||
File file = file("src/main/resources/plugin.yml")
|
||||
String version = "notfound"
|
||||
file.readLines("UTF-8").each { String line ->
|
||||
line = line.trim()
|
||||
if (line.startsWith(tag)) {
|
||||
version = line.substring(tag.length() + 2, line.length())
|
||||
}
|
||||
}
|
||||
println "Advanced Portals v" + version
|
||||
return version
|
||||
}
|
||||
|
||||
configurations {
|
||||
// configuration that holds jars to copy into lib
|
||||
implementation.extendsFrom(includeLibs)
|
||||
@ -131,68 +69,29 @@ repositories {
|
||||
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
maven { url "https://nexus.velocitypowered.com/repository/maven-public/" }
|
||||
maven { url 'https://papermc.io/repo/repository/maven-public/' }
|
||||
maven { url 'https://maven.enginehub.org/repo/' } // WorldEdit
|
||||
}
|
||||
|
||||
minecraft {
|
||||
}
|
||||
|
||||
// includeLibs just says to include the library in the final jar
|
||||
dependencies {
|
||||
|
||||
//implementation "org.bukkit:bukkit:1.16.1-R0.1-SNAPSHOT"
|
||||
implementation "org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT"
|
||||
implementation "net.md-5:bungeecord-api:1.16-R0.4"
|
||||
|
||||
implementation "com.velocitypowered:velocity-api:3.1.1"
|
||||
annotationProcessor "com.velocitypowered:velocity-api:3.1.1"
|
||||
|
||||
implementation "io.netty:netty-all:4.1.91.Final"
|
||||
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
||||
|
||||
implementation "com.sk89q.worldedit:worldedit-bukkit:7.2.14"
|
||||
//compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
includeLibs project(':lang')
|
||||
includeLibs project(':core')
|
||||
includeLibs project(':bungee')
|
||||
includeLibs project(':spigot')
|
||||
includeLibs project(':velocity')
|
||||
}
|
||||
|
||||
/** For pre-releases and testers to be able to try the latest commits if they want.
|
||||
* If the builds start exceeding 8MB then we may want to upload to s3 instead and periodically clear.
|
||||
* TODO possibly add a task that announces when builds are made?
|
||||
* Though add a note that it may take a while for Curse to approve the files.
|
||||
*/
|
||||
task discordupload {
|
||||
dependsOn(jar)
|
||||
doLast {
|
||||
String discordWebhook = System.getenv("DISCORD_WEBHOOK")
|
||||
apply from: 'env-variables.gradle'
|
||||
|
||||
if (discordWebhook != null) {
|
||||
println("Logging Into Discord")
|
||||
println "Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'"
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault()
|
||||
HttpPost uploadFile = new HttpPost(discordWebhook)
|
||||
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create()
|
||||
|
||||
if (isCanary) {
|
||||
builder.addTextBody("content", "New canary Build")
|
||||
} else {
|
||||
builder.addTextBody("content", "New release build\n\n" +
|
||||
"Current Features: <${project.github}/blob/${branch}/CHANGELOG.md>")
|
||||
}
|
||||
|
||||
builder.addBinaryBody("file", file(jar.archiveFile).newInputStream(), ContentType.APPLICATION_OCTET_STREAM, jar.archiveName)
|
||||
|
||||
HttpEntity multipart = builder.build()
|
||||
|
||||
uploadFile.setEntity(multipart)
|
||||
CloseableHttpResponse response = httpClient.execute(uploadFile)
|
||||
response.getEntity()
|
||||
|
||||
println("Posted build")
|
||||
|
||||
} else {
|
||||
println("Discord webhook unspecified")
|
||||
}
|
||||
jar {
|
||||
// Filters the files out that are in the build folders. Look to see if there is a better way to do this?
|
||||
from configurations.includeLibs.filter {
|
||||
it.path.contains("${File.separator}build${File.separator}libs")
|
||||
} .collect {
|
||||
println("Will Include: ${it.name}")
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
}
|
||||
|
||||
}
|
||||
@ -262,197 +161,10 @@ tasks.register('copyPlugin') {
|
||||
}
|
||||
}
|
||||
|
||||
minecraftServerConfig {
|
||||
//jarUrl.set('https://download.getbukkit.org/spigot/spigot-1.19.3.jar')
|
||||
jarUrl.set('https://api.papermc.io/v2/projects/paper/versions/1.19.3/builds/381/downloads/paper-1.19.3-381.jar')
|
||||
jvmArgument = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
|
||||
}
|
||||
|
||||
|
||||
String getValueFromCurseAPI(apiKey, endpoint) {
|
||||
String API_BASE_URL = 'https://minecraft.curseforge.com'
|
||||
|
||||
Gson gson = new Gson()
|
||||
|
||||
HttpClient client = HttpClientBuilder.create()
|
||||
.setDefaultRequestConfig(RequestConfig.custom()
|
||||
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build()).build()
|
||||
|
||||
HttpGet get = new HttpGet(API_BASE_URL + endpoint)
|
||||
get.setHeader('X-Api-Token', apiKey)
|
||||
|
||||
HttpResponse response = client.execute(get)
|
||||
|
||||
int statusCode = response.statusLine.statusCode
|
||||
|
||||
if (statusCode == 200) {
|
||||
byte[] data = response.entity.content.bytes
|
||||
return new String(data, Charsets.UTF_8)
|
||||
} else {
|
||||
if (response.getFirstHeader('content-type').value.contains('json')) {
|
||||
InputStreamReader reader = new InputStreamReader(response.entity.content)
|
||||
reader.close()
|
||||
throw new RuntimeException("[CurseForge] Error")
|
||||
} else {
|
||||
throw new RuntimeException("[CurseForge] HTTP Error Code $response.statusLine.statusCode: $response.statusLine.reasonPhrase")
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a single file (in case you also want to upload the other files like source n stuff)
|
||||
* @param json
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
UploadResponse uploadFile(Metadata metadata, File file, String apiKey, Gson gson) throws IOException, URISyntaxException {
|
||||
String API_BASE_URL = 'https://minecraft.curseforge.com'
|
||||
String UPLOAD_URL = "/api/projects/%s/upload-file"
|
||||
// Upload
|
||||
// Important info
|
||||
String uploadUrl = String.format(API_BASE_URL + UPLOAD_URL, project.curse_project_id)
|
||||
|
||||
HttpClient client = HttpClientBuilder.create()
|
||||
.setDefaultRequestConfig(RequestConfig.custom()
|
||||
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build()).build()
|
||||
|
||||
HttpPost post = new HttpPost(uploadUrl)
|
||||
post.setHeader('X-Api-Token', apiKey)
|
||||
|
||||
|
||||
// https://support.curseforge.com/en/support/solutions/articles/9000197321-curseforge-api
|
||||
post.setEntity(MultipartEntityBuilder.create()
|
||||
.addTextBody('metadata', gson.toJson(metadata), ContentType.APPLICATION_JSON)
|
||||
.addBinaryBody('file', file)
|
||||
.build())
|
||||
|
||||
HttpResponse response = client.execute(post)
|
||||
InputStreamReader reader = new InputStreamReader(response.entity.content)
|
||||
UploadResponse uploadResponse = gson.fromJson(reader, UploadResponse)
|
||||
reader.close()
|
||||
return uploadResponse
|
||||
}
|
||||
|
||||
class GameVersion {
|
||||
int id
|
||||
int gameVersionTypeID
|
||||
String name
|
||||
String slug
|
||||
}
|
||||
|
||||
/**
|
||||
* As described here https://support.curseforge.com/en/support/solutions/articles/9000197321-curseforge-api
|
||||
*/
|
||||
class Metadata {
|
||||
String changelog
|
||||
String changelogType
|
||||
int[] gameVersions
|
||||
String releaseType
|
||||
}
|
||||
|
||||
class UploadResponse {
|
||||
int id;
|
||||
}
|
||||
|
||||
|
||||
// Based on https://github.com/matthewprenger/CurseGradle as it didnt support Bukkit uploads at the time.
|
||||
task curseforge {
|
||||
dependsOn(jar)
|
||||
doLast {
|
||||
String apiKey = null
|
||||
|
||||
if (System.getenv("CURSE_API") != null) {
|
||||
apiKey = System.getenv("CURSE_API")
|
||||
}
|
||||
|
||||
if (apiKey != null) {
|
||||
|
||||
Gson gson = new Gson()
|
||||
|
||||
//String VERSION_TYPES_URL = "/api/game/version-types"
|
||||
int gameVersionTypeID = 1
|
||||
String VERSION_URL = "/api/game/versions"
|
||||
println("Uploading to CurseForge")
|
||||
|
||||
// Get game versions
|
||||
String gameVersionsString = getValueFromCurseAPI(apiKey, VERSION_URL)
|
||||
GameVersion[] gameVersions = gson.fromJson(gameVersionsString, GameVersion[].class)
|
||||
def versions = gameVersions.findAll { it.gameVersionTypeID == gameVersionTypeID }
|
||||
|
||||
String[] supportedVersions = [
|
||||
"1.18",
|
||||
"1.17",
|
||||
"1.16",
|
||||
"1.15",
|
||||
"1.14",
|
||||
"1.13"
|
||||
]
|
||||
|
||||
def supportedGameVersions = versions.findAll { supportedVersions.contains(it.name) }
|
||||
int[] supportedGameVersionIds = supportedGameVersions.collect { it.id }.toArray()
|
||||
|
||||
println("Supported Version Id's ${supportedGameVersionIds}")
|
||||
|
||||
Metadata uploadMetadata = new Metadata();
|
||||
|
||||
uploadMetadata.changelog = "${project.github}/blob/${branch}/CHANGELOG.md"
|
||||
uploadMetadata.changelogType = "markdown"
|
||||
uploadMetadata.releaseType = "release"
|
||||
uploadMetadata.gameVersions = supportedGameVersionIds
|
||||
|
||||
def uploadId = uploadFile(uploadMetadata, file(jar.archiveFile), apiKey, gson)
|
||||
|
||||
println("Uploaded with ID: ${uploadId.id}")
|
||||
|
||||
println("Published build")
|
||||
|
||||
} else {
|
||||
println("Discord webhook unspecified")
|
||||
}
|
||||
}
|
||||
// id = project.curse_project_id
|
||||
// // TODO add code to reference this but also cut the latest change logs in for the files
|
||||
// changelogType = 'markdown'
|
||||
// releaseType = 'release'
|
||||
}
|
||||
|
||||
/**
|
||||
* Will build then copy it to the minecraft server folder for use with the launch task and dev tools plugin
|
||||
*/
|
||||
tasks.register('copyPlugin') {
|
||||
dependsOn(build)
|
||||
doLast {
|
||||
copy {
|
||||
def sourceFilePath = Paths.get("$buildDir/libs/Advanced-Portals-${getVersion()}.jar")
|
||||
def destinationFilePath = Paths.get("$buildDir/MinecraftServer/plugins/Advanced-Portals.jar")
|
||||
|
||||
println "Handling file: $destinationFilePath"
|
||||
|
||||
byte[] newContent = Files.readAllBytes(sourceFilePath)
|
||||
|
||||
if (Files.exists(destinationFilePath)) {
|
||||
println "File exists. Overwriting with new binary content."
|
||||
|
||||
Files.write(destinationFilePath, newContent, StandardOpenOption.TRUNCATE_EXISTING)
|
||||
} else {
|
||||
println "File does not exist. Copying from source."
|
||||
|
||||
Files.copy(sourceFilePath, destinationFilePath, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set SPIGOT_LOC to the location of your server and SPIGOT_JAR as the name of the jar file in the server you want to run
|
||||
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
|
||||
task runJar() {
|
||||
tasks.register('runJar') {
|
||||
doLast {
|
||||
if (System.env.MC_SERVER_LOC == null || System.env.MC_SERVER_JAR == null) {
|
||||
throw new Exception('You must set the server location and jar to use MC_SERVER_LOC and MC_SERVER_JAR')
|
||||
}
|
||||
javaexec {
|
||||
main "-jar"
|
||||
args "${System.env.MC_SERVER_LOC}\\${System.env.MC_SERVER_JAR}.jar"
|
||||
@ -462,101 +174,13 @@ task runJar() {
|
||||
}
|
||||
}
|
||||
|
||||
task publish {
|
||||
doLast {
|
||||
println "This is a dummy task to run others for version: ${version}"
|
||||
|
||||
idea {
|
||||
project {
|
||||
settings {
|
||||
taskTriggers {
|
||||
afterSync(project(':core').tasks.named('generateTemplates'))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/researchgate/gradle-release
|
||||
// Only other plugin I can find using auto & gradle https://github.com/intuit/hooks
|
||||
release {
|
||||
failOnPublishNeeded = false
|
||||
failOnSnapshotDependencies = false
|
||||
git {
|
||||
requireBranch = ''
|
||||
}
|
||||
|
||||
|
||||
// Disable tasks because something we have is causing -x to be ignored
|
||||
createReleaseTag.enabled = false
|
||||
preTagCommit.enabled = false
|
||||
commitNewVersion.enabled = false
|
||||
}
|
||||
|
||||
task cleanbuildfolder {
|
||||
doFirst {
|
||||
println "Cleaning up previous builds (to stop publishing old ones by mistake)"
|
||||
project.delete(files("${buildDir}/libs"))
|
||||
}
|
||||
}
|
||||
|
||||
void updateFileVersion(String fileLoc, Pattern pattern, Closure<String> stringClosure) {
|
||||
File file = new File(projectDir, fileLoc)
|
||||
Matcher m = pattern.matcher(file.text)
|
||||
if (m.find()) {
|
||||
def newVersion = stringClosure.call(m)
|
||||
println "Replacing ${pattern.toString()} in ${fileLoc} with '${newVersion}'"
|
||||
file.text = file.text.replaceAll(pattern, newVersion)
|
||||
}
|
||||
}
|
||||
|
||||
// Just to keep all numbers the same (as they are dotted all over the place)
|
||||
task updateVersionNumbers {
|
||||
doFirst {
|
||||
def versionRegex = ~/(\nversion:\s)([0-9.-]+)/
|
||||
def velocityVersionRegex = ~/(\sversion\s=\s")([0-9.-]+)("\))/
|
||||
|
||||
updateFileVersion("src/main/resources/bungee.yml", versionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}"
|
||||
})
|
||||
|
||||
updateFileVersion("src/main/resources/plugin.yml", versionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}"
|
||||
})
|
||||
|
||||
updateFileVersion("src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsPlugin.java",
|
||||
velocityVersionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}${m.group(3)}"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
updateVersion.finalizedBy 'updateVersionNumbers'
|
||||
|
||||
compileJava.dependsOn 'cleanbuildfolder'
|
||||
|
||||
// Publish rules
|
||||
// Current behavior seems to be canary or release. Though pre-releases may break this pattern.
|
||||
publish.dependsOn 'build'
|
||||
publish.finalizedBy 'discordupload'
|
||||
if (!isCanary) {
|
||||
publish.finalizedBy 'curseforge'
|
||||
}
|
||||
|
||||
jar {
|
||||
from configurations.includeLibs.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
|
||||
jar {
|
||||
from configurations.includeLibs.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
|
||||
jar {
|
||||
from configurations.includeLibs.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
|
||||
// Set SPIGOT_LOC to the location of your server and SPIGOT_JAR as the name of the jar file in the server you want to run
|
||||
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
|
||||
task runJar() << {
|
||||
javaexec {
|
||||
main "-jar"
|
||||
args "${System.env.SPIGOT_LOC}\\${System.env.SPIGOT_JAR}.jar"
|
||||
jvmArgs "-DIReallyKnowWhatIAmDoingISwear=true"
|
||||
workingDir "${System.env.SPIGOT_LOC}"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,751 +0,0 @@
|
||||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.api.portaldata.PortalArg;
|
||||
import com.sekwah.advancedportals.listeners.Listeners;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final ArrayList<String> blockMaterialList = new ArrayList<>();
|
||||
private AdvancedPortalsPlugin plugin;
|
||||
|
||||
private int portalArgsStringLength = 0;
|
||||
|
||||
// TODO recode the portal args to be put into a hashmap and use a string array
|
||||
// to store all possible portal arguments. Makes code shorter and possibly more efficient.
|
||||
//private HashMap<String, String> portalArgs = new HashMap<>();
|
||||
|
||||
public AdvancedPortalsCommand(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
|
||||
for(Material material : Material.values()) {
|
||||
this.blockMaterialList.add("triggerblock:" + material.name().toLowerCase());
|
||||
}
|
||||
plugin.getCommand("advancedportals").setExecutor(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
System.out.printf("%s %s %s %s%n", sender, cmd, command, args );
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
|
||||
if(!(sender instanceof Player)) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You cannot use commands with the console.");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
if (sender.hasPermission("advancedportals.portal")) {
|
||||
if (args.length > 0) { switch (args[0].toLowerCase()) {
|
||||
case "wand":
|
||||
case "selector":
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
|
||||
Material WandMaterial = Material.getMaterial(ItemID);
|
||||
|
||||
if (WandMaterial == null) {
|
||||
WandMaterial = Material.IRON_AXE;
|
||||
}
|
||||
|
||||
ItemStack regionselector = new ItemStack(WandMaterial);
|
||||
ItemMeta selectorname = regionselector.getItemMeta();
|
||||
selectorname.setDisplayName("\u00A7ePortal Region Selector");
|
||||
selectorname.setLore(Arrays.asList("\u00A7rThis wand with has the power to help"
|
||||
, "\u00A7r create portals bistowed upon it!"));
|
||||
regionselector.setItemMeta(selectorname);
|
||||
|
||||
inventory.addItem(regionselector);
|
||||
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Region Selector\u00A7a!");
|
||||
break;
|
||||
case "portalblock":
|
||||
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
|
||||
// Also do this for other blocks such as gateways and end portals just in case they want it.
|
||||
ItemStack portalBlock = new Wool(DyeColor.PURPLE).toItemStack(1);
|
||||
ItemMeta blockName = portalBlock.getItemMeta();
|
||||
blockName.setDisplayName("\u00A75Portal Block Placer");
|
||||
blockName.setLore(Arrays.asList("\u00A7rThis wool is made of a magical substance",
|
||||
"\u00A7rRight Click: Place portal block",
|
||||
"\u00A7rLeft Click: Rotate portal block"));
|
||||
portalBlock.setItemMeta(blockName);
|
||||
inventory.addItem(portalBlock);
|
||||
|
||||
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Block\u00A7a!");
|
||||
break;
|
||||
case "endportalblock":
|
||||
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
|
||||
// Also do this for other blocks such as gateways and end portals just in case they want it.
|
||||
portalBlock = new Wool(DyeColor.BLACK).toItemStack(1);
|
||||
blockName = portalBlock.getItemMeta();
|
||||
blockName.setDisplayName("\u00A78End Portal Block Placer");
|
||||
blockName.setLore(Arrays.asList("\u00A7rThis wool is made of a magical substance",
|
||||
"\u00A7rRight Click: Place portal block"));
|
||||
portalBlock.setItemMeta(blockName);
|
||||
inventory.addItem(portalBlock);
|
||||
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Block\u00A7a!");
|
||||
break;
|
||||
case "gatewayblock":
|
||||
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
|
||||
// Also do this for other blocks such as gateways and end portals just in case they want it.
|
||||
portalBlock = new Wool(DyeColor.BLACK).toItemStack(1);
|
||||
blockName = portalBlock.getItemMeta();
|
||||
blockName.setDisplayName("\u00A78Gateway Block Placer");
|
||||
blockName.setLore(Arrays.asList("\u00A7rThis wool is made of a magical substance",
|
||||
"\u00A7rRight Click: Place portal block"));
|
||||
portalBlock.setItemMeta(blockName);
|
||||
inventory.addItem(portalBlock);
|
||||
|
||||
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Block\u00A7a!");
|
||||
break;
|
||||
case "create":
|
||||
if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
|
||||
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString())
|
||||
&& player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
|
||||
if (args.length >= 2) { // may make this next piece of code more efficient, maybe check against a list of available variables or something
|
||||
// TODO change system to use arrays and hashmaps
|
||||
boolean hasName = false;
|
||||
boolean hasTriggerBlock = false;
|
||||
boolean hasDestination = false;
|
||||
boolean isBungeePortal = false;
|
||||
boolean needsPermission = false;
|
||||
boolean executesCommand = false;
|
||||
String destination = null;
|
||||
String portalName = null;
|
||||
String triggerBlock = null;
|
||||
String serverName = null;
|
||||
String permission = null;
|
||||
String portalCommand = null;
|
||||
|
||||
ArrayList<PortalArg> extraData = new ArrayList<>();
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (args[i].toLowerCase().startsWith("name:") && args[i].length() > 5) {
|
||||
hasName = true;
|
||||
portalName = args[i].replaceFirst("name:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("name:")) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You must include a name for the portal that isnt nothing!");
|
||||
return true;
|
||||
} else if (args[i].toLowerCase().startsWith("destination:") && args[i].length() > 12) {
|
||||
hasDestination = true;
|
||||
destination = args[i].toLowerCase().replaceFirst("destination:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("desti:") && args[i].length() > 6) {
|
||||
hasDestination = true;
|
||||
destination = args[i].toLowerCase().replaceFirst("desti:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13) {
|
||||
hasTriggerBlock = true;
|
||||
triggerBlock = args[i].toLowerCase().replaceFirst("triggerblock:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13) {
|
||||
hasTriggerBlock = true;
|
||||
triggerBlock = args[i].toLowerCase().replaceFirst("triggerblock:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("bungee:") && args[i].length() > 7) { // not completely implemented
|
||||
isBungeePortal = true;
|
||||
serverName = args[i].toLowerCase().replaceFirst("bungee:", "");
|
||||
//extraData.add(new PortalArgs("bungee", serverName));
|
||||
} else if (args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11) { // not completely implemented
|
||||
needsPermission = true;
|
||||
permission = args[i].toLowerCase().replaceFirst("permission:", "");
|
||||
extraData.add(new PortalArg("permission", permission));
|
||||
} else if (args[i].toLowerCase().startsWith("command:") && args[i].length() > 8) { // not completely implemented
|
||||
executesCommand = true;
|
||||
portalCommand = parseArgVariable(args, i, "command:");
|
||||
i += this.portalArgsStringLength - 1;
|
||||
if(portalCommand.startsWith("#") && ((this.plugin.getSettings().hasCommandLevel("c")
|
||||
&& (sender.hasPermission("advancedportals.createportal.commandlevel.console"))
|
||||
|| (this.plugin.getSettings().hasCommandLevel("k") && sender.isOp())))) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a console command portal!");
|
||||
return true;
|
||||
}
|
||||
else if(portalCommand.startsWith("!") && ((this.plugin.getSettings().hasCommandLevel("o")
|
||||
&& (sender.hasPermission("advancedportals.createportal.commandlevel.op"))
|
||||
|| (this.plugin.getSettings().hasCommandLevel("p") && sender.isOp())))) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a op command portal!");
|
||||
return true;
|
||||
}
|
||||
else if(portalCommand.startsWith("^") && ((this.plugin.getSettings().hasCommandLevel("p")
|
||||
&& (sender.hasPermission("advancedportals.createportal.commandlevel.perms"))
|
||||
|| (this.plugin.getSettings().hasCommandLevel("e") && sender.isOp())))) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a all perms command portal!");
|
||||
return true;
|
||||
}
|
||||
extraData.add(new PortalArg("command.1", portalCommand));
|
||||
}
|
||||
}
|
||||
if (!hasName) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You must include a name for the portal that you are creating in the variables!");
|
||||
return true;
|
||||
}
|
||||
|
||||
World world = org.bukkit.Bukkit.getWorld(player.getMetadata("Pos1World").get(0).asString());
|
||||
Location pos1 = new Location(world, player.getMetadata("Pos1X").get(0).asInt(), player.getMetadata("Pos1Y").get(0).asInt(), player.getMetadata("Pos1Z").get(0).asInt());
|
||||
Location pos2 = new Location(world, player.getMetadata("Pos2X").get(0).asInt(), player.getMetadata("Pos2Y").get(0).asInt(), player.getMetadata("Pos2Z").get(0).asInt());
|
||||
|
||||
ConfigAccessor desticonfig = new ConfigAccessor(plugin, "destinations.yml");
|
||||
String destiPosX = desticonfig.getConfig().getString(destination + ".pos.X");
|
||||
|
||||
if (!Portal.portalExists(portalName)) {
|
||||
|
||||
player.sendMessage("");
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7e You have created a new portal with the following details:");
|
||||
player.sendMessage("\u00A7aname: \u00A7e" + portalName);
|
||||
if (hasDestination) {
|
||||
if (destiPosX == null) {
|
||||
player.sendMessage("\u00A7cdestination: \u00A7e" + destination + " (destination does not exist)");
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
player.sendMessage("\u00A7adestination: \u00A7e" + destination);
|
||||
}
|
||||
|
||||
} else {
|
||||
player.sendMessage("\u00A7cdestination: \u00A7eN/A (will not teleport to a location)");
|
||||
}
|
||||
|
||||
if (isBungeePortal) {
|
||||
player.sendMessage("\u00A7abungee: \u00A7e" + serverName);
|
||||
}
|
||||
|
||||
if (needsPermission) {
|
||||
player.sendMessage("\u00A7apermission: \u00A7e" + permission);
|
||||
} else {
|
||||
player.sendMessage("\u00A7apermission: \u00A7e(none needed)");
|
||||
}
|
||||
|
||||
if (executesCommand) {
|
||||
player.sendMessage("\u00A7acommand: \u00A7e" + portalCommand);
|
||||
}
|
||||
|
||||
Material triggerBlockMat;
|
||||
if (hasTriggerBlock) {
|
||||
triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase());
|
||||
if (triggerBlockMat != null) {
|
||||
player.sendMessage("\u00A7atriggerBlock: \u00A7e" + triggerBlock.toUpperCase());
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
portalArgs = extraData.toArray(portalArgs);
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, portalArgs));
|
||||
} else {
|
||||
hasTriggerBlock = false;
|
||||
ConfigAccessor Config = new ConfigAccessor(plugin, "config.yml");
|
||||
player.sendMessage("\u00A7ctriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
|
||||
|
||||
player.sendMessage("\u00A7cThe block " + triggerBlock.toUpperCase() + " is not a valid block name in minecraft so the trigger block has been set to the default!");
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
portalArgs = extraData.toArray(portalArgs);
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
|
||||
}
|
||||
} else {
|
||||
ConfigAccessor Config = new ConfigAccessor(plugin, "config.yml");
|
||||
player.sendMessage("\u00A7atriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
portalArgs = extraData.toArray(portalArgs);
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " A portal by that name already exists!");
|
||||
}
|
||||
|
||||
// add code to save the portal to the portal config and reload the portals
|
||||
|
||||
player.sendMessage("");
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need to at least add the name of the portal as a variable, \u00A7cType \u00A7e/portal variables\u00A7c"
|
||||
+ " for a full list of currently available variables and an example command!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " The points you have selected need to be in the same world!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need to have two points selected to make a portal!");
|
||||
}
|
||||
break;
|
||||
case "variables" :
|
||||
sender.sendMessage(PluginMessages.customPrefix + " \u00A77Variables \u00A7c: \u00A7aname, triggerBlock, desti, destination, bungee, permission, command");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
|
||||
break;
|
||||
case "select":
|
||||
// TODO finish the select command and the hit block to replace!
|
||||
if (!player.hasMetadata("selectingPortal")) {
|
||||
if (args.length > 1) {
|
||||
if (Portal.portalExists(args[1])) {
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
|
||||
player.sendMessage(PluginMessages.customPrefix + " You have selected\u00A7e" + args[1] + "\u00A7a.");
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists (maybe you got the caps wrong)\n Try typing \u00A7e/portal select\u00A7c and hit inside the apropriate portals area!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefix + " Hit a block inside the portal region to select the portal!");
|
||||
player.setMetadata("selectingPortal", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
|
||||
} else {
|
||||
player.removeMetadata("selectingPortal", plugin);
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " Portal selection cancelled!");
|
||||
}
|
||||
break;
|
||||
case "unselect":
|
||||
if(player.hasMetadata("selectedPortal")){
|
||||
player.sendMessage(PluginMessages.customPrefix + " You have unselected\u00A7e" + player.getMetadata("selectedPortal").get(0).asString()
|
||||
+ "\u00A7a.");
|
||||
}
|
||||
else{
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You had no portal selected!");
|
||||
}
|
||||
case "gui" :
|
||||
if (args.length > 1) {
|
||||
if (args[1].toLowerCase().equals("remove") && args.length > 2) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?");
|
||||
sender.sendMessage("");
|
||||
plugin.compat.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\"," +
|
||||
"\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " +
|
||||
"{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"}" +
|
||||
",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player);
|
||||
sender.sendMessage("");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "edit":
|
||||
if (args.length > 1) {
|
||||
if (Portal.portalExists(args[1])) {
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
|
||||
portalEditMenu(sender, portalConfig, args[1]);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
if (posX != null) {
|
||||
portalEditMenu(sender, portalConfig, portalName);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "rename":
|
||||
|
||||
// not finished yet /
|
||||
if (args.length > 1) {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
if (portalName.toLowerCase() != args[1].toLowerCase()) {
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
|
||||
String newPortalPosX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
|
||||
if (posX != null && newPortalPosX == null) {
|
||||
Portal.rename(portalName, args[1]);
|
||||
sender.sendMessage(PluginMessages.customPrefix + " The portal \u00A7e" + portalName + "\u00A7a has been renamed to \u00A7e" + args[1] + "\u00A7a.");
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
|
||||
} else if (newPortalPosX != null) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " There is already a portal with the name \u00A7e" + args[1] + "\u00A7c!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you have selected is already called that!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must select a portal first and then type \u00A7e/portal rename (new name)\u00A7c!");
|
||||
}
|
||||
break;
|
||||
case "command":
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
if (args.length > 1) {
|
||||
// TODO add the command autocompletes, add, remove and show
|
||||
if (args[1].toLowerCase().equals("add")) {
|
||||
if (args.length > 2) {
|
||||
String portalCommand = args[2];
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
portalCommand += args[i];
|
||||
}
|
||||
if (Portal.addCommand(portalName, portalCommand)) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " Command added to portal!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " Failed to add command to portal!");
|
||||
}
|
||||
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must actually specify a command to execute!");
|
||||
}
|
||||
|
||||
} else if (args[1].toLowerCase().equals("remove")) {
|
||||
// Specify what line to remove
|
||||
} else if (args[1].toLowerCase().equals("show")) {
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove a command!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove\u00A7c a command!");
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if (args.length > 1) {
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
|
||||
if (posX != null) {
|
||||
Portal.remove(args[1]);
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal \u00A7e" + args[1] + "\u00A7c has been removed!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
if (posX != null) {
|
||||
Portal.remove(portalName);
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal \u00A77" + portalName + "\u00A7c has been removed!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "help":
|
||||
helpCommand(sender, command, args);
|
||||
break;
|
||||
case "show":
|
||||
if (args.length > 1) {
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
|
||||
if (posX != null) {
|
||||
Selection.show(player, this.plugin, args[1]);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
player.sendMessage(PluginMessages.customPrefix + " Your currently selected portal has been shown, it will dissapear shortly!");
|
||||
Selection.show(player, this.plugin, player.getMetadata("selectedPortal").get(0).asString());
|
||||
} else if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
|
||||
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString())
|
||||
&& player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
|
||||
player.sendMessage(PluginMessages.customPrefix + " Your currently selected area has been shown, it will dissapear shortly!");
|
||||
Selection.show(player, this.plugin, null);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " No regions selected!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "reload":
|
||||
sender.sendMessage(PluginMessages.customPrefix + " Reloaded values!");
|
||||
Listeners.reloadValues(plugin);
|
||||
Portal.loadPortals();
|
||||
break;
|
||||
case "list" :
|
||||
String message = PluginMessages.customPrefix + " \u00A77Portals \u00A7c:\u00A7a";
|
||||
LinkedList<String> portals = new LinkedList<>();
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
portals.add(portal.getName());
|
||||
}
|
||||
Collections.sort(portals);
|
||||
for (Object portalName : portals.toArray()) {
|
||||
message = message + " " + portalName;
|
||||
}
|
||||
player.sendMessage(message);
|
||||
break;
|
||||
default:
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
}
|
||||
} else {
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
}
|
||||
} else {
|
||||
PluginMessages.NoPermission(sender, command);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void helpCommand(CommandSender sender, String command, String[] args) {
|
||||
// Add pages if there starts to become too many
|
||||
if(args.length == 1) {
|
||||
sendMenu(sender, "Help Menu",
|
||||
"\u00A76/" + command + " selector \u00A7a- gives you a region selector",
|
||||
"\u00A76/" + command + " create \u00A7c[tags] \u00A7a- creates a portal with a selection ",
|
||||
"\u00A76/" + command + " portalblock \u00A7a- gives you a portal block",
|
||||
"\u00A76/" + command + " endportalblock \u00A7a- gives you an end portal block",
|
||||
"\u00A76/" + command + " gatewayblock \u00A7a- gives you a gateway block",
|
||||
"\u00A76/" + command + " select \u00A7a- selects an existing portal",
|
||||
"\u00A76/" + command + " unselect \u00A7a- unselects the current portal",
|
||||
"\u00A76/" + command + " command \u00A7a- adds or removes commands from the selected portal",
|
||||
"\u00A76/" + command + " help \u00A7a- shows this help section",
|
||||
"\u00A76/" + command + " help <arg> \u00A7a- shows help for the specified arg",
|
||||
"\u00A76/" + command + " remove \u00A7a- removes a portal",
|
||||
"\u00A76/" + command + " list \u00A7a- lists all the current portals",
|
||||
"\u00A76/" + command + " variables \u00A7a- lists all available tags");
|
||||
}
|
||||
else if(args.length > 1){
|
||||
if(args[1].toLowerCase().equals("help")) {
|
||||
sendMenu(sender, "Help Command",
|
||||
"Shows the help section. You can also use a single argument after it to show the " +
|
||||
"help section for the corresponding command.");
|
||||
}
|
||||
else if(args[1].toLowerCase().equals("portalblock")) {
|
||||
sendMenu(sender, "Help Command",
|
||||
"Gives you a special wool block to place portal blocks.",
|
||||
"",
|
||||
"\u00A7eLeft Click: \u00A76Rotates the hit portal block",
|
||||
"\u00A7eRight Click: \u00A76Placed a portal block");
|
||||
}
|
||||
else if(args[1].toLowerCase().equals("endportalblock")) {
|
||||
sendMenu(sender, "Help Command",
|
||||
"Gives you a special wool block to place end portal blocks.",
|
||||
"",
|
||||
"\u00A7eRight Click: \u00A76Placed a end portal block");
|
||||
}
|
||||
else if(args[1].toLowerCase().equals("gatewayblock")) {
|
||||
sendMenu(sender, "Help Command",
|
||||
"Gives you a special wool block to place gateway blocks.",
|
||||
"",
|
||||
"\u00A7eRight Click: \u00A76Placed a gateway block");
|
||||
}
|
||||
else{
|
||||
sender.sendMessage(PluginMessages.customPrefix + " Either \u00A7e" + args[1] + "\u00A7a is not a command or a help page has not been added yet.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMenu(CommandSender sender, String title, String... lines) {
|
||||
sender.sendMessage(PluginMessages.customPrefix + " " + title);
|
||||
sender.sendMessage("\u00A7e\u00A7m-----------------------------------");
|
||||
for(String line : lines){
|
||||
sender.sendMessage("\u00A7a" + line);
|
||||
}
|
||||
sender.sendMessage("\u00A7e\u00A7m-----------------------------------");
|
||||
}
|
||||
|
||||
private String parseArgVariable(String[] args, int currentArg, String argStarter) {
|
||||
String variableString = args[currentArg].replaceFirst(argStarter, "");
|
||||
this.portalArgsStringLength = 1;
|
||||
if (variableString.charAt(0) == '"') {
|
||||
variableString = variableString.substring(1, variableString.length());
|
||||
if (variableString.charAt(variableString.length() - 1) != '"') {
|
||||
currentArg++;
|
||||
for (; currentArg < args.length; currentArg++) {
|
||||
variableString += " " + args[currentArg];
|
||||
this.portalArgsStringLength += 1;
|
||||
if (variableString.charAt(variableString.length() - 1) == '"') {
|
||||
variableString = variableString.substring(0, variableString.length() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
variableString = variableString.substring(0, variableString.length() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
return variableString;
|
||||
}
|
||||
|
||||
private void portalEditMenu(CommandSender sender, ConfigAccessor portalConfig, String portalName) {
|
||||
// make the text gui with the json message for a list of edit commands to be clicked or hovered
|
||||
// put \" for a " in the json messages
|
||||
// sadly there is no newline code so these three lines will have to be copied and pasted for each line
|
||||
|
||||
// use the usual messages for normal lines but anything that needs special features make sure you use the
|
||||
// chat steriliser
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(PluginMessages.customPrefix + " Editing: \u00A7e" + portalName);
|
||||
|
||||
sender.sendMessage(" \u00A7apos1\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos1.X")
|
||||
+ ", " + portalConfig.getConfig().getString(portalName + ".pos1.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Z"));
|
||||
sender.sendMessage(" \u00A7apos2\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos2.X")
|
||||
+ ", " + portalConfig.getConfig().getString(portalName + ".pos2.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Z"));
|
||||
|
||||
String destination = portalConfig.getConfig().getString(portalName + ".destination");
|
||||
if (destination != null) {
|
||||
sender.sendMessage(" \u00A7adestination\u00A7e: " + destination);
|
||||
} else {
|
||||
sender.sendMessage(" \u00A7cdestination\u00A7e: null");
|
||||
}
|
||||
|
||||
String trigger = portalConfig.getConfig().getString(portalName + ".triggerblock");
|
||||
if (trigger != null) {
|
||||
sender.sendMessage(" \u00A7atriggerBlock\u00A7e: " + trigger);
|
||||
} else {
|
||||
sender.sendMessage(" \u00A7ctriggerBlock\u00A7e: null");
|
||||
}
|
||||
|
||||
if (portalConfig.getConfig().getString(portalName + ".portalArgs.command.1") != null) {
|
||||
int commands = 0;
|
||||
String command = portalConfig.getConfig().getString(portalName + ".portalArgs.command.1");
|
||||
// TODO possibly change code so it counds number of subvalues rather than a loop.
|
||||
while (command != null) {
|
||||
command = portalConfig.getConfig().getString(portalName + ".portalArgs.command." + ++commands);
|
||||
}
|
||||
if (--commands > 1) {
|
||||
sender.sendMessage(" \u00A7acommands\u00A7e: " + commands + " commands");
|
||||
} else {
|
||||
sender.sendMessage(" \u00A7acommands\u00A7e: " + commands + " command");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(" \u00A7ccommands\u00A7e: none");
|
||||
}
|
||||
sender.sendMessage("");
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
plugin.compat.sendRawMessage("{\"text\":\"\u00A7aFunctions\u00A7e: \"," +
|
||||
"\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal gui remove " + portalName + "\"}}"
|
||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eShow\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Show the selected portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal show " + portalName + "\"}}"
|
||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eRename\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Change the name of the portal\"},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/portal rename \"}}"
|
||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eTeleport\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(If there is one)\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/desti warp " + destination + "\"}}]}", player);
|
||||
|
||||
sender.sendMessage("");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
|
||||
/*System.out.printf("%s %s %s %s%n", sender, cmd, command, args);
|
||||
|
||||
System.out.println(args.length);
|
||||
System.out.println("ARRAY");
|
||||
for(String arg : args) {
|
||||
System.out.println(arg);
|
||||
}*/
|
||||
|
||||
LinkedList<String> autoComplete = new LinkedList<String>();
|
||||
if (sender.hasPermission("advancedportals.createportal")) {
|
||||
if (args.length == 1 || (args.length == 2 && args[0].toLowerCase().equals("help"))) {
|
||||
autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "unselect", "command", "selector"
|
||||
, "show", "gatewayblock", "endportalblock", "variables", "wand", "remove", "rename", "help", "bukkitpage", "helppage"));
|
||||
} else if (args[0].toLowerCase().equals("create")) {
|
||||
|
||||
boolean hasName = false;
|
||||
boolean hasTriggerBlock = false;
|
||||
boolean hasDestination = false;
|
||||
boolean isBungeePortal = false;
|
||||
boolean needsPermission = false;
|
||||
boolean hasCommand = false;
|
||||
|
||||
|
||||
// TODO change auto complete when quotes are opened and closed. Such as autocomplete @Player and stuff when specifying commands
|
||||
|
||||
// For if partially complete found and also valid
|
||||
boolean partialComplete = true;
|
||||
|
||||
// TODO add a better version of this to the new api.
|
||||
|
||||
//System.out.println(args[args.length - 1].equals(""));
|
||||
|
||||
String stillToComplete = args[args.length - 1];
|
||||
|
||||
if(stillToComplete.toLowerCase().startsWith("triggerblock:")) {
|
||||
autoComplete.addAll(this.blockMaterialList);
|
||||
}
|
||||
else {
|
||||
partialComplete = false;
|
||||
}
|
||||
|
||||
if(!partialComplete) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String argTag = getTag(args[i].toLowerCase());
|
||||
if (argTag.length() + 1 < args[i].length()) {
|
||||
switch (argTag) {
|
||||
case "name":
|
||||
hasName = true;
|
||||
break;
|
||||
case "destination":
|
||||
hasDestination = true;
|
||||
break;
|
||||
case "desti":
|
||||
hasDestination = true;
|
||||
break;
|
||||
case "triggerblock":
|
||||
hasTriggerBlock = true;
|
||||
break;
|
||||
case "bungee":
|
||||
isBungeePortal = true;
|
||||
break;
|
||||
case "permission":
|
||||
needsPermission = true;
|
||||
break;
|
||||
case "command":
|
||||
hasCommand = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!hasName) {
|
||||
autoComplete.add("name:");
|
||||
}
|
||||
if (!hasTriggerBlock) {
|
||||
autoComplete.add("triggerblock:");
|
||||
}
|
||||
if (!hasDestination) {
|
||||
autoComplete.add("destination:");
|
||||
autoComplete.add("desti:");
|
||||
}
|
||||
if (!isBungeePortal) {
|
||||
autoComplete.add("bungee:");
|
||||
}
|
||||
if (!needsPermission) {
|
||||
autoComplete.add("permission:");
|
||||
}
|
||||
if (!hasCommand) {
|
||||
autoComplete.add("command:");
|
||||
}
|
||||
else {
|
||||
autoComplete.add("@player");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(autoComplete);
|
||||
for (Object result : autoComplete.toArray()) {
|
||||
if (!result.toString().startsWith(args[args.length - 1])) {
|
||||
autoComplete.remove(result);
|
||||
}
|
||||
}
|
||||
return autoComplete;
|
||||
}
|
||||
|
||||
private String getTag(String arg) {
|
||||
int indexOfSplitter = arg.indexOf(':');
|
||||
if (indexOfSplitter > 0) {
|
||||
return arg.substring(0, indexOfSplitter);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,187 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.DestinationCommand;
|
||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.bukkit.listeners.*;
|
||||
import com.sekwah.advancedportals.bukkit.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
private Settings settings;
|
||||
|
||||
protected boolean registerProxyChannels = false;
|
||||
protected boolean disableProxyWarning = false;
|
||||
|
||||
private boolean worldEditActive = false;
|
||||
|
||||
protected static final Map<String, String> PLAYER_DESTI_MAP = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
/*Metrics metrics = */
|
||||
new Metrics(this, 4814);
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
|
||||
|
||||
ConfigHelper configHelper = new ConfigHelper(config.getConfig());
|
||||
|
||||
configHelper.update();
|
||||
|
||||
config.saveConfig();
|
||||
|
||||
FileConfiguration pluginConfig = config.getConfig();
|
||||
registerProxyChannels = pluginConfig.getBoolean(ConfigHelper.ENABLE_PROXY_SUPPORT, false);
|
||||
disableProxyWarning = pluginConfig.getBoolean(ConfigHelper.DISABLE_PROXY_WARNING, false);
|
||||
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
|
||||
portalConfig.saveDefaultConfig();
|
||||
|
||||
|
||||
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
|
||||
destinationConfig.saveDefaultConfig();
|
||||
|
||||
|
||||
ConfigAccessor messagesConfig = new ConfigAccessor(this, "messages.yml");
|
||||
messagesConfig.saveDefaultConfig();;
|
||||
|
||||
this.settings = new Settings(this);
|
||||
|
||||
// Loads the portal and destination editors
|
||||
Portal.init(this);
|
||||
Destination.init(this);
|
||||
|
||||
|
||||
this.registerCommands();
|
||||
|
||||
new WarpEffects(this);
|
||||
|
||||
this.addListeners();
|
||||
this.setupDataCollector();
|
||||
|
||||
this.setupBungee();
|
||||
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
|
||||
|
||||
for (Player player:
|
||||
this.getServer().getOnlinePlayers()) {
|
||||
player.removeMetadata(Listeners.HAS_WARPED, this);
|
||||
player.removeMetadata(Listeners.LAVA_WARPED, this);
|
||||
}
|
||||
|
||||
if (settings.enabledWorldEditIntegration() && Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
|
||||
worldEditActive = true;
|
||||
}
|
||||
|
||||
// thanks to the new config accessor code the config.saveDefaultConfig(); will now
|
||||
// only copy the file if it doesnt exist!
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
new PluginMessages(this);
|
||||
new AdvancedPortalsCommand(this);
|
||||
new DestinationCommand(this);
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
new Listeners(this);
|
||||
|
||||
new FlowStopper(this);
|
||||
new PortalProtect(this);
|
||||
new PortalPlacer(this);
|
||||
}
|
||||
|
||||
private void setupDataCollector() {
|
||||
Selection.loadData(this);
|
||||
}
|
||||
|
||||
private void setupBungee() {
|
||||
// Enables very basic bungee support if not setup right
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
if(registerProxyChannels || this.checkIfBungee()) {
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
||||
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, BungeeMessages.CHANNEL_NAME);
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, BungeeMessages.CHANNEL_NAME, new PluginMessageReceiver(this));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getPlayerDestiMap() {
|
||||
return PLAYER_DESTI_MAP;
|
||||
}
|
||||
|
||||
public boolean isProxyPluginEnabled() {
|
||||
return registerProxyChannels;
|
||||
}
|
||||
|
||||
private boolean checkIfBungee()
|
||||
{
|
||||
// we check if the server is Spigot/Paper (because of the spigot.yml file)
|
||||
try {
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
} catch (ClassNotFoundException e) {
|
||||
this.getServer().getConsoleSender().sendMessage( "\u00A7ePossibly unsupported version for bungee messages detected, channels won't be enabled." );
|
||||
getLogger().info("If you believe this shouldn't be the case please contact us on discord https://discord.sekwah.com/");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
ConfigurationSection configSelection = getServer().spigot().getConfig().getConfigurationSection("settings");
|
||||
if (configSelection != null && configSelection.getBoolean("bungeecord") ) {
|
||||
getLogger().info( "Bungee detected. Enabling proxy features." );
|
||||
return true;
|
||||
}
|
||||
} catch(NoSuchMethodError | NullPointerException e) {
|
||||
if(!disableProxyWarning) getLogger().info("BungeeCord config not detected, ignoring settings");
|
||||
}
|
||||
|
||||
// Will be valid if paperspigot is being used. Otherwise catch.
|
||||
try {
|
||||
YamlConfiguration config = getServer().spigot().getPaperConfig();
|
||||
if(Objects.equals(config.get("velocity-support.enabled"),true)
|
||||
|| Objects.equals(config.get("proxies.velocity.enabled"),true)) {
|
||||
getLogger().info( "Modern forwarding detected. Enabling proxy features." );
|
||||
return true;
|
||||
}
|
||||
} catch(NoSuchMethodError | NullPointerException e) {
|
||||
if(!disableProxyWarning) getLogger().info("Paper config not detected, ignoring paper settings");
|
||||
}
|
||||
|
||||
if(!disableProxyWarning) getLogger().warning( "Proxy features disabled for Advanced Portals as bungee isn't enabled on the server (spigot.yml)." +
|
||||
"If you are using Paper proxies.velocity.enabled (config/paper-global.yml) or settings.velocity-support.enabled (paper.yml) may not be enabled " );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7cAdvanced portals are being disabled!");
|
||||
}
|
||||
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public boolean isWorldEditActive() {
|
||||
return worldEditActive;
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.checkerframework.checker.regex.qual.Regex;
|
||||
|
||||
public class PluginMessages {
|
||||
private static String WARP_MESSAGE;
|
||||
private static String COOLDOWN_PROTECTION_MESSAGE;
|
||||
private static String PORTAL_COOLDOWN_MESSAGE;
|
||||
private static String NO_PERMISSION_PORTAL;
|
||||
private static String NO_BUILD_PERMISSION;
|
||||
public boolean useCustomPrefix = false;
|
||||
public static String customPrefix = "§a[§eAdvancedPortals§a]";
|
||||
public static String customPrefixFail = "§c[§7AdvancedPortals§c]";
|
||||
|
||||
// TODO: Create function for replacing all '&'
|
||||
public PluginMessages (AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "messages.yml");
|
||||
|
||||
this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix");
|
||||
String regexColorConverter = "&(?=[0-9a-fk-orx])";
|
||||
|
||||
if (useCustomPrefix) {
|
||||
PluginMessages.customPrefix = config.getConfig().getString("CustomPrefix", "§a[§eAdvancedPortals§a]").replaceAll(regexColorConverter, "§");
|
||||
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefixFail", "§c[§7AdvancedPortals§c]").replaceAll(regexColorConverter, "§");
|
||||
}
|
||||
|
||||
WARP_MESSAGE = config.getConfig().getString("WarpMessage", "§aYou have warped to §e<warp>§a").replaceAll(regexColorConverter, "§");
|
||||
COOLDOWN_PROTECTION_MESSAGE = config.getConfig().getString("CooldownProtectionMessage", "§cThere is §e<time>§c join cooldown protection left.").replaceAll(regexColorConverter, "§");
|
||||
NO_PERMISSION_PORTAL = config.getConfig().getString("NoPermissionPortal", "§cYou do not have permission to use this portal!").replaceAll(regexColorConverter, "§");
|
||||
PORTAL_COOLDOWN_MESSAGE = config.getConfig().getString("PortalCooldownMessage", "§cPlease wait §e<time> §cuntil attempting to enter this portal again").replaceAll(regexColorConverter, "§");
|
||||
NO_BUILD_PERMISSION = config.getConfig().getString("NoBuildPermission", "§cYou don't have permission to build here!").replaceAll(regexColorConverter, "§");
|
||||
}
|
||||
|
||||
// This class is so then the common messages in commands or just messages over the commands are the same and can be
|
||||
// easily changed.
|
||||
|
||||
public static String getWarpMessage(String warp) {
|
||||
String cleanedWarp = warp.replace("_", " ");
|
||||
return WARP_MESSAGE.replace("<warp>", cleanedWarp);
|
||||
}
|
||||
|
||||
public static String getCooldownProtectionMessage(int time) {
|
||||
String secondsOrSecond = (time == 1) ? " second" : " seconds";
|
||||
return COOLDOWN_PROTECTION_MESSAGE.replace("<time>", time + secondsOrSecond);
|
||||
}
|
||||
|
||||
public static String getNoPermissionPortal() {
|
||||
return NO_PERMISSION_PORTAL;
|
||||
}
|
||||
|
||||
public static String getNoBuildPermission() {
|
||||
return NO_BUILD_PERMISSION;
|
||||
}
|
||||
|
||||
public static void UnknownCommand(CommandSender sender, String command) {
|
||||
sender.sendMessage(customPrefixFail + " You need to type something after /" + command + "\n");
|
||||
sender.sendMessage("§cIf you do not know what you can put or would like some help with the commands please type §e" + '"' + "§e/" + command + " help" + '"' + "§c\n");
|
||||
}
|
||||
|
||||
public static void NoPermission(CommandSender sender, String command) {
|
||||
sender.sendMessage(customPrefixFail + " You do not have permission to perform that command!");
|
||||
}
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Selection {
|
||||
|
||||
private static Material blockType = Material.RED_STAINED_GLASS;
|
||||
private static int timeout = 10;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void loadData(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
|
||||
timeout = config.getConfig().getInt("ShowSelectionShowDuration");
|
||||
|
||||
String BlockID = config.getConfig().getString("ShowSelectionBlockID");
|
||||
|
||||
blockType = Material.getMaterial(BlockID);
|
||||
|
||||
if (blockType == null) {
|
||||
plugin.getLogger().warning("Material may be from old name format");
|
||||
blockType = Material.RED_STAINED_GLASS;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void show(final Player player, final AdvancedPortalsPlugin plugin, String portalName) {
|
||||
|
||||
int LowX = 0;
|
||||
int LowY = 0;
|
||||
int LowZ = 0;
|
||||
|
||||
int HighX = 0;
|
||||
int HighY = 0;
|
||||
int HighZ = 0;
|
||||
|
||||
if (portalName != null) {
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
|
||||
|
||||
LowX = portalConfig.getConfig().getInt(portalName + ".pos2.X");
|
||||
LowY = portalConfig.getConfig().getInt(portalName + ".pos2.Y");
|
||||
LowZ = portalConfig.getConfig().getInt(portalName + ".pos2.Z");
|
||||
|
||||
HighX = portalConfig.getConfig().getInt(portalName + ".pos1.X");
|
||||
HighY = portalConfig.getConfig().getInt(portalName + ".pos1.Y");
|
||||
HighZ = portalConfig.getConfig().getInt(portalName + ".pos1.Z");
|
||||
} else {
|
||||
if (player.getMetadata("Pos1X").get(0).asInt() > player.getMetadata("Pos2X").get(0).asInt()) {
|
||||
LowX = player.getMetadata("Pos2X").get(0).asInt();
|
||||
HighX = player.getMetadata("Pos1X").get(0).asInt();
|
||||
} else {
|
||||
LowX = player.getMetadata("Pos1X").get(0).asInt();
|
||||
HighX = player.getMetadata("Pos2X").get(0).asInt();
|
||||
}
|
||||
if (player.getMetadata("Pos1Y").get(0).asInt() > player.getMetadata("Pos2Y").get(0).asInt()) {
|
||||
LowY = player.getMetadata("Pos2Y").get(0).asInt();
|
||||
HighY = player.getMetadata("Pos1Y").get(0).asInt();
|
||||
} else {
|
||||
LowY = player.getMetadata("Pos1Y").get(0).asInt();
|
||||
HighY = player.getMetadata("Pos2Y").get(0).asInt();
|
||||
}
|
||||
if (player.getMetadata("Pos1Z").get(0).asInt() > player.getMetadata("Pos2Z").get(0).asInt()) {
|
||||
LowZ = player.getMetadata("Pos2Z").get(0).asInt();
|
||||
HighZ = player.getMetadata("Pos1Z").get(0).asInt();
|
||||
} else {
|
||||
LowZ = player.getMetadata("Pos1Z").get(0).asInt();
|
||||
HighZ = player.getMetadata("Pos2Z").get(0).asInt();
|
||||
}
|
||||
}
|
||||
|
||||
final Location pos1 = new Location(player.getWorld(), LowX, LowY, LowZ);
|
||||
final Location pos2 = new Location(player.getWorld(), HighX, HighY, HighZ);
|
||||
|
||||
BlockData blockData = blockType.createBlockData();
|
||||
|
||||
/*
|
||||
* There are alot of for loops at the moment, when i find an easier way to do these other that a load of if statements
|
||||
* then i will change it, but for now its the best way i can think of for doing this.
|
||||
*/
|
||||
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, LowY, z);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, LowY, z);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, HighY, z);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, HighY, z);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
Selection.hide(player, plugin, pos1, pos2);
|
||||
}
|
||||
}, timeout * 20);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected static void hide(Player player, AdvancedPortalsPlugin plugin, Location pos1, Location pos2) {
|
||||
|
||||
int LowX = pos1.getBlockX();
|
||||
int LowY = pos1.getBlockY();
|
||||
int LowZ = pos1.getBlockZ();
|
||||
|
||||
int HighX = pos2.getBlockX();
|
||||
int HighY = pos2.getBlockY();
|
||||
int HighZ = pos2.getBlockZ();
|
||||
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, LowY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, LowY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, HighY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, HighY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
|
||||
import static com.sekwah.advancedportals.bukkit.Settings.PortalConfigOption.*;
|
||||
|
||||
/**
|
||||
* This contains generally used settings mostly
|
||||
*/
|
||||
public class Settings {
|
||||
|
||||
private int currentWarpParticles = 0;
|
||||
|
||||
private int currentWarpSound = 0;
|
||||
|
||||
private String commandLevels = "n";
|
||||
|
||||
private boolean worldEditEnabled = false;
|
||||
|
||||
public enum PortalConfigOption {
|
||||
COMMAND_LEVELS("CommandLevels"),
|
||||
WARP_PARTICLES("WarpParticles"),
|
||||
WARP_SOUND("WarpSound"),
|
||||
WORLDEDIT_INTEGRATION("WorldEditIntegration");
|
||||
|
||||
private final String target;
|
||||
|
||||
PortalConfigOption(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return this.target;
|
||||
}
|
||||
}
|
||||
|
||||
public Settings(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
currentWarpParticles = config.getConfig().getInt(WARP_PARTICLES.value());
|
||||
currentWarpSound = config.getConfig().getInt(WARP_SOUND.value());
|
||||
|
||||
commandLevels = config.getConfig().getString(COMMAND_LEVELS.value(), "opcb");
|
||||
|
||||
worldEditEnabled = config.getConfig().getBoolean(WORLDEDIT_INTEGRATION.value(), false);
|
||||
|
||||
assert commandLevels != null;
|
||||
if(commandLevels.equals("opchek")) {
|
||||
commandLevels = "opcb";
|
||||
config.getConfig().set(COMMAND_LEVELS.value(), "opcb");
|
||||
}
|
||||
if(commandLevels.contains("n") || commandLevels.equals("")) {
|
||||
commandLevels = "n";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandLevels(){
|
||||
return this.commandLevels;
|
||||
}
|
||||
|
||||
public boolean enabledCommandLevel(String level){
|
||||
return this.commandLevels.contains(level);
|
||||
}
|
||||
|
||||
public int getCurrentWarpSound() {
|
||||
return currentWarpSound;
|
||||
}
|
||||
|
||||
public int getCurrentWarpParticles() {
|
||||
return currentWarpParticles;
|
||||
}
|
||||
|
||||
public boolean enabledWorldEditIntegration() {
|
||||
return worldEditEnabled;
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.events;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Trigered whenever a player activates the warp after the tags are handled.
|
||||
*/
|
||||
public class WarpEvent extends Event implements Cancellable {
|
||||
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
private final Player player;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortal portalData;
|
||||
|
||||
private boolean hasWarped = false;
|
||||
|
||||
/*public WarpEvent(Player player, AdvancedPortal portalData) {
|
||||
this.player = player;
|
||||
this.portalData = portalData;
|
||||
}*/
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the event has been cancelled
|
||||
*
|
||||
* @return cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
/*public AdvancedPortal getPortalData() {
|
||||
return portalData;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* This will return true if another plugin has warped the player(and set this to true)
|
||||
*
|
||||
* @return hasWarped
|
||||
*/
|
||||
public boolean getHasWarped() {
|
||||
return hasWarped;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the
|
||||
*
|
||||
* @param warped
|
||||
*/
|
||||
public void setHasWarped(boolean warped) {
|
||||
this.hasWarped = warped;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.portaldata;
|
||||
|
||||
public class PortalArg {
|
||||
|
||||
public final String argName;
|
||||
public final String value;
|
||||
|
||||
public PortalArg(String argName, String value/*, int type*/) {
|
||||
this.argName = argName;
|
||||
this.value = value;
|
||||
// may be used if values need to be 100% not string
|
||||
//this.type = type;
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.portaldata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PortalTags {
|
||||
|
||||
// TODO create a list or hashmap of tags to check for.
|
||||
|
||||
public Map<String, String> tagDesc = new HashMap<String, String>();
|
||||
|
||||
public ArrayList<String> tags = new ArrayList<String>();
|
||||
|
||||
|
||||
public void registerTag(String tagName) {
|
||||
this.registerTag(tagName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will only be used if a /portal tags command is created. The descriptions will be used for help text
|
||||
* so please keep it short.
|
||||
*
|
||||
* @param tagName
|
||||
* @param description
|
||||
*/
|
||||
public void registerTag(String tagName, boolean multiWord, String description) {
|
||||
this.registerTag(tagName, multiWord);
|
||||
}
|
||||
|
||||
public void registerTag(String tagName, boolean multiWord) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.registry;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.api.warphandler.TagHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TagRegistry {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
private final ArrayList<String> tags = new ArrayList<String>();
|
||||
|
||||
private final Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>();
|
||||
|
||||
private final Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>();
|
||||
|
||||
private final Map<String, TagHandler.TagStatus> tagStatus = new HashMap<String, TagHandler.TagStatus>();
|
||||
|
||||
// TODO the event can be used for general data detection and management, but use a TagHandler to make it so they can register
|
||||
// the individual class to handle.
|
||||
|
||||
public TagRegistry(AdvancedPortalsPlugin plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return if the tag has been registered or if it already exists.
|
||||
*/
|
||||
public boolean registerTag(String tag, TagHandler tagHandler){
|
||||
|
||||
if(tag == null){
|
||||
plugin.getLogger().warning("A tag can not be null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(tags.contains(tag)){
|
||||
return false;
|
||||
}
|
||||
|
||||
tags.add(tag);
|
||||
|
||||
if(tagHandler != null && !(tagHandler instanceof TagHandler.Activation) && !(tagHandler instanceof TagHandler.TagStatus) &&
|
||||
!(tagHandler instanceof TagHandler.Creation)){
|
||||
plugin.getLogger().warning("Error with tag: " + tag + ". A tag handler must implement one of the handlers. Not just extend.");
|
||||
if(tagHandler instanceof TagHandler.Activation){
|
||||
tagActivation.put(tag, (TagHandler.Activation) tagHandler);
|
||||
}
|
||||
if(tagHandler instanceof TagHandler.TagStatus){
|
||||
tagStatus.put(tag, (TagHandler.TagStatus) tagHandler);
|
||||
}
|
||||
if(tagHandler instanceof TagHandler.Creation){
|
||||
tagCreation.put(tag, (TagHandler.Creation) tagHandler);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
|
||||
public class ActivationData {
|
||||
|
||||
private boolean warpAllowed = true;
|
||||
|
||||
private WarpedStatus warpStatus = WarpedStatus.INACTIVE;
|
||||
|
||||
private final Portal activePortal;
|
||||
|
||||
/*public ActivationData(Portal portal){
|
||||
this.activePortal = portal;
|
||||
}
|
||||
*/
|
||||
public WarpedStatus getWarped() {
|
||||
return this.warpStatus;
|
||||
}
|
||||
|
||||
public void setWarpStatus(WarpedStatus warped){
|
||||
if(this.warpStatus == WarpedStatus.WARPED || this.warpStatus == WarpedStatus.INACTIVE){
|
||||
return;
|
||||
}
|
||||
this.warpStatus = warped;
|
||||
}
|
||||
|
||||
/**
|
||||
* In case you need to set the status back down a step for whatever reason. However it is not recommended.
|
||||
*
|
||||
* @param warped
|
||||
*/
|
||||
public void setWarpStatusAbsolute(WarpedStatus warped) {
|
||||
this.warpStatus = warped;
|
||||
}
|
||||
|
||||
public boolean getAllowed() {
|
||||
return this.warpAllowed;
|
||||
}
|
||||
|
||||
public void setAllowed(boolean allowed) {
|
||||
this.warpAllowed = allowed;
|
||||
}
|
||||
|
||||
public enum WarpedStatus {
|
||||
/**
|
||||
* Player has moved or something major has happened. (only one of these should activate)
|
||||
*/
|
||||
WARPED,
|
||||
/**
|
||||
* Shows that the portal has been activated even if a major function is not performed.
|
||||
*/
|
||||
ACTIVATED,
|
||||
/**
|
||||
* Nothing has activated on the portal.
|
||||
*/
|
||||
INACTIVE
|
||||
}
|
||||
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.warphandler;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TagHandler {
|
||||
|
||||
/**
|
||||
* When the user wants to activate the tag, not all will support this of course. its just a _ before or after the tag
|
||||
* to specify
|
||||
*/
|
||||
public enum ActivatePref{
|
||||
BEFORE,
|
||||
AFTER,
|
||||
DEFAULT;
|
||||
}
|
||||
|
||||
public interface Creation {
|
||||
|
||||
/**
|
||||
* Example if the player does not have access to use a tag on the portal.
|
||||
*
|
||||
* @param player if null the portal has been created by the server or a plugin
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the portal can be created.
|
||||
*/
|
||||
boolean portalCreated(@Nullable Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Example if the player does not have access to remove the portal.
|
||||
*
|
||||
* @param player if null the portal has been destroyed by the server or a plugin
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the portal can be destroyed.
|
||||
*/
|
||||
boolean portalDestroyed(@Nullable Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
public interface Activation {
|
||||
|
||||
/**
|
||||
* Activates before the main part of portal activation.
|
||||
*
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalPreActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Activates after portal activation
|
||||
*
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalPostActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Activates if the portal is allowed from pre
|
||||
*
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
public interface TagStatus {
|
||||
|
||||
/**
|
||||
* If the user has access to add the tag
|
||||
*
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the tag will be added.
|
||||
*/
|
||||
boolean tagAdded(@Nullable Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* If the user has access to remove the tag
|
||||
*
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the tag will be removed.
|
||||
*/
|
||||
boolean tagRemoved(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.config;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ConfigAccessor {
|
||||
|
||||
private final String fileName;
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
private File configFile;
|
||||
private FileConfiguration fileConfiguration;
|
||||
|
||||
public ConfigAccessor(JavaPlugin plugin, String fileName) {
|
||||
this.plugin = plugin;
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
// gets all of the
|
||||
public void reloadConfig() {
|
||||
if (configFile == null) {
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
if (dataFolder == null)
|
||||
throw new IllegalStateException();
|
||||
configFile = new File(dataFolder, fileName);
|
||||
}
|
||||
fileConfiguration = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Look for defaults in the jar
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(new File(this.getClass()
|
||||
.getClassLoader().getResource(fileName).getPath()));
|
||||
fileConfiguration.setDefaults(defConfig);
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
if (fileConfiguration == null) {
|
||||
this.reloadConfig();
|
||||
}
|
||||
return fileConfiguration;
|
||||
}
|
||||
|
||||
// Saves all the data to the selected yml file
|
||||
public void saveConfig() {
|
||||
if (fileConfiguration == null || configFile == null) {
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
getConfig().save(configFile);
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Saves
|
||||
|
||||
/**
|
||||
* public void saveDefaultConfig() {
|
||||
* if (!configFile.exists()) {
|
||||
* this.plugin.saveResource(fileName, false);
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
// New save default config saving code, it checks if the needed config is in the jar file before
|
||||
// overriding it.
|
||||
public void saveDefaultConfig() {
|
||||
if (configFile == null) {
|
||||
configFile = new File(plugin.getDataFolder(), fileName);
|
||||
}
|
||||
if (!configFile.exists()) {
|
||||
plugin.saveResource(fileName, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.config;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class ConfigHelper {
|
||||
|
||||
public static final String CONFIG_VERSION = "ConfigVersion";
|
||||
|
||||
public static final String COMMAND_LOGS = "CommandLogs";
|
||||
|
||||
public static final String ENABLE_PROXY_SUPPORT = "EnableProxySupport";
|
||||
public static final String FORCE_ENABLE_PROXY_SUPPORT = "ForceEnableProxySupport";
|
||||
public static final String DISABLE_PROXY_WARNING = "DisableProxyWarning";
|
||||
|
||||
public static final String PROXY_TELEPORT_DELAY = "ProxyTeleportDelay";
|
||||
|
||||
public static final String DISABLE_GATEWAY_BEAM = "DisableGatewayBeam";
|
||||
|
||||
private final FileConfiguration config;
|
||||
|
||||
public ConfigHelper(FileConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively for each time there is a future update
|
||||
*/
|
||||
public void update() {
|
||||
String configVersion = config.getString(CONFIG_VERSION);
|
||||
// Added in 0.5.4
|
||||
if(configVersion == null || configVersion.equals("true") || configVersion.equals("0.5.3")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.4");
|
||||
|
||||
config.set(ConfigHelper.DISABLE_GATEWAY_BEAM, true);
|
||||
update();
|
||||
} else if(configVersion.equals("0.5.4")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.11");
|
||||
config.set(ConfigHelper.COMMAND_LOGS, true);
|
||||
update();
|
||||
} else if(configVersion.equals("0.5.10") || configVersion.equals("0.5.11")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.13");
|
||||
config.set(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT, false);
|
||||
config.set(ConfigHelper.PROXY_TELEPORT_DELAY, 0);
|
||||
update();
|
||||
} else if(configVersion.equals("0.5.13")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.14");
|
||||
config.set(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT, null);
|
||||
config.set(ConfigHelper.ENABLE_PROXY_SUPPORT, config.getBoolean(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Destination {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
|
||||
private static boolean TELEPORT_RIDING = false;
|
||||
public static int PORTAL_MESSAGE_DISPLAY = 0;
|
||||
|
||||
public static void init(AdvancedPortalsPlugin plugin) {
|
||||
Destination.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
ConfigAccessor messagesConfig = new ConfigAccessor(plugin, "messages.yml");
|
||||
|
||||
TELEPORT_RIDING = config.getConfig().getBoolean("WarpRiddenEntity");
|
||||
PORTAL_MESSAGE_DISPLAY = messagesConfig.getConfig().getInt("WarpMessageDisplay");
|
||||
}
|
||||
|
||||
// TODO add permissions for destinations.
|
||||
|
||||
// TODO try keeping the chunks loaded and add different delays to events to make
|
||||
// the horse teleport when you have more time.(its an annoying bug caused by changed)
|
||||
// in mc
|
||||
|
||||
public static void create(Location location, String name) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", location.getY());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", location.getZ());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", location.getPitch());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", location.getYaw());
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void move(Location location, String name) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", location.getY());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", location.getZ());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", location.getPitch());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", location.getYaw());
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void rename(String oldName, String newName) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".world", config.getConfig().getString(oldName + ".world"));
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.X", config.getConfig().getDouble(oldName + ".pos.X"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.Y", config.getConfig().getDouble(oldName + ".pos.Y"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.Z", config.getConfig().getDouble(oldName + ".pos.Z"));
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.pitch", config.getConfig().getDouble(oldName + ".pos.pitch"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.yaw", config.getConfig().getDouble(oldName + ".pos.yaw"));
|
||||
|
||||
remove(oldName);
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void remove(String name) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase(), null);
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String name) {
|
||||
return warp(player, name, false);
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String name, boolean hideActionBar) {
|
||||
return warp(player, name, null, hideActionBar, false);
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String name, boolean hideActionBar, boolean noEffects) {
|
||||
return warp(player, name, null, hideActionBar, noEffects);
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String dest, AdvancedPortal disp, boolean hideActionbar, boolean noEffects) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if (config.getConfig().getString(dest + ".world") != null) {
|
||||
Location loc = player.getLocation();
|
||||
if (Bukkit.getWorld(config.getConfig().getString(dest + ".world")) != null) {
|
||||
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(dest + ".world")));
|
||||
|
||||
loc.setX(config.getConfig().getDouble(dest + ".pos.X"));
|
||||
loc.setY(config.getConfig().getDouble(dest + ".pos.Y"));
|
||||
loc.setZ(config.getConfig().getDouble(dest + ".pos.Z"));
|
||||
|
||||
loc.setPitch((float) config.getConfig().getDouble(dest + ".pos.pitch"));
|
||||
loc.setYaw((float) config.getConfig().getDouble(dest + ".pos.yaw"));
|
||||
|
||||
if (disp != null && disp.getArg("particlein") != null) {
|
||||
WarpEffects.activateParticle(player, disp.getArg("particlein"));
|
||||
}
|
||||
|
||||
if(!noEffects) {
|
||||
WarpEffects.activateEffect(player);
|
||||
WarpEffects.activateSound(player);
|
||||
}
|
||||
Chunk c = loc.getChunk();
|
||||
Entity riding = player.getVehicle();
|
||||
if (!c.isLoaded()) c.load();
|
||||
|
||||
if (player.getVehicle() != null && TELEPORT_RIDING) {
|
||||
|
||||
riding.eject();
|
||||
riding.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
riding.setPassenger(player);
|
||||
|
||||
} else {
|
||||
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
}
|
||||
|
||||
if (disp != null && disp.getArg("particleout") != null) {
|
||||
WarpEffects.activateParticle(player, disp.getArg("particleout"));
|
||||
}
|
||||
if(!noEffects) {
|
||||
WarpEffects.activateEffect(player);
|
||||
WarpEffects.activateSound(player);
|
||||
}
|
||||
|
||||
if (PORTAL_MESSAGE_DISPLAY == 1) {
|
||||
player.sendMessage("");
|
||||
player.sendMessage(PluginMessages.customPrefix + PluginMessages.getWarpMessage(dest));
|
||||
player.sendMessage("");
|
||||
} else if (PORTAL_MESSAGE_DISPLAY == 2 && !hideActionbar) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(PluginMessages.getWarpMessage(dest)));
|
||||
}
|
||||
|
||||
Location newLoc = player.getLocation();
|
||||
Location newEyeLoc = player.getEyeLocation();
|
||||
UUID uuid = player.getUniqueId();
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (!portal.inPortal.contains(uuid) && !portal.isDelayed()
|
||||
&& (Portal.locationInPortalTrigger(portal, newLoc) || Portal.locationInPortalTrigger(portal, newEyeLoc))) {
|
||||
portal.inPortal.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The destination '" + dest + "' is linked to the world "
|
||||
+ config.getConfig().getString(dest + ".world") + " which doesnt seem to exist any more!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The destination '" + dest + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or that destination doesn't exist!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public DestinationCommand(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("destination").setExecutor(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You cannot use commands with the console.");
|
||||
return true;
|
||||
}
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if (args.length > 0) { switch (args[0].toLowerCase()) {
|
||||
case "create":
|
||||
if (sender.hasPermission("advancedportals.desti")) {
|
||||
if (args.length > 1) {
|
||||
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
|
||||
if (posX == null) {
|
||||
sender.sendMessage(PluginMessages.customPrefix + " You have created a new destination called \u00A7e" + args[1] + "!");
|
||||
Player player = (Player) sender;
|
||||
Destination.create(player.getLocation(), args[1]);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " A destination by that name already exists!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " Please state the name of the destination you would like to create!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission to create destinations!");
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if (sender.hasPermission("advancedportals.desti")) {
|
||||
if (args.length > 1) {
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos.X");
|
||||
if (posX != null) {
|
||||
Destination.remove(args[1]);
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The destination \u00A7e" + args[1] + "\u00A7c has been removed!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No destination by that name exists.");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You need to state the name of the destination you wish to remove.");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission to remove destinations!");
|
||||
}
|
||||
break;
|
||||
case "list":
|
||||
String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a";
|
||||
Object[] destiObj = config.getConfig().getKeys(false).toArray();
|
||||
LinkedList<String> destis = new LinkedList<>();
|
||||
for (Object object : destiObj) {
|
||||
destis.add(object.toString());
|
||||
}
|
||||
Collections.sort(destis);
|
||||
for (Object desti : destis.toArray()) message = message + " " + desti;
|
||||
sender.sendMessage(message);
|
||||
break;
|
||||
case "help":
|
||||
sender.sendMessage(PluginMessages.customPrefix + " Destination Help Menu");
|
||||
sender.sendMessage("\u00A7e\u00A7m----------------------------");
|
||||
sender.sendMessage("\u00A76/" + command + " create \u00A7c[name] \u00A7a- create destination at your location");
|
||||
sender.sendMessage("\u00A76/" + command + " remove \u00A7c[name] \u00A7a- remove destination");
|
||||
sender.sendMessage("\u00A76/" + command + " warp \u00A7c[name] \u00A7a- teleport to destination");
|
||||
sender.sendMessage("\u00A76/" + command + " list \u00A7a- list all destinations");
|
||||
sender.sendMessage("\u00A7e\u00A7m----------------------------");
|
||||
break;
|
||||
case "warp":
|
||||
if (!(sender.hasPermission("advancedportals.warp.*") || sender.hasPermission("advancedportals.warp." + args[1]))) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to warp to " + args[1] + "!");
|
||||
return true;
|
||||
}
|
||||
if(args.length >= 2){
|
||||
Destination.warp((Player) sender, args[1]);
|
||||
}
|
||||
else{
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify a warp location!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
LinkedList<String> autoComplete = new LinkedList<>();
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if(args.length > 1 && args[0].equalsIgnoreCase("warp")){
|
||||
for (String string : config.getConfig().getKeys(false)) {
|
||||
if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string))
|
||||
autoComplete.add(string);
|
||||
}
|
||||
}
|
||||
if (args.length == 1) {
|
||||
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("advancedportals.createportal")) {
|
||||
autoComplete.addAll(Arrays.asList("create", "remove", "help"));
|
||||
}
|
||||
autoComplete.add("warp");
|
||||
}
|
||||
Collections.sort(autoComplete);
|
||||
for (Object result : autoComplete.toArray()) {
|
||||
if (!result.toString().startsWith(args[args.length - 1])) {
|
||||
autoComplete.remove(result);
|
||||
}
|
||||
}
|
||||
return autoComplete;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
public class PortalWarp {
|
||||
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.effects;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WarpEffects {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin = null;
|
||||
|
||||
public boolean oldSoundLoc = true;
|
||||
|
||||
public static Sound[] sounds = new Sound[2];
|
||||
|
||||
public static boolean soundError = false;
|
||||
|
||||
public WarpEffects(AdvancedPortalsPlugin pluginTemp) {
|
||||
|
||||
plugin = pluginTemp;
|
||||
|
||||
//sounds[0] = findSound(plugin, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT");
|
||||
sounds[0] = Sound.ENTITY_ENDERMAN_TELEPORT;
|
||||
|
||||
sounds[1] = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
|
||||
}
|
||||
|
||||
public static Sound findSound(AdvancedPortalsPlugin plugin, String newName, String oldName){
|
||||
Sound soundFound = null;
|
||||
try{
|
||||
soundFound = Sound.valueOf(newName);
|
||||
plugin.getLogger().info(newName + " found");
|
||||
} catch (IllegalArgumentException e) {
|
||||
try {
|
||||
soundFound = Sound.valueOf(oldName);
|
||||
plugin.getLogger().info("Using old effect name: " + oldName);
|
||||
} catch (IllegalArgumentException e2) {
|
||||
plugin.getLogger().warning("There was an error using both the old and new names for " + newName);
|
||||
soundError = true;
|
||||
}
|
||||
}
|
||||
return soundFound;
|
||||
}
|
||||
|
||||
public static void activateEffect(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (plugin.getSettings().getCurrentWarpParticles()){
|
||||
case 1:
|
||||
for(int i = 0; i < 10; i++){
|
||||
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
}
|
||||
loc.add(0D, 1D, 0D);
|
||||
for(int i = 0; i < 10; i++){
|
||||
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void activateParticle(Player player, String particle_name) {
|
||||
Particle particle = Portal.getParticle(particle_name);
|
||||
if(particle == null) {
|
||||
plugin.getLogger().warning("wrong particle name: " + particle_name);
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc_from = player.getLocation();
|
||||
|
||||
World world = player.getWorld();
|
||||
|
||||
world.spawnParticle(particle, loc_from, 100, 1, 1, 1);
|
||||
|
||||
}
|
||||
|
||||
public static void activateSound(Player player) {
|
||||
if(!soundError){
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (plugin.getSettings().getCurrentWarpSound()){
|
||||
case 1:
|
||||
world.playSound(loc, sounds[0], 1F, 1F);
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.injector;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.reflection.ReflectionHelper;
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class PacketInjector {
|
||||
|
||||
private Method getPlayerHandle;
|
||||
private Field playerConnection;
|
||||
private Field networkManager;
|
||||
private Field networkChannel;
|
||||
|
||||
public PacketInjector(AdvancedPortalsPlugin plugin, String bukkitImpl) {
|
||||
String craftBukkitPackage = "org.bukkit.craftbukkit." + bukkitImpl + ".";
|
||||
String minecraftPackage = "net.minecraft.server." + bukkitImpl + ".";
|
||||
|
||||
try {
|
||||
getPlayerHandle = Class.forName(craftBukkitPackage + "entity.CraftPlayer").getMethod("getHandle");
|
||||
playerConnection = Class.forName(minecraftPackage + "EntityPlayer").getField("playerConnection");
|
||||
networkManager = Class.forName(minecraftPackage + "PlayerConnection").getField("networkManager");
|
||||
networkChannel = ReflectionHelper.getFieldByType(Class.forName(minecraftPackage + "NetworkManager"), Channel.class, true);
|
||||
|
||||
} catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
public class BungeeListener implements PluginMessageListener {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public BungeeListener(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// some codes
|
||||
}
|
||||
|
||||
/**
|
||||
* Example forward packet.
|
||||
*
|
||||
* Construct like the forge packets.
|
||||
*
|
||||
* out.writeUTF("Forward"); // So BungeeCord knows to forward it
|
||||
out.writeUTF("ALL");
|
||||
out.writeUTF("MyChannel"); // The channel name to check if this your data
|
||||
|
||||
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
|
||||
DataOutputStream msgout = new DataOutputStream(msgbytes);
|
||||
msgout.writeUTF("Some kind of data here"); // You can do anything you want with msgout
|
||||
msgout.writeShort(123);
|
||||
|
||||
out.writeShort(msgbytes.toByteArray().length);
|
||||
out.write(msgbytes.toByteArray());
|
||||
*
|
||||
*/
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
|
||||
public class FlowStopper implements Listener {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
// The needed config values will be stored so they are easier to access later
|
||||
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("<EFBFBD>eP...
|
||||
private boolean WaterFlow = true;
|
||||
|
||||
public FlowStopper(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.WaterFlow = config.getConfig().getBoolean("StopWaterFlow");
|
||||
|
||||
if (WaterFlow) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
if (Portal.inPortalRegion(event.getBlock().getLocation(), 3) | Portal.inPortalRegion(event.getToBlock().getLocation(), 3))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,400 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.api.events.WarpEvent;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Orientable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityPortalEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Listeners implements Listener {
|
||||
|
||||
private static boolean UseOnlyServerAxe = false;
|
||||
private static Material WandMaterial;
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public static String HAS_WARPED = "hasWarped";
|
||||
public static String LAVA_WARPED = "lavaWarped";
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Listeners(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
if (ItemID == null) {
|
||||
WandMaterial = Material.IRON_AXE;
|
||||
} else {
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
int cleanPeriod = config.getConfig().getInt("CleanUpPeriod", 120);
|
||||
int period = 20 * 60 * cleanPeriod;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new CooldownDataRemovalTask(), period, period);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void reloadValues(AdvancedPortalsPlugin plugin) {
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void spawnMobEvent(CreatureSpawnEvent event) {
|
||||
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NETHER_PORTAL
|
||||
&& Portal.inPortalRegion(event.getLocation(), Portal.getPortalProtectionRadius())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Portal.joinCooldown.put(event.getPlayer().getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeaveEvent(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasMetadata("leaveDesti")) {
|
||||
Destination.warp(player, player.getMetadata("leaveDesti").get(0).asString(),
|
||||
false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoinEvent(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata(HAS_WARPED)) player.removeMetadata(HAS_WARPED, plugin);
|
||||
|
||||
Portal.joinCooldown.put(player.getName(), System.currentTimeMillis());
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Location eyeLoc = player.getEyeLocation();
|
||||
UUID uuid = player.getUniqueId();
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (!portal.inPortal.contains(uuid)
|
||||
&& (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc))) {
|
||||
portal.inPortal.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> playerMap = plugin.getPlayerDestiMap();
|
||||
|
||||
if (playerMap.containsKey(uuid.toString())) {
|
||||
Destination.warp(player, playerMap.get(uuid.toString()), false, true);
|
||||
playerMap.remove(uuid.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onMoveEvent(PlayerMoveEvent event) {
|
||||
// will check if the player is in the portal or not.
|
||||
if (!Portal.portalsActive || event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
checkTriggerLocations(player, false, event.getTo(), player.getEyeLocation());
|
||||
|
||||
}
|
||||
|
||||
public void checkTriggerLocations(Player player, boolean useDelayed, Location... locations) {
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
boolean delayed = portal.isDelayed();
|
||||
if (delayed == useDelayed) {
|
||||
for (Location loc : locations) {
|
||||
if (delayed ? Portal.locationInPortal(portal, loc, 1)
|
||||
: Portal.locationInPortalTrigger(portal, loc)) {
|
||||
|
||||
player.setMetadata(HAS_WARPED, new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveWarpData(player), 10);
|
||||
if (portal.getTriggers().contains(Material.LAVA)) {
|
||||
player.setMetadata(LAVA_WARPED, new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveLavaData(player), 10);
|
||||
}
|
||||
if (portal.inPortal.contains(player.getUniqueId()))
|
||||
return;
|
||||
WarpEvent warpEvent = new WarpEvent(player, portal);
|
||||
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
||||
|
||||
if (!warpEvent.isCancelled())
|
||||
Portal.activate(player, portal);
|
||||
|
||||
if (!delayed)
|
||||
portal.inPortal.add(player.getUniqueId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
portal.inPortal.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CooldownDataRemovalTask implements Runnable {
|
||||
|
||||
private int removed;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean canRemove = true;
|
||||
while (canRemove) {
|
||||
canRemove = Portal.cooldown.entrySet().removeIf(e -> {
|
||||
HashMap<String, Long> cds = e.getValue();
|
||||
if (cds == null) {
|
||||
removed++;
|
||||
return true;
|
||||
} else {
|
||||
cds.entrySet().removeIf(entry -> shouldRemovePortalCooldown(entry));
|
||||
if (cds.isEmpty()) {
|
||||
removed++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure maps are never too big than they need to be
|
||||
if (removed > 16) {
|
||||
resizeMaps();
|
||||
removed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldRemovePortalCooldown(Map.Entry<String, Long> entry) {
|
||||
String portalName = entry.getKey();
|
||||
AdvancedPortal portal = Portal.getPortal(portalName);
|
||||
if (portal != null) {
|
||||
long portalCD = entry.getValue();
|
||||
int diff = (int) ((System.currentTimeMillis() - portalCD) / 1000);
|
||||
int portalCooldown = -1;
|
||||
try {
|
||||
portalCooldown = Integer.parseInt(portal.getArg("cooldowndelay"));
|
||||
return diff >= portalCooldown; // cooldown expired
|
||||
} catch (Exception exc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void resizeMaps() {
|
||||
HashMap<String, HashMap<String, Long>> newCooldowns = new HashMap<String, HashMap<String, Long>>(Math.max(Portal.cooldown.size() * 2, 10));
|
||||
newCooldowns.putAll(Portal.cooldown);
|
||||
Portal.cooldown = newCooldowns;
|
||||
|
||||
HashMap<String, Long> newJoinCooldowns = new HashMap<String, Long>(Math.max(Portal.joinCooldown.size() * 2, 10));
|
||||
newJoinCooldowns.putAll(Portal.joinCooldown);
|
||||
Portal.joinCooldown = newJoinCooldowns;
|
||||
}
|
||||
}
|
||||
|
||||
// These are here because java 7 can only take finals straight into a runnable
|
||||
class RemoveLavaData implements Runnable {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public RemoveLavaData(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.removeMetadata(LAVA_WARPED, plugin);
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveWarpData implements Runnable {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public RemoveWarpData(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player != null && player.isOnline()) {
|
||||
player.removeMetadata(HAS_WARPED, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onCombustEntityEvent(EntityCombustEvent event) {
|
||||
if (event.getEntity() instanceof Player && Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDamEvent(EntityDamageEvent event) {
|
||||
if (event.getEntity() instanceof Player && (event.getCause() == EntityDamageEvent.DamageCause.LAVA
|
||||
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE
|
||||
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||
if (event.getEntity().hasMetadata(LAVA_WARPED)
|
||||
| Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPortalEvent(PlayerPortalEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!player.hasMetadata(HAS_WARPED)) {
|
||||
Location loc = event.getFrom();
|
||||
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
|
||||
|
||||
checkTriggerLocations(player, true, loc, eyeLoc);
|
||||
}
|
||||
|
||||
if (player.hasMetadata(HAS_WARPED) | Portal.inPortalRegion(event.getFrom(), 1))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityPortalEvent(EntityPortalEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if(Portal.locationInPortal(event.getFrom(), 2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onItemInteract(PlayerInteractEvent event) {
|
||||
|
||||
// will detect if the player is using an axe so the points of a portal can be
|
||||
// set
|
||||
// also any other detections such as sign interaction or basic block protection
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasMetadata("selectingPortal")
|
||||
&& (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (Portal.locationInPortal(portal, event.getClickedBlock().getLocation(), 0)) {
|
||||
player.sendMessage(
|
||||
PluginMessages.customPrefix + "\u00A7a You have selected: \u00A7e" + portal.getName());
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, portal.getName())); // adds the
|
||||
// name to
|
||||
// the
|
||||
// metadata
|
||||
// of the
|
||||
// character
|
||||
event.setCancelled(true);
|
||||
player.removeMetadata("selectingPortal", plugin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.sendMessage(PluginMessages.customPrefixFail
|
||||
+ "\u00A7c No portal was selected. If you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.hasPermission("advancedportals.createportal")) {
|
||||
if (!plugin.getSettings().enabledWorldEditIntegration()
|
||||
&& event.getItem() != null && event.getItem().getType() == WandMaterial // was type id
|
||||
&& (!UseOnlyServerAxe || (checkItemForName(event.getItem()) && event.getItem().getItemMeta()
|
||||
.getDisplayName().equals("\u00A7ePortal Region Selector")))) {
|
||||
|
||||
// This checks if the action was a left or right click and if it was directly
|
||||
// effecting a block.
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
Location blockloc = event.getClickedBlock().getLocation();
|
||||
// stores the selection as metadata on the character so then it isn't saved
|
||||
// anywhere, if the player logs out it will
|
||||
// have to be selected again if the player joins, also it does not affect any
|
||||
// other players.
|
||||
player.setMetadata("Pos1X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
|
||||
player.setMetadata("Pos1Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
|
||||
player.setMetadata("Pos1Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
|
||||
player.setMetadata("Pos1World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
|
||||
player.sendMessage(
|
||||
"\u00A7eYou have selected pos1! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY()
|
||||
+ " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
|
||||
|
||||
// Stops the event so the block is not damaged
|
||||
event.setCancelled(true);
|
||||
|
||||
// Returns the event so no more code is executed(stops unnecessary code being
|
||||
// executed)
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Location blockloc = event.getClickedBlock().getLocation();
|
||||
player.setMetadata("Pos2X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
|
||||
player.setMetadata("Pos2Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
|
||||
player.setMetadata("Pos2Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
|
||||
player.setMetadata("Pos2World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
|
||||
player.sendMessage(
|
||||
"\u00A7eYou have selected pos2! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY()
|
||||
+ " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
|
||||
|
||||
// Stops the event so the block is not interacted with
|
||||
event.setCancelled(true);
|
||||
|
||||
// Returns the event so no more code is executed(stops unnecessary code being
|
||||
// executed)
|
||||
}
|
||||
} else if (checkItemForName(event.getItem())
|
||||
&& event.getItem().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer")
|
||||
&& event.getAction() == Action.LEFT_CLICK_BLOCK
|
||||
&& event.getClickedBlock().getType() == Material.NETHER_PORTAL) {
|
||||
BlockData block = event.getClickedBlock().getBlockData();
|
||||
|
||||
if (block instanceof Orientable) {
|
||||
Orientable rotatable = (Orientable) block;
|
||||
if (rotatable.getAxis() == Axis.X) {
|
||||
rotatable.setAxis(Axis.Z);
|
||||
} else {
|
||||
rotatable.setAxis(Axis.X);
|
||||
}
|
||||
event.getClickedBlock().setBlockData(rotatable);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean checkItemForName(ItemStack item) {
|
||||
return item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName();
|
||||
}
|
||||
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PluginMessageReceiver implements PluginMessageListener {
|
||||
|
||||
public static final String ENABLE_MESSAGE = PluginMessages.customPrefixFail + "§c Warning! To avoid vulnerabilities we have disabled proxy messages by default. To enable full proxy features, please change §eEnableProxySupport §cin the config.yml and ensure you have the plugin installed on the proxy.";
|
||||
public static final String WARNING_MESSAGE = PluginMessages.customPrefixFail + "§c Warning! A proxy message was received but proxy plugin support is not enabled. To enable it, please set §eEnableProxySupport §cto true and install the plugin on the proxy. If you do not remember having the proxy plugin, please ignore this message as it may be someone trying to attack your server.";
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
private final int teleportDelay;
|
||||
private boolean isNotifiedAboutEnabling = false;
|
||||
|
||||
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
teleportDelay = config.getConfig().getInt(ConfigHelper.PROXY_TELEPORT_DELAY, 0);
|
||||
if(!plugin.isProxyPluginEnabled()) {
|
||||
Bukkit.getConsoleSender().sendMessage(ENABLE_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
|
||||
if (!channel.equals(BungeeMessages.CHANNEL_NAME)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!plugin.isProxyPluginEnabled()) {
|
||||
if(!isNotifiedAboutEnabling) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!p.isOp()) continue;
|
||||
p.sendMessage(WARNING_MESSAGE);
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(WARNING_MESSAGE);
|
||||
|
||||
isNotifiedAboutEnabling = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
||||
String subchannel = in.readUTF();
|
||||
|
||||
if (subchannel.equals(BungeeMessages.SERVER_DESTI)) {
|
||||
String targetDestination = in.readUTF();
|
||||
String bungeeUUID = in.readUTF();
|
||||
|
||||
Player targetPlayer = this.plugin.getServer().getPlayer(UUID.fromString(bungeeUUID));
|
||||
|
||||
if(teleportDelay <= 0) {
|
||||
teleportPlayerToDesti(targetPlayer, targetDestination, bungeeUUID);
|
||||
} else {
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
teleportPlayerToDesti(targetPlayer, targetDestination, bungeeUUID),
|
||||
20L * teleportDelay
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void teleportPlayerToDesti(Player player, String desti, String bungeeUUID) {
|
||||
if (player != null) {
|
||||
Destination.warp(player, desti, false, true);
|
||||
|
||||
}
|
||||
else {
|
||||
plugin.getPlayerDestiMap().put(bungeeUUID, desti);
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
plugin.getPlayerDestiMap().remove(bungeeUUID),
|
||||
20L * 10
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.EndGateway;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
public class PortalPlacer implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
private final boolean DISABLE_GATEWAY_BEAM;
|
||||
|
||||
public PortalPlacer(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
boolean portalPlace = config.getConfig().getBoolean("CanBuildPortalBlock");
|
||||
|
||||
this.DISABLE_GATEWAY_BEAM = config.getConfig().getBoolean("DisableGatewayBeam", true);
|
||||
|
||||
|
||||
if (portalPlace) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if(event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand() != null &&
|
||||
event.getItemInHand().hasItemMeta()){
|
||||
String name = event.getItemInHand().getItemMeta().getDisplayName();
|
||||
|
||||
if(name == null) return;
|
||||
|
||||
if (name.equals("\u00A75Portal Block Placer")){
|
||||
event.getBlock().setType(Material.NETHER_PORTAL);
|
||||
} else if (name.equals("\u00A78End Portal Block Placer")){
|
||||
event.getBlockPlaced().setType(Material.END_PORTAL);
|
||||
}
|
||||
else if (name.equals("\u00A78Gateway Block Placer")){
|
||||
Block block = event.getBlockPlaced();
|
||||
|
||||
block.setType(Material.END_GATEWAY);
|
||||
if(this.DISABLE_GATEWAY_BEAM) {
|
||||
EndGateway tileState = (EndGateway) block.getState();
|
||||
tileState.setAge(Long.MIN_VALUE);
|
||||
tileState.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if(!this.DISABLE_GATEWAY_BEAM) {
|
||||
return;
|
||||
}
|
||||
BlockState[] tileEntities = event.getChunk().getTileEntities();
|
||||
for(BlockState block : tileEntities) {
|
||||
if(block.getType() == Material.END_GATEWAY) {
|
||||
if(Portal.inPortalRegion(block.getLocation(), 5)) {
|
||||
EndGateway tileState = (EndGateway) block;
|
||||
tileState.setAge(Long.MIN_VALUE);
|
||||
tileState.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Block newBlock = block.getWorld().getBlockAt(block.getLocation());
|
||||
Material material = block.getType();
|
||||
if (material == Material.NETHER_PORTAL && Portal.inPortalRegion(block.getLocation(), Portal.getPortalProtectionRadius()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PortalProtect implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
// The needed config values will be stored so they are easier to access later
|
||||
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("<EFBFBD>eP...
|
||||
private final boolean PortalProtect;
|
||||
private final int PortalProtectionArea;
|
||||
|
||||
public PortalProtect(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.PortalProtect = config.getConfig().getBoolean("PortalProtection", true);
|
||||
|
||||
this.PortalProtectionArea = config.getConfig().getInt("PortalProtectionArea", 5);
|
||||
|
||||
if (PortalProtect) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if(!this.PortalProtect) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!player.hasPermission("advancedportals.build")
|
||||
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(String.join(" ",PluginMessages.customPrefixFail, PluginMessages.getNoBuildPermission()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if(!this.PortalProtect) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (PortalProtect && !player.hasPermission("advancedportals.build")
|
||||
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(String.join(" ",PluginMessages.customPrefixFail, PluginMessages.getNoBuildPermission()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onExplosion(EntityExplodeEvent event) {
|
||||
if(!this.PortalProtect) return;
|
||||
|
||||
List<Block> blockList = event.blockList();
|
||||
for (int i = 0; i < blockList.size(); i++) {
|
||||
Block block = blockList.get(i);
|
||||
if (Portal.inPortalRegion(block.getLocation(), PortalProtectionArea)) {
|
||||
blockList.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,719 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.metrics;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
* <p>
|
||||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
public class Metrics {
|
||||
|
||||
// This ThreadFactory enforces the naming convention for our Threads
|
||||
private final ThreadFactory threadFactory = task -> new Thread(task, "bStats-Metrics");
|
||||
|
||||
// Executor service for requests
|
||||
// We use an executor service because the Bukkit scheduler is affected by server lags
|
||||
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, threadFactory);
|
||||
|
||||
// The version of this bStats class
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
private static final String URL = "https://bStats.org/submitData/bukkit";
|
||||
|
||||
// Is bStats enabled on this server?
|
||||
private boolean enabled;
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests;
|
||||
|
||||
// Should the sent data be logged?
|
||||
private static boolean logSentData;
|
||||
|
||||
// Should the response text be logged?
|
||||
private static boolean logResponseStatusText;
|
||||
|
||||
// The uuid of the server
|
||||
private static String serverUUID;
|
||||
|
||||
// The plugin
|
||||
private final Plugin plugin;
|
||||
|
||||
// The plugin id
|
||||
private final int pluginId;
|
||||
|
||||
// A list with all custom charts
|
||||
private final List<CustomChart> charts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param plugin The plugin which stats should be submitted.
|
||||
* @param pluginId The id of the plugin.
|
||||
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
||||
*/
|
||||
public Metrics(Plugin plugin, int pluginId) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null!");
|
||||
}
|
||||
this.plugin = plugin;
|
||||
this.pluginId = pluginId;
|
||||
|
||||
// Get the config file
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Check if the config file exists
|
||||
if (!config.isSet("serverUuid")) {
|
||||
|
||||
// Add default values
|
||||
config.addDefault("enabled", true);
|
||||
// Every server gets it's unique random id.
|
||||
config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
// Should failed request be logged?
|
||||
config.addDefault("logFailedRequests", false);
|
||||
// Should the sent data be logged?
|
||||
config.addDefault("logSentData", false);
|
||||
// Should the response text be logged?
|
||||
config.addDefault("logResponseStatusText", false);
|
||||
|
||||
// Inform the server owners about bStats
|
||||
config.options().header(
|
||||
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
|
||||
"To honor their work, you should not disable it.\n" +
|
||||
"This has nearly no effect on the server performance!\n" +
|
||||
"Check out https://bStats.org/ to learn more :)"
|
||||
).copyDefaults(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
|
||||
// Load the data
|
||||
enabled = config.getBoolean("enabled", true);
|
||||
serverUUID = config.getString("serverUuid");
|
||||
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
logSentData = config.getBoolean("logSentData", false);
|
||||
logResponseStatusText = config.getBoolean("logResponseStatusText", false);
|
||||
|
||||
if (enabled) {
|
||||
boolean found = false;
|
||||
// Search for all other bStats Metrics classes to see if we are the first one
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
}
|
||||
// Register our service
|
||||
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
|
||||
if (!found) {
|
||||
// We are the first!
|
||||
startSubmitting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if bStats is enabled.
|
||||
*
|
||||
* @return Whether bStats is enabled or not.
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Chart cannot be null!");
|
||||
}
|
||||
charts.add(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Scheduler which submits our data every 30 minutes.
|
||||
*/
|
||||
private void startSubmitting() {
|
||||
final Runnable submitTask = () -> {
|
||||
if (!plugin.isEnabled()) { // Plugin was disabled
|
||||
scheduler.shutdown();
|
||||
return;
|
||||
}
|
||||
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
|
||||
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
|
||||
Bukkit.getScheduler().runTask(plugin, this::submitData);
|
||||
};
|
||||
|
||||
// Many servers tend to restart at a fixed time at xx:00 which causes an uneven distribution of requests on the
|
||||
// bStats backend. To circumvent this problem, we introduce some randomness into the initial and second delay.
|
||||
// WARNING: You must not modify and part of this Metrics class, including the submit delay or frequency!
|
||||
// WARNING: Modifying this code will get your plugin banned on bStats. Just don't do it!
|
||||
long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3));
|
||||
long secondDelay = (long) (1000 * 60 * (Math.random() * 30));
|
||||
scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS);
|
||||
scheduler.scheduleAtFixedRate(submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin specific data.
|
||||
* This method is called using Reflection.
|
||||
*
|
||||
* @return The plugin specific data.
|
||||
*/
|
||||
public JsonObject getPluginData() {
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
String pluginName = plugin.getDescription().getName();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.addProperty("pluginName", pluginName); // Append the name of the plugin
|
||||
data.addProperty("id", pluginId); // Append the id of the plugin
|
||||
data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||
JsonArray customCharts = new JsonArray();
|
||||
for (CustomChart customChart : charts) {
|
||||
// Add the data of the custom charts
|
||||
JsonObject chart = customChart.getRequestJsonObject();
|
||||
if (chart == null) { // If the chart is null, we skip it
|
||||
continue;
|
||||
}
|
||||
customCharts.add(chart);
|
||||
}
|
||||
data.add("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server specific data.
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
private JsonObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount;
|
||||
try {
|
||||
// Around MC 1.8 the return type was changed to a collection from an array,
|
||||
// This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {
|
||||
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = Bukkit.getVersion();
|
||||
String bukkitName = Bukkit.getName();
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
data.addProperty("serverUUID", serverUUID);
|
||||
|
||||
data.addProperty("playerAmount", playerAmount);
|
||||
data.addProperty("onlineMode", onlineMode);
|
||||
data.addProperty("bukkitVersion", bukkitVersion);
|
||||
data.addProperty("bukkitName", bukkitName);
|
||||
|
||||
data.addProperty("javaVersion", javaVersion);
|
||||
data.addProperty("osName", osName);
|
||||
data.addProperty("osArch", osArch);
|
||||
data.addProperty("osVersion", osVersion);
|
||||
data.addProperty("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the data and sends it afterwards.
|
||||
*/
|
||||
private void submitData() {
|
||||
final JsonObject data = getServerData();
|
||||
|
||||
JsonArray pluginData = new JsonArray();
|
||||
// Search for all other bStats Metrics classes to get their plugin data
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
|
||||
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
|
||||
try {
|
||||
Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
|
||||
if (plugin instanceof JsonObject) {
|
||||
pluginData.add((JsonObject) plugin);
|
||||
} else { // old bstats version compatibility
|
||||
try {
|
||||
Class<?> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
|
||||
if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
|
||||
Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
|
||||
jsonStringGetter.setAccessible(true);
|
||||
String jsonString = (String) jsonStringGetter.invoke(plugin);
|
||||
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
|
||||
pluginData.add(object);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// minecraft version 1.14+
|
||||
if (logFailedRequests) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
||||
}
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
}
|
||||
|
||||
data.add("plugins", pluginData);
|
||||
|
||||
// Create a new thread for the connection to the bStats server
|
||||
new Thread(() -> {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data to the bStats server.
|
||||
*
|
||||
* @param plugin Any plugin. It's just used to get a logger instance.
|
||||
* @param data The data to send.
|
||||
* @throws Exception If the request failed.
|
||||
*/
|
||||
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null!");
|
||||
}
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
throw new IllegalAccessException("This method must not be called from the main thread!");
|
||||
}
|
||||
if (logSentData) {
|
||||
plugin.getLogger().info("Sending data to bStats: " + data);
|
||||
}
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
|
||||
// Add headers
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
// Send data
|
||||
connection.setDoOutput(true);
|
||||
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||
outputStream.write(compressedData);
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (logResponseStatusText) {
|
||||
plugin.getLogger().info("Sent data to bStats and received response: " + builder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gzips the given String.
|
||||
*
|
||||
* @param str The string to gzip.
|
||||
* @return The gzipped String.
|
||||
* @throws IOException If the compression failed.
|
||||
*/
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom chart.
|
||||
*/
|
||||
public static abstract class CustomChart {
|
||||
|
||||
// The id of the chart
|
||||
final String chartId;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
*/
|
||||
CustomChart(String chartId) {
|
||||
if (chartId == null || chartId.isEmpty()) {
|
||||
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||
}
|
||||
this.chartId = chartId;
|
||||
}
|
||||
|
||||
private JsonObject getRequestJsonObject() {
|
||||
JsonObject chart = new JsonObject();
|
||||
chart.addProperty("chartId", chartId);
|
||||
try {
|
||||
JsonObject data = getChartData();
|
||||
if (data == null) {
|
||||
// If the data is null we don't send the chart.
|
||||
return null;
|
||||
}
|
||||
chart.add("data", data);
|
||||
} catch (Throwable t) {
|
||||
if (logFailedRequests) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return chart;
|
||||
}
|
||||
|
||||
protected abstract JsonObject getChartData() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple pie.
|
||||
*/
|
||||
public static class SimplePie extends CustomChart {
|
||||
|
||||
private final Callable<String> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimplePie(String chartId, Callable<String> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
String value = callable.call();
|
||||
if (value == null || value.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced pie.
|
||||
*/
|
||||
public static class AdvancedPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom drilldown pie.
|
||||
*/
|
||||
public static class DrilldownPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Map<String, Integer>>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Map<String, Integer>> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean reallyAllSkipped = true;
|
||||
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||
JsonObject value = new JsonObject();
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||
value.addProperty(valueEntry.getKey(), valueEntry.getValue());
|
||||
allSkipped = false;
|
||||
}
|
||||
if (!allSkipped) {
|
||||
reallyAllSkipped = false;
|
||||
values.add(entryValues.getKey(), value);
|
||||
}
|
||||
}
|
||||
if (reallyAllSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom single line chart.
|
||||
*/
|
||||
public static class SingleLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Integer> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SingleLineChart(String chartId, Callable<Integer> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
int value = callable.call();
|
||||
if (value == 0) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom multi line chart.
|
||||
*/
|
||||
public static class MultiLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple bar chart.
|
||||
*/
|
||||
public static class SimpleBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
categoryValues.add(new JsonPrimitive(entry.getValue()));
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced bar chart.
|
||||
*/
|
||||
public static class AdvancedBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, int[]>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, int[]> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, int[]> entry : map.entrySet()) {
|
||||
if (entry.getValue().length == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
for (int categoryValue : entry.getValue()) {
|
||||
categoryValues.add(new JsonPrimitive(categoryValue));
|
||||
}
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.portals;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdvancedPortal {
|
||||
|
||||
private Set<Material> triggers = null;
|
||||
|
||||
private String worldName = null;
|
||||
|
||||
private Location pos1 = null;
|
||||
|
||||
private Location pos2 = null;
|
||||
|
||||
private String portalName = null;
|
||||
|
||||
// TODO store destinations also as variables like portals
|
||||
private String[] destinations = new String[] {}; // Could possibly store the destination name to stop the server having to read the config file
|
||||
|
||||
private String bungee = null; // Could possibly store the bungee server name to stop the server having to read the config file
|
||||
|
||||
// Bungee will be stored inside the destination.
|
||||
|
||||
private PortalArg[] portalArgs = null;
|
||||
|
||||
public HashSet<UUID> inPortal = new HashSet<UUID>();
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, new String[] { destination }, pos1, pos2, portalArgs);
|
||||
}
|
||||
|
||||
// TODO think of relaying out the data input to a more logical format.
|
||||
public AdvancedPortal(String portalName, Material trigger, String[] destinations, Location pos1, Location pos2, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, pos2.getWorld().getName(), portalArgs);
|
||||
this.destinations = destinations;
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, Location pos1, Location pos2, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, pos2.getWorld().getName(), portalArgs);
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, new String[] { destination }, pos1, pos2, worldName, portalArgs);
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, String[] destinations, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, worldName, portalArgs);
|
||||
this.destinations = destinations;
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this(portalName, new HashSet<>(Collections.singletonList(trigger)), pos1, pos2, worldName, portalArgs);
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Set<Material> triggers, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this.portalName = portalName;
|
||||
this.triggers = triggers;
|
||||
this.pos1 = pos1;
|
||||
this.pos2 = pos2;
|
||||
this.worldName = worldName;
|
||||
this.portalArgs = portalArgs;
|
||||
}
|
||||
|
||||
public String getArg(String arg) {
|
||||
for (PortalArg portalArg : this.portalArgs) {
|
||||
if (arg.equals(portalArg.argName)) {
|
||||
return portalArg.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PortalArg[] getArgs(){
|
||||
return this.portalArgs;
|
||||
}
|
||||
|
||||
public boolean hasArg(String arg) {
|
||||
return this.getArg(arg) != null;
|
||||
}
|
||||
|
||||
public Set<Material> getTriggers() {
|
||||
return this.triggers;
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return this.worldName;
|
||||
}
|
||||
|
||||
public Location getPos1() {
|
||||
return this.pos1;
|
||||
}
|
||||
|
||||
public Location getPos2() {
|
||||
return this.pos2;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.portalName;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getDestiation() {
|
||||
if(this.destinations.length == 0) {
|
||||
// backwards compatibility
|
||||
return null;
|
||||
}
|
||||
return String.join(",", this.destinations);
|
||||
}
|
||||
|
||||
public String[] getDestinations() {
|
||||
return this.destinations;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDestiation(String destiation) {
|
||||
if(destiation == null) {
|
||||
// backwards compatibility
|
||||
this.destinations = new String[] {};
|
||||
return;
|
||||
}
|
||||
|
||||
this.destinations = destiation.split(",");
|
||||
}
|
||||
|
||||
public void setDestinations(String[] destinations) {
|
||||
this.destinations = destinations;
|
||||
}
|
||||
|
||||
public String getBungee() {
|
||||
return this.bungee;
|
||||
}
|
||||
|
||||
public void setBungee(String bungee) {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public boolean isDelayed() {
|
||||
return this.hasArg("delayed") && this.getArg("delayed").equalsIgnoreCase("true");
|
||||
}
|
||||
}
|
@ -1,758 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.portals;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Portal {
|
||||
|
||||
public static HashMap<String, Long> joinCooldown = new HashMap<String, Long>();
|
||||
public static HashMap<String, HashMap<String, Long>> cooldown = new HashMap<String, HashMap<String, Long>>();
|
||||
// Config values
|
||||
public static boolean portalsActive = false;
|
||||
public static AdvancedPortal[] portals = new AdvancedPortal[0];
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
public static ConfigAccessor portalData = new ConfigAccessor(plugin, "portals.yml");
|
||||
private static boolean showBungeeMessage;
|
||||
private static double throwback;
|
||||
private static Sound portalSound;
|
||||
private static int portalProtectionRadius;
|
||||
private static boolean blockSpectatorMode;
|
||||
private static int joinCooldownDelay;
|
||||
private static boolean commandLog;
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static void init(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage", false);
|
||||
|
||||
portalProtectionRadius = config.getConfig().getBoolean("PortalProtection") ?
|
||||
config.getConfig().getInt("PortalProtectionArea") : 0;
|
||||
|
||||
throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
|
||||
|
||||
portalSound = WarpEffects.findSound(plugin, "BLOCK_PORTAL_TRAVEL", "PORTAL_TRAVEL");
|
||||
blockSpectatorMode = config.getConfig().getBoolean("BlockSpectatorMode", false);
|
||||
|
||||
joinCooldownDelay = config.getConfig().getInt("PortalCooldown", 5);
|
||||
|
||||
commandLog = config.getConfig().getBoolean(ConfigHelper.COMMAND_LOGS, true);
|
||||
|
||||
Portal.plugin = plugin;
|
||||
Portal.loadPortals();
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be used to move the get keys to different sections
|
||||
* <p>
|
||||
* ConfigurationSection section = portalData.getSection("sectionname");
|
||||
* <p>
|
||||
* section.getKeys(false);
|
||||
*/
|
||||
|
||||
public static void loadPortals() {
|
||||
portalData = new ConfigAccessor(plugin, "portals.yml");
|
||||
Set<String> PortalSet = portalData.getConfig().getKeys(false);
|
||||
if (PortalSet.size() > 0) {
|
||||
portals = new AdvancedPortal[PortalSet.toArray().length];
|
||||
|
||||
/*
|
||||
* for(int i = 0; i <= PortalSet.toArray().length - 1; i++){ portals[i] = new
|
||||
* AdvancedPortal(); }
|
||||
*/
|
||||
|
||||
int portalId = 0;
|
||||
for (Object portal : PortalSet.toArray()) {
|
||||
|
||||
ConfigurationSection portalConfigSection = portalData.getConfig()
|
||||
.getConfigurationSection(portal.toString());
|
||||
|
||||
String blockTypesRaw = portalConfigSection.getString("triggerblock");
|
||||
|
||||
String[] blockTypesString = blockTypesRaw != null ? blockTypesRaw.split(",") : null;
|
||||
|
||||
HashSet<Material> blockTypes = getMaterialSet(blockTypesString);
|
||||
|
||||
if (blockTypes.isEmpty()) {
|
||||
blockTypes.add(Material.NETHER_PORTAL);
|
||||
}
|
||||
|
||||
ConfigurationSection portalArgsConf = portalConfigSection.getConfigurationSection("portalArgs");
|
||||
|
||||
ArrayList<PortalArg> extraData = new ArrayList<>();
|
||||
|
||||
if (portalArgsConf != null) {
|
||||
Set<String> argsSet = portalArgsConf.getKeys(true);
|
||||
|
||||
for (Object argName : argsSet.toArray()) {
|
||||
if (portalArgsConf.isString(argName.toString())) {
|
||||
extraData.add(
|
||||
new PortalArg(argName.toString(), portalArgsConf.getString(argName.toString())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String worldName = portalData.getConfig().getString(portal.toString() + ".world");
|
||||
if (worldName != null) {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
Location pos1 = new Location(world, portalData.getConfig().getInt(portal.toString() + ".pos1.X"),
|
||||
portalData.getConfig().getInt(portal.toString() + ".pos1.Y"),
|
||||
portalData.getConfig().getInt(portal.toString() + ".pos1.Z"));
|
||||
Location pos2 = new Location(world, portalData.getConfig().getInt(portal.toString() + ".pos2.X"),
|
||||
portalData.getConfig().getInt(portal.toString() + ".pos2.Y"),
|
||||
portalData.getConfig().getInt(portal.toString() + ".pos2.Z"));
|
||||
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
extraData.toArray(portalArgs);
|
||||
|
||||
portals[portalId] = new AdvancedPortal(portal.toString(), blockTypes, pos1, pos2, worldName,
|
||||
portalArgs);
|
||||
|
||||
portals[portalId].setBungee(portalConfigSection.getString("bungee"));
|
||||
|
||||
portals[portalId].setDestiation(portalConfigSection.getString("destination"));
|
||||
|
||||
portalId++;
|
||||
} else {
|
||||
AdvancedPortal[] tempPortals = portals;
|
||||
|
||||
portals = new AdvancedPortal[portals.length - 1];
|
||||
|
||||
System.arraycopy(tempPortals, 0, portals, 0, portalId);
|
||||
}
|
||||
}
|
||||
portalsActive = true;
|
||||
} else {
|
||||
portalsActive = false;
|
||||
portals = new AdvancedPortal[0];
|
||||
}
|
||||
}
|
||||
|
||||
public static HashSet<Material> getMaterialSet(String[] blockTypesString) {
|
||||
HashSet<Material> blockTypes = new HashSet<>();
|
||||
|
||||
if (blockTypesString != null) {
|
||||
for (String blockType : blockTypesString) {
|
||||
Material material = Material.getMaterial(blockType);
|
||||
if (material != null) {
|
||||
blockTypes.add(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return blockTypes;
|
||||
}
|
||||
|
||||
public static Particle getParticle(String name) {
|
||||
try {
|
||||
return Particle.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String destination,
|
||||
Set<Material> triggerBlocks, PortalArg... extraData) {
|
||||
return create(pos1, pos2, name, new String[] { destination }, triggerBlocks, extraData);
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String[] destinations,
|
||||
Set<Material> triggerBlocks, PortalArg... extraData) {
|
||||
return create(pos1, pos2, name, destinations, triggerBlocks, null, extraData);
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String destination,
|
||||
Set<Material> triggerBlocks, String serverName, PortalArg... portalArgs) {
|
||||
return create(pos1, pos2, name, new String[] { destination }, triggerBlocks, serverName, portalArgs);
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String[] destinations,
|
||||
Set<Material> triggerBlocks, String serverName, PortalArg... portalArgs) {
|
||||
|
||||
if (!pos1.getWorld().equals(pos2.getWorld())) {
|
||||
plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!");
|
||||
return "\u00A7cPortal creation error, pos1 and pos2 must be in the same world!";
|
||||
}
|
||||
|
||||
int LowX = 0;
|
||||
int LowY = 0;
|
||||
int LowZ = 0;
|
||||
|
||||
int HighX = 0;
|
||||
int HighY = 0;
|
||||
int HighZ = 0;
|
||||
|
||||
if (pos1.getX() > pos2.getX()) {
|
||||
LowX = (int) pos2.getX();
|
||||
HighX = (int) pos1.getX();
|
||||
} else {
|
||||
LowX = (int) pos1.getX();
|
||||
HighX = (int) pos2.getX();
|
||||
}
|
||||
if (pos1.getY() > pos2.getY()) {
|
||||
LowY = (int) pos2.getY();
|
||||
HighY = (int) pos1.getY();
|
||||
} else {
|
||||
LowY = (int) pos1.getY();
|
||||
HighY = (int) pos2.getY();
|
||||
}
|
||||
if (pos1.getZ() > pos2.getZ()) {
|
||||
LowZ = (int) pos2.getZ();
|
||||
HighZ = (int) pos1.getZ();
|
||||
} else {
|
||||
LowZ = (int) pos1.getZ();
|
||||
HighZ = (int) pos2.getZ();
|
||||
}
|
||||
|
||||
Location checkpos1 = new Location(pos1.getWorld(), HighX, HighY, HighZ);
|
||||
Location checkpos2 = new Location(pos2.getWorld(), LowX, LowY, LowZ);
|
||||
|
||||
/*
|
||||
* if (checkPortalOverlap(checkpos1, checkpos2)) {
|
||||
* plugin.getLogger().log(Level.WARNING, "portals must not overlap!"); return
|
||||
* "\u00A7cPortal creation error, portals must not overlap!"; }
|
||||
*/
|
||||
|
||||
portalData.getConfig().set(name + ".world", pos1.getWorld().getName());
|
||||
|
||||
String store = triggerBlocks.stream().map(Enum::name).collect(Collectors.joining(","));
|
||||
portalData.getConfig().set(name + ".triggerblock", store);
|
||||
|
||||
// not renaming config entry for backwards compatibility
|
||||
portalData.getConfig().set(name + ".destination", String.join(",", destinations));
|
||||
|
||||
portalData.getConfig().set(name + ".bungee", serverName);
|
||||
|
||||
portalData.getConfig().set(name + ".pos1.X", HighX);
|
||||
portalData.getConfig().set(name + ".pos1.Y", HighY);
|
||||
portalData.getConfig().set(name + ".pos1.Z", HighZ);
|
||||
|
||||
portalData.getConfig().set(name + ".pos2.X", LowX);
|
||||
portalData.getConfig().set(name + ".pos2.Y", LowY);
|
||||
portalData.getConfig().set(name + ".pos2.Z", LowZ);
|
||||
|
||||
for (PortalArg arg : portalArgs) {
|
||||
portalData.getConfig().set(name + ".portalArgs." + arg.argName, arg.value);
|
||||
}
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
|
||||
return "\u00A7aPortal creation successful!";
|
||||
}
|
||||
|
||||
private static boolean checkPortalOverlap(Location pos1, Location pos2) {
|
||||
|
||||
if (portalsActive) {
|
||||
int portalId = 0;
|
||||
for (@SuppressWarnings("unused")
|
||||
Object portal : Portal.portals) {
|
||||
if (portals[portalId].getWorldName().equals(pos2.getWorld().getName())) { // checks that the cubes arnt
|
||||
// overlapping by seeing if
|
||||
// all 4 corners are not in
|
||||
// side another
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos1().getBlockX(),
|
||||
portals[portalId].getPos1().getBlockY(), portals[portalId].getPos1().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos1().getBlockX(),
|
||||
portals[portalId].getPos1().getBlockY(), portals[portalId].getPos2().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos1().getBlockX(),
|
||||
portals[portalId].getPos2().getBlockY(), portals[portalId].getPos1().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos2().getBlockX(),
|
||||
portals[portalId].getPos1().getBlockY(), portals[portalId].getPos1().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos2().getBlockX(),
|
||||
portals[portalId].getPos2().getBlockY(), portals[portalId].getPos2().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos2().getBlockX(),
|
||||
portals[portalId].getPos1().getBlockY(), portals[portalId].getPos2().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos1().getBlockX(),
|
||||
portals[portalId].getPos2().getBlockY(), portals[portalId].getPos2().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos2().getBlockX(),
|
||||
portals[portalId].getPos2().getBlockY(), portals[portalId].getPos1().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
portalId++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkOverLapPortal(Location pos1, Location pos2, int posX, int posY, int posZ) {
|
||||
if (pos1.getX() >= posX && pos1.getY() >= posX && pos1.getZ() >= posZ) {
|
||||
return (pos2.getX()) <= posX && pos2.getY() <= posY && pos2.getZ() <= posZ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String destination, String serverName,
|
||||
PortalArg... extraData) {
|
||||
return create(pos1, pos2, name, new String[] { destination }, serverName, extraData);
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String[] destinations, String serverName,
|
||||
PortalArg... extraData) { // add stuff for destination names or coordinates
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
|
||||
Material triggerBlockType;
|
||||
String BlockID = config.getConfig().getString("DefaultPortalTriggerBlock");
|
||||
triggerBlockType = Material.getMaterial(BlockID);
|
||||
|
||||
if (triggerBlockType == null) {
|
||||
triggerBlockType = Material.NETHER_PORTAL;
|
||||
}
|
||||
|
||||
return create(pos1, pos2, name, destinations, new HashSet<>(Collections.singletonList(triggerBlockType)),
|
||||
serverName, extraData);
|
||||
}
|
||||
|
||||
public static void redefine(Location pos1, Location pos2, String name) {
|
||||
|
||||
portalData.getConfig().set(name + ".pos1.X", pos1.getX());
|
||||
portalData.getConfig().set(name + ".pos1.Y", pos1.getY());
|
||||
portalData.getConfig().set(name + ".pos1.Z", pos1.getZ());
|
||||
|
||||
portalData.getConfig().set(name + ".pos2.X", pos2.getX());
|
||||
portalData.getConfig().set(name + ".pos2.Y", pos2.getY());
|
||||
portalData.getConfig().set(name + ".pos2.Z", pos2.getZ());
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
|
||||
}
|
||||
|
||||
public static String getDestination(String portalName) {
|
||||
return portalData.getConfig().getString(portalName + ".destination");
|
||||
}
|
||||
|
||||
public static void remove(String name) {
|
||||
|
||||
Object[] keys = portalData.getConfig().getKeys(true).toArray();
|
||||
for (int i = keys.length - 1; i >= 0; i--) {
|
||||
String key = keys[i].toString();
|
||||
if (key.startsWith(name + ".")) {
|
||||
portalData.getConfig().set(key, null);
|
||||
}
|
||||
}
|
||||
portalData.getConfig().set(name, null);
|
||||
|
||||
// TODO add code to check if people have the portal selected and notify if
|
||||
// removed.
|
||||
|
||||
/**
|
||||
* Set<String> keys = portalData.getConfig().getKeys(true); for(String key:
|
||||
* keys){ if(key.startsWith(name)){ portalData.getConfig().set(key, null); } }
|
||||
*/
|
||||
|
||||
/**
|
||||
* portalData.getConfig().set(name + ".world", null);
|
||||
* portalData.getConfig().set(name + ".triggerblock", null);
|
||||
* portalData.getConfig().set(name + ".destination", null);
|
||||
*
|
||||
* portalData.getConfig().set(name + ".pos1.X", null);
|
||||
* portalData.getConfig().set(name + ".pos1.Y", null);
|
||||
* portalData.getConfig().set(name + ".pos1.Z", null);
|
||||
*
|
||||
* portalData.getConfig().set(name + ".pos2.X", null);
|
||||
* portalData.getConfig().set(name + ".pos2.Y", null);
|
||||
* portalData.getConfig().set(name + ".pos2.Z", null);
|
||||
*
|
||||
* portalData.getConfig().set(name + ".pos1", null);
|
||||
* portalData.getConfig().set(name + ".getPos2()", null);
|
||||
*
|
||||
* portalData.getConfig().set(name, null);
|
||||
*/
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
}
|
||||
|
||||
public static AdvancedPortal getPortal(String portalName) {
|
||||
for (AdvancedPortal portalElement : Portal.portals) {
|
||||
if (portalElement.getName().equals(portalName)) {
|
||||
return portalElement;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean portalExists(String portalName) {
|
||||
|
||||
String posX = portalData.getConfig().getString(portalName + ".pos1.X");
|
||||
|
||||
return posX != null;
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, String portalName) {
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (portal.getName().equals(portalName))
|
||||
return activate(player, portal);
|
||||
}
|
||||
plugin.getLogger().log(Level.SEVERE, "Portal not found by name of: " + portalName);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, AdvancedPortal portal, boolean doKnockback) {
|
||||
|
||||
if (blockSpectatorMode && player.getGameMode() == GameMode.SPECTATOR) {
|
||||
player.sendMessage(
|
||||
PluginMessages.customPrefixFail + "\u00A7c You cannot enter a portal in spectator mode!");
|
||||
return false;
|
||||
}
|
||||
|
||||
String permission = portal.getArg("permission");
|
||||
|
||||
boolean invertPermission = false;
|
||||
if(permission != null) {
|
||||
invertPermission = permission.startsWith("!");
|
||||
if (invertPermission) {
|
||||
permission.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
boolean noMessage = permission != null && permission.startsWith("nomsg.");
|
||||
if(noMessage) {
|
||||
permission.substring(6);
|
||||
}
|
||||
|
||||
if (!(permission == null || ((!invertPermission && player.hasPermission(permission)) || (invertPermission && !player.hasPermission(permission))) || player.isOp())) {
|
||||
if(!noMessage) {
|
||||
player.sendMessage(
|
||||
String.join(" ", PluginMessages.customPrefixFail, PluginMessages.getNoPermissionPortal()));
|
||||
failSound(player, portal);
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Long joinCD = joinCooldown.get(player.getName());
|
||||
if (joinCD != null) {
|
||||
int diff = (int) ((System.currentTimeMillis() - joinCD) / 1000);
|
||||
if (diff < joinCooldownDelay) {
|
||||
int time = (joinCooldownDelay - diff);
|
||||
player.sendMessage(PluginMessages.getCooldownProtectionMessage(time));
|
||||
failSound(player, portal);
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
return false;
|
||||
}
|
||||
joinCooldown.remove(player.getName());
|
||||
}
|
||||
|
||||
HashMap<String, Long> cds = cooldown.get(player.getName());
|
||||
if (cds != null) {
|
||||
if (cds.get(portal.getName()) != null) {
|
||||
long portalCD = cds.get(portal.getName());
|
||||
int diff = (int) ((System.currentTimeMillis() - portalCD) / 1000);
|
||||
int portalCooldown = 0; // default cooldowndelay when cooldowndelay is not specified
|
||||
try {
|
||||
portalCooldown = Integer.parseInt(portal.getArg("cooldowndelay"));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (diff < portalCooldown) {
|
||||
int time = (portalCooldown - diff);
|
||||
player.sendMessage(PluginMessages.getCooldownProtectionMessage(time));
|
||||
failSound(player, portal);
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cds == null) {
|
||||
cds = new HashMap<String, Long>();
|
||||
}
|
||||
cds.put(portal.getName(), System.currentTimeMillis());
|
||||
cooldown.put(player.getName(), cds);
|
||||
|
||||
boolean showFailMessage = !portal.hasArg("command.1");
|
||||
|
||||
boolean hasMessage = portal.getArg("message") != null;
|
||||
|
||||
// plugin.getLogger().info(portal.getName() + ":" + portal.getDestiation());
|
||||
boolean warped = false;
|
||||
if (portal.getBungee() != null) {
|
||||
String[] bungeeServers = portal.getBungee().split(",");
|
||||
String bungeeServer = bungeeServers[random.nextInt(bungeeServers.length)];
|
||||
if (showBungeeMessage) {
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + bungeeServer
|
||||
+ "\u00A7a.");
|
||||
}
|
||||
|
||||
if(portal.hasArg("leavedesti")) {
|
||||
player.setMetadata("leaveDesti", new FixedMetadataValue(plugin, portal.getArg("leavedesti")));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
player.removeMetadata("leaveDesti", plugin);
|
||||
}, 20 * 10);
|
||||
}
|
||||
|
||||
if (portal.getDestinations().length != 0) {
|
||||
if(plugin.isProxyPluginEnabled()) {
|
||||
String randomDest = portal.getDestinations()[random.nextInt(portal.getDestinations().length)];
|
||||
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
||||
outForList.writeUTF(BungeeMessages.ENTER_PORTAL);
|
||||
outForList.writeUTF(bungeeServer);
|
||||
outForList.writeUTF(randomDest);
|
||||
outForList.writeUTF(player.getUniqueId().toString());
|
||||
|
||||
player.sendPluginMessage(plugin, BungeeMessages.CHANNEL_NAME, outForList.toByteArray());
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().log(Level.WARNING, "You do not have bungee setup correctly. Cross server destinations won't work.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ByteArrayDataOutput outForSend = ByteStreams.newDataOutput();
|
||||
outForSend.writeUTF("Connect");
|
||||
outForSend.writeUTF(bungeeServer);
|
||||
|
||||
|
||||
|
||||
portal.inPortal.add(player.getUniqueId());
|
||||
player.sendPluginMessage(plugin, "BungeeCord", outForSend.toByteArray());
|
||||
// Down to bungee to sort out the teleporting but yea theoretically they should
|
||||
// warp.
|
||||
} else if (portal.getDestinations().length > 0) {
|
||||
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
|
||||
String randomDest = portal.getDestinations()[random.nextInt(portal.getDestinations().length)];
|
||||
if (configDesti.getConfig().getString(randomDest + ".world") != null) {
|
||||
warped = Destination.warp(player, randomDest, portal, hasMessage, false);
|
||||
if (!warped) {
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
}
|
||||
}
|
||||
} else if (showFailMessage) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail
|
||||
+ "\u00A7c The portal you are trying to use doesn't have a destination!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.getName() + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or portal doesn't exist!");
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
failSound(player, portal);
|
||||
}
|
||||
|
||||
if (portal.hasArg("command.1")) {
|
||||
warped = true;
|
||||
int commandLine = 1;
|
||||
String command = portal.getArg("command." + commandLine);// portalData.getConfig().getString(portal.getName()+
|
||||
// ".portalArgs.command." + commandLine);
|
||||
do {
|
||||
// (?i) makes the search case insensitive
|
||||
command = command.replaceAll("@player", player.getName());
|
||||
if(commandLog) plugin.getLogger().log(Level.INFO, "Portal command: " + command);
|
||||
if (command.startsWith("#") && plugin.getSettings().enabledCommandLevel("c")) {
|
||||
command = command.substring(1);
|
||||
try {
|
||||
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Error while executing: " + command);
|
||||
}
|
||||
} else if (command.startsWith("!") && plugin.getSettings().enabledCommandLevel("o")) {
|
||||
command = command.substring(1);
|
||||
boolean wasOp = player.isOp();
|
||||
if(!wasOp) {
|
||||
try {
|
||||
player.setOp(true);
|
||||
player.chat("/" + command);
|
||||
} finally {
|
||||
player.setOp(false);
|
||||
}
|
||||
} else {
|
||||
player.chat("/" + command);
|
||||
}
|
||||
} else if (command.startsWith("^") && plugin.getSettings().enabledCommandLevel("p")) {
|
||||
command = command.substring(1);
|
||||
PermissionAttachment permissionAttachment = null;
|
||||
try {
|
||||
permissionAttachment = player.addAttachment(plugin, "*", true);
|
||||
player.chat("/" + command);
|
||||
// player.performCommand(command);
|
||||
} finally {
|
||||
player.removeAttachment(permissionAttachment);
|
||||
}
|
||||
} else if (command.startsWith("%") && plugin.getSettings().enabledCommandLevel("b")) {
|
||||
if(plugin.isProxyPluginEnabled()) {
|
||||
command = command.substring(1);
|
||||
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
||||
outForList.writeUTF(BungeeMessages.BUNGEE_COMMAND);
|
||||
outForList.writeUTF(command);
|
||||
player.sendPluginMessage(plugin, BungeeMessages.CHANNEL_NAME, outForList.toByteArray());
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().log(Level.WARNING, "You do not have bungee setup correctly. For security advanced bungee features won't work.");
|
||||
}
|
||||
|
||||
} else {
|
||||
player.chat("/" + command);
|
||||
// player.performCommand(command);
|
||||
}
|
||||
command = portal.getArg("command." + ++commandLine);
|
||||
} while (command != null);
|
||||
}
|
||||
|
||||
if (warped) {
|
||||
if (hasMessage) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||
TextComponent.fromLegacyText(portal.getArg("message").replaceAll("&(?=[0-9a-fk-or])", "\u00A7")));
|
||||
}
|
||||
}
|
||||
|
||||
return warped;
|
||||
}
|
||||
|
||||
private static void failSound(Player player, AdvancedPortal portal) {
|
||||
if (!(portal.getTriggers().contains(Material.NETHER_PORTAL) && player.getGameMode() == GameMode.CREATIVE)) {
|
||||
player.playSound(player.getLocation(), portalSound, 0.2f, new Random().nextFloat() * 0.4F + 0.8F);
|
||||
}
|
||||
}
|
||||
|
||||
public static void rename(String oldName, String newName) {
|
||||
|
||||
// set it so it gets all data from one and puts it into another place
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml");
|
||||
|
||||
Set<String> keys = config.getConfig().getKeys(true);
|
||||
for (String key : keys) {
|
||||
if (key.startsWith(oldName + ".")) {
|
||||
if (config.getConfig().getString(key) != null) {
|
||||
try {
|
||||
int intData = Integer.parseInt(config.getConfig().getString(key));
|
||||
config.getConfig().set(key.replace(oldName + ".", newName + "."), intData);
|
||||
} catch (Exception e) {
|
||||
config.getConfig().set(key.replace(oldName + ".", newName + "."),
|
||||
config.getConfig().getString(key));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.saveConfig();
|
||||
|
||||
remove(oldName);
|
||||
|
||||
}
|
||||
|
||||
public static boolean addCommand(String portalName, String portalCommand) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml");
|
||||
if (portalExists(portalName)) {
|
||||
int commandLine = 0;
|
||||
while (config.getConfig().getString(portalName + ".portalArgs.command." + ++commandLine) != null)
|
||||
; // Loops increasing commandLine till 1 is null
|
||||
config.getConfig().set(portalName + ".portalArgs.command." + commandLine, portalCommand);
|
||||
config.saveConfig();
|
||||
loadPortals();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean inPortalTriggerRegion(Location loc) {
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortalTrigger(portal, loc))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc, int additionalArea) {
|
||||
return portal.getTriggers().contains(loc.getBlock().getType()) && locationInPortal(portal, loc, additionalArea);
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc) {
|
||||
return locationInPortalTrigger(portal, loc, 0);
|
||||
}
|
||||
|
||||
public static boolean inPortalRegion(Location loc, int additionalArea) {
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortal(portal, loc, additionalArea))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortal(Location loc, int additionalArea) {
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortal(portal, loc, additionalArea))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortal(AdvancedPortal portal, Location loc) {
|
||||
return locationInPortal(portal, loc);
|
||||
}
|
||||
|
||||
public static boolean locationInPortal(AdvancedPortal portal, Location loc, int additionalArea) {
|
||||
if (!portalsActive)
|
||||
return false;
|
||||
if (loc.getWorld() != null && portal.getWorldName().equals(loc.getWorld().getName()))
|
||||
if ((portal.getPos1().getX() + 1 + additionalArea) >= loc.getX()
|
||||
&& (portal.getPos1().getY() + 1 + additionalArea) > loc.getY()
|
||||
&& (portal.getPos1().getZ() + 1 + additionalArea) >= loc.getZ())
|
||||
return portal.getPos2().getX() - additionalArea <= loc.getX()
|
||||
&& portal.getPos2().getY() - additionalArea <= loc.getY()
|
||||
&& portal.getPos2().getZ() - additionalArea <= loc.getZ();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void throwPlayerBack(Player player) {
|
||||
// Not ensured to remove them out of the portal, but it makes it feel nicer for
|
||||
// the player.
|
||||
if (throwback > 0) {
|
||||
Vector velocity = player.getLocation().getDirection();
|
||||
player.setVelocity(velocity.setY(0).normalize().multiply(-1).setY(throwback));
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPortalProtectionRadius() {
|
||||
return portalProtectionRadius;
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, AdvancedPortal portal) {
|
||||
return activate(player, portal, true);
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.reflection;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ReflectionHelper {
|
||||
|
||||
public static Field getFieldByType(Class<?> clazz, Class<?> findingType, boolean isAccessable) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for(Field field : fields) {
|
||||
if(field.getType() == findingType && field.isAccessible() == isAccessable) {
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Class<?> findClass(Class<?> classObj, String className){
|
||||
for(Class<?> classes : classObj.getDeclaredClasses()){
|
||||
if(classes.getSimpleName().equals(className)){
|
||||
return classes;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.util;
|
||||
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WorldEditIntegration {
|
||||
private static Region getCurrentSelection(Player player) {
|
||||
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player));
|
||||
try {
|
||||
return localSession.getSelection(BukkitAdapter.adapt(player.getWorld()));
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean validateSelection(Player player) {
|
||||
return getCurrentSelection(player) instanceof CuboidRegion;
|
||||
}
|
||||
|
||||
public static Location getPos1(Player player) {
|
||||
Region currentSelection = getCurrentSelection(player);
|
||||
if (!(currentSelection instanceof CuboidRegion)) return null;
|
||||
return BukkitAdapter.adapt(player.getWorld(), ((CuboidRegion) currentSelection).getPos1());
|
||||
}
|
||||
|
||||
public static Location getPos2(Player player) {
|
||||
Region currentSelection = getCurrentSelection(player);
|
||||
if (currentSelection == null) return null;;
|
||||
return BukkitAdapter.adapt(player.getWorld(), ((CuboidRegion) currentSelection).getPos2());
|
||||
}
|
||||
|
||||
public static void explainRegion(Player player, Location pos1, Location pos2) {
|
||||
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player));
|
||||
RegionSelector selector = new CuboidRegionSelector(BukkitAdapter.adapt(player.getWorld()), BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2));
|
||||
localSession.setRegionSelector(BukkitAdapter.adapt(player.getWorld()), selector);
|
||||
selector.explainRegionAdjust(BukkitAdapter.adapt(player), localSession);
|
||||
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.sekwah.advancedportals.bungee;
|
||||
|
||||
import com.sekwah.advancedportals.bungee.listener.EventListener;
|
||||
import com.sekwah.advancedportals.bungee.listener.PluginMessageReceiver;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AdvancedPortalsPlugin extends Plugin {
|
||||
|
||||
public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
|
||||
// key: UUID (string)
|
||||
// value: [0] targetServer, [1] targetDestination
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getProxy().registerChannel(BungeeMessages.CHANNEL_NAME);
|
||||
|
||||
if(BungeeMessages.CHANNEL_NAME != null)
|
||||
|
||||
getProxy().getPluginManager().registerListener(this, new PluginMessageReceiver(this));
|
||||
getProxy().getPluginManager().registerListener(this, new EventListener(this));
|
||||
|
||||
getLogger().info("\u00A7aAdvanced portals have been successfully enabled!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("\\u00A7cAdvanced portals are being disabled!");
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.sekwah.advancedportals.bungee;
|
||||
|
||||
public class BungeeMessages {
|
||||
|
||||
/**
|
||||
* String in
|
||||
* string bungee server
|
||||
* string desti name
|
||||
* string uuid (of what the server thinks it is)
|
||||
*
|
||||
* String out (to recieving server)
|
||||
* string destination
|
||||
* string uuid
|
||||
* string offline uuid
|
||||
*
|
||||
* String out
|
||||
*/
|
||||
public static String ENTER_PORTAL = "PortalEnter";
|
||||
|
||||
public static String CHANNEL_NAME = "advancedportals:warp";
|
||||
|
||||
|
||||
public static String SERVER_DESTI = "BungeePortal";
|
||||
|
||||
/**
|
||||
* Same in and out. This is read by the bungee
|
||||
* String containing command
|
||||
*/
|
||||
public static String BUNGEE_COMMAND = "BungeeCommand";
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package com.sekwah.advancedportals.bungee.listener;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class EventListener implements Listener {
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public EventListener(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }
|
||||
|
||||
@EventHandler
|
||||
public void onServerConnected(ServerConnectedEvent event) {
|
||||
String uuid = event.getPlayer().getUniqueId().toString();
|
||||
|
||||
String[] val = plugin.PlayerDestiMap.get(uuid);
|
||||
|
||||
if (val != null) {
|
||||
|
||||
// key: UUID (string)
|
||||
// value: [0] targetServer, [1] targetDestination, [2] onlineUUID
|
||||
|
||||
if (event.getServer().getInfo().getName().equalsIgnoreCase(val[0])) {
|
||||
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
|
||||
out.writeUTF(BungeeMessages.SERVER_DESTI);
|
||||
out.writeUTF(val[1]);
|
||||
out.writeUTF(val[2]);
|
||||
|
||||
event.getServer().sendData(BungeeMessages.CHANNEL_NAME, out.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.sekwah.advancedportals.bungee.listener;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PluginMessageReceiver implements Listener {
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }
|
||||
|
||||
@EventHandler
|
||||
public void onMessageReceived(PluginMessageEvent event) {
|
||||
if(!event.getTag().equalsIgnoreCase(BungeeMessages.CHANNEL_NAME)) return;
|
||||
event.setCancelled(true);
|
||||
|
||||
if(!(event.getSender() instanceof Server)) return;
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
||||
String subChannel = in.readUTF();
|
||||
|
||||
if (subChannel.equalsIgnoreCase(BungeeMessages.ENTER_PORTAL)) {
|
||||
String targetServer = in.readUTF();
|
||||
String targetDestination = in.readUTF();
|
||||
String targetUUID = in.readUTF();
|
||||
|
||||
plugin.PlayerDestiMap.put(targetUUID, new String[]{targetServer, targetDestination, targetUUID});
|
||||
|
||||
plugin.getProxy().getScheduler().schedule(plugin, () -> plugin.PlayerDestiMap.remove(targetUUID),
|
||||
10, TimeUnit.SECONDS);
|
||||
}
|
||||
else if (subChannel.equalsIgnoreCase(BungeeMessages.BUNGEE_COMMAND)) {
|
||||
String command = in.readUTF();
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
if (player != null) {
|
||||
// To send command to server the player is currently on in a lazy way
|
||||
//player.chat("/" + command);
|
||||
plugin.getProxy().getPluginManager().dispatchCommand(player, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.events;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Trigered whenever a player activates the warp after the tags are handled.
|
||||
*
|
||||
*
|
||||
* TODO Need to make a custom event handler to be able to register against or something similar like a general events data
|
||||
*/
|
||||
public class WarpEvent /*extends Event implements Cancellable*/ {
|
||||
|
||||
/*private static HandlerList handlers = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
private final Player player;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortal portalData;
|
||||
|
||||
private boolean hasWarped = false;
|
||||
|
||||
*//*public WarpEvent(Player player, AdvancedPortal portalData) {
|
||||
this.player = player;
|
||||
this.portalData = portalData;
|
||||
}*//*
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
*//**
|
||||
* Returns if the event has been cancelled
|
||||
*
|
||||
* @return cancelled
|
||||
*//*
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
*//*public AdvancedPortal getPortalData() {
|
||||
return portalData;
|
||||
}*//*
|
||||
|
||||
*//**
|
||||
* This will return true if another plugin has warped the player(and set this to true)
|
||||
*
|
||||
* @return hasWarped
|
||||
*//*
|
||||
public boolean getHasWarped() {
|
||||
return hasWarped;
|
||||
}
|
||||
|
||||
*//**
|
||||
* If the
|
||||
*
|
||||
* @param warped
|
||||
*//*
|
||||
public void setHasWarped(boolean warped) {
|
||||
this.hasWarped = warped;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
|
||||
public class ActivationData {
|
||||
|
||||
private boolean warpAllowed = true;
|
||||
|
||||
private WarpedStatus warpStatus = WarpedStatus.NOTACTIVATED;
|
||||
|
||||
private final Portal activePortal;
|
||||
|
||||
private PlayerLocation wantedLocation;
|
||||
|
||||
public WarpedStatus getWarped() {
|
||||
return this.warpStatus;
|
||||
}
|
||||
|
||||
public void setWarpStatus(WarpedStatus warped){
|
||||
if(this.warpStatus == WarpedStatus.WARPED || this.warpStatus == WarpedStatus.INACTIVE){
|
||||
return;
|
||||
}
|
||||
this.warpStatus = warped;
|
||||
}
|
||||
|
||||
/**
|
||||
* In case you need to set the status back down a step for whatever reason. However it is not recommended.
|
||||
*
|
||||
* @param warped
|
||||
*/
|
||||
public void setWarpStatusAbsolute(WarpedStatus warped) {
|
||||
this.warpStatus = warped;
|
||||
}
|
||||
|
||||
public boolean getAllowed() {
|
||||
return this.warpAllowed;
|
||||
}
|
||||
|
||||
public void setAllowed(boolean allowed) {
|
||||
this.warpAllowed = allowed;
|
||||
}
|
||||
|
||||
public enum WarpedStatus {
|
||||
/**
|
||||
* Player has moved or something major has happened. (only one of these should activate)
|
||||
*/
|
||||
WARPED,
|
||||
/**
|
||||
* Shows that the portal has been activated even if a major function is not performed.
|
||||
*/
|
||||
ACTIVATED,
|
||||
/**
|
||||
* Nothing has activated on the portal (may need to come up with a new name)
|
||||
*/
|
||||
INACTIVE
|
||||
}
|
||||
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
package com.sekwah.advancedportals.bukkit.api.warphandler;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TagHandler {
|
||||
|
||||
/**
|
||||
* The events for portal creation and destroying
|
||||
*/
|
||||
interface Creation<T> extends TagHandler {
|
||||
|
||||
/**
|
||||
* Example if the player does not have access to use the tag.
|
||||
*
|
||||
* @param player if null then created by the server or a plugin
|
||||
* @param argData
|
||||
*/
|
||||
void created(T target, PlayerContainer player, String argData);
|
||||
|
||||
/**
|
||||
* Example if the player does not have access to remove the portal or destination.
|
||||
*
|
||||
* @param player if null then removed by the server or a plugin
|
||||
* @param argData
|
||||
*/
|
||||
void destroyed(T target, PlayerContainer player, String argData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Order of activation
|
||||
* Portal and Desti:
|
||||
* preActivated
|
||||
* activated
|
||||
* postActivated
|
||||
*
|
||||
* Order of them combined:
|
||||
* Portal.preActivated
|
||||
* Portal.activated - when desti tag is hit (if listed) then next two actions are activated
|
||||
* - Desti.preActivate
|
||||
* - Desti.activate
|
||||
* Portal.postActivate - when desti tag is hit (if listed) then the next action is activated
|
||||
* - Desti.postActivate
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
interface Activation<T> extends TagHandler {
|
||||
|
||||
/**
|
||||
* Activates before the main part of activation. This should be for prechecks e.g. if the player has enough
|
||||
* money before then taking the money in postActivated.
|
||||
*
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*
|
||||
* @return If the tag has allowed the warp
|
||||
*/
|
||||
boolean preActivated(T target, PlayerContainer player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Activates after activation, should be used for actions such as removing money for a teleport.
|
||||
*
|
||||
* Any actions to do with player location should be done in activate
|
||||
*
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void postActivated(T target, PlayerContainer player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Activates if the portal is allowed from preActivating. Should be used to set the intended warp location
|
||||
*
|
||||
* You should do some second checks if it can be dependent on the preActivate, the destination tags will also be
|
||||
* triggered here if a desti is listed.
|
||||
*
|
||||
* (You can still cancel here but it is advised to check properly in preActive)
|
||||
*
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*
|
||||
* @return If the tag has allowed the warp
|
||||
*/
|
||||
boolean activated(T target, PlayerContainer player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
interface TagStatus<T> extends TagHandler {
|
||||
|
||||
/**
|
||||
* If the user has access to add the tag (this does not include being added on creation)
|
||||
*
|
||||
* @param player
|
||||
* @param argData
|
||||
* @return if the tag will be added.
|
||||
*/
|
||||
boolean tagAdded(T target, PlayerContainer player, String argData);
|
||||
|
||||
/**
|
||||
* If the user has access to remove the tag (this does not include being added on destruction)
|
||||
*
|
||||
* @param player
|
||||
* @param argData
|
||||
* @return if the tag will be removed.
|
||||
*/
|
||||
boolean tagRemoved(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package com.sekwah.advancedportals.core.connector.container;
|
||||
|
||||
import com.sekwah.advancedportals.core.entities.PlayerLocation;
|
||||
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Just a temporary container for whenever advanced portals needs to get data from a player
|
||||
*/
|
||||
public interface PlayerContainer {
|
||||
|
||||
UUID getUUID();
|
||||
|
||||
public void sendMessage(String message);
|
||||
|
||||
boolean isOp();
|
||||
|
||||
PlayerLocation getLoc();
|
||||
|
||||
double getEyeHeight();
|
||||
|
||||
void teleport(PlayerLocation location);
|
||||
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
WorldContainer getWorld();
|
||||
|
||||
/**
|
||||
* @param blockPos
|
||||
* @param material
|
||||
*/
|
||||
void sendFakeBlock(PortalLocation blockPos, String material);
|
||||
|
||||
/**
|
||||
* Only 1.12 and below supported
|
||||
* @param blockPos
|
||||
* @param material
|
||||
* @param data
|
||||
*/
|
||||
void sendFakeBlockWithData(PortalLocation blockPos, String material, byte data);
|
||||
|
||||
void giveWool(String dyeColor, String itemName, String... itemDescription);
|
||||
|
||||
public void giveItem(String material, String itemName, String... itemDescription) {
|
||||
ItemStack regionselector = new ItemStack(Material.getMaterial(material));
|
||||
ItemMeta selectorname = regionselector.getItemMeta();
|
||||
selectorname.setDisplayName(itemName);
|
||||
selectorname.setLore(Arrays.asList(itemDescription));
|
||||
regionselector.setItemMeta(selectorname);
|
||||
this.player.getInventory().addItem(regionselector);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.sekwah.advancedportals.core.connector.container;
|
||||
|
||||
import com.sekwah.advancedportals.core.data.PortalLocation;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.material.Directional;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
public interface WorldContainer {
|
||||
|
||||
void setBlock(PortalLocation location, String material);
|
||||
|
||||
void setBlockData(PortalLocation location, byte data);
|
||||
|
||||
String getBlock(PortalLocation location);
|
||||
|
||||
byte getBlockData(PortalLocation location);
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
package com.sekwah.advancedportals.velocity;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* While there may be a better way to do this for now we are keeping the behavior so it also works with Bungee's horrible API.
|
||||
*/
|
||||
@Plugin(authors = {"sekwah41"} ,id = "advancedportals", name = "Advanced Portals",
|
||||
url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
|
||||
version = "1.0.0")
|
||||
public class AdvancedPortalsPlugin {
|
||||
|
||||
public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
|
||||
|
||||
private final Logger logger;
|
||||
private final ProxyServer proxy;
|
||||
private LegacyChannelIdentifier AP_CHANNEL;
|
||||
|
||||
@Inject
|
||||
public AdvancedPortalsPlugin(ProxyServer proxy, Logger logger) {
|
||||
|
||||
this.proxy = proxy;
|
||||
this.logger = logger;
|
||||
|
||||
logger.info("\u00A7aAdvanced portals have been successfully enabled!");
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialize(ProxyInitializeEvent event) {
|
||||
|
||||
String[] splitChannel = BungeeMessages.CHANNEL_NAME.split(":");
|
||||
AP_CHANNEL = new LegacyChannelIdentifier(BungeeMessages.CHANNEL_NAME);
|
||||
|
||||
proxy.getChannelRegistrar().register(AP_CHANNEL);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
if(event.getIdentifier().equals(AP_CHANNEL)) {
|
||||
if(event.getSource() instanceof ServerConnection) {
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
||||
|
||||
String subChannel = in.readUTF();
|
||||
|
||||
if (subChannel.equalsIgnoreCase(BungeeMessages.ENTER_PORTAL)) {
|
||||
String targetServer = in.readUTF();
|
||||
String targetDestination = in.readUTF();
|
||||
String targetUUID = in.readUTF();
|
||||
|
||||
PlayerDestiMap.put(targetUUID, new String[]{targetServer, targetDestination, targetUUID});
|
||||
|
||||
proxy.getScheduler().buildTask(this, () -> PlayerDestiMap.remove(targetUUID))
|
||||
.delay(10, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
else if (subChannel.equalsIgnoreCase(BungeeMessages.BUNGEE_COMMAND)) {
|
||||
String command = in.readUTF();
|
||||
ServerConnection connection = (ServerConnection) event.getSource();
|
||||
if(connection.getPlayer() != null) {
|
||||
proxy.getCommandManager().executeAsync(connection.getPlayer(), command);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// So that client packets don't make it through to the servers, always trigger on this channel.
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void postJoinEvent(ServerPostConnectEvent event) {
|
||||
String uuid = event.getPlayer().getUniqueId().toString();
|
||||
|
||||
String[] val = PlayerDestiMap.get(uuid);
|
||||
|
||||
if (val != null) {
|
||||
// key: UUID (string)
|
||||
// value: [0] targetServer, [1] targetDestination, [2] onlineUUID
|
||||
|
||||
event.getPlayer().getCurrentServer().ifPresent(serverConnection -> {
|
||||
|
||||
if (serverConnection.getServerInfo().getName().equalsIgnoreCase(val[0])) {
|
||||
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
|
||||
out.writeUTF(BungeeMessages.SERVER_DESTI);
|
||||
out.writeUTF(val[1]);
|
||||
out.writeUTF(val[2]);
|
||||
|
||||
serverConnection.sendPluginMessage(AP_CHANNEL, out.toByteArray());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 1.0.0
|
||||
author: sekwah41
|
@ -1,91 +0,0 @@
|
||||
# Advanced Portals Config
|
||||
|
||||
# To set this file back to its default state just delete it and reload the server or restart it!
|
||||
|
||||
# Will update whenever there is a config update from an older version so may not be the latest plugin version
|
||||
ConfigVersion: 0.5.14
|
||||
|
||||
# Set to true if you want the normal axes to work normally but the ones given with /portals selector or wand will still work though
|
||||
# It can be useful if people with permission want to use an iron axe on a survival server
|
||||
UseOnlyServerMadeAxe: false
|
||||
|
||||
# Preferably an item and not a block but it shouldn't matter
|
||||
AxeItemId: IRON_AXE
|
||||
|
||||
# Will be implemented, so you can give yourself the portal block and build manually with it, so it's easier to make portals with the portal block.
|
||||
CanBuildPortalBlock: true
|
||||
|
||||
# Defines if portals protect themselves
|
||||
PortalProtection: true
|
||||
|
||||
# How many blocks around the portals will be protected from griefing or destruction
|
||||
PortalProtectionArea: 5
|
||||
|
||||
# What the default trigger block is for portals if nothing is defined.
|
||||
DefaultPortalTriggerBlock: PORTAL
|
||||
|
||||
# This stops all water flowing inside a portal area(can be disabled if something like world edit is handling the water flow or you don't want it active)
|
||||
# you want to
|
||||
StopWaterFlow: true
|
||||
|
||||
# This must be a placeable block, or it will not work and may even crash
|
||||
ShowSelectionBlockID: RED_STAINED_GLASS
|
||||
|
||||
# WarpEffect
|
||||
# 0 = disabled(no particles)
|
||||
# 1 = Eye of ender explode effect(loads of portal particles)
|
||||
# adding more soon and may create some custom ones
|
||||
WarpParticles: 1
|
||||
|
||||
# WarpSound generally suggested to keep the same as warpeffect but can usually be used for just the sound and no particle effects
|
||||
# 0 = disabled(no sound)
|
||||
# 1 = Enderman Warp Sound
|
||||
# adding more soon
|
||||
WarpSound: 1
|
||||
|
||||
# In case you want to show the bungee attempting warp message
|
||||
ShowBungeeWarpMessage: false
|
||||
|
||||
# This changes how long the show selection lasts in seconds
|
||||
ShowSelectionShowDuration: 10
|
||||
|
||||
# Use plugin name in the warp messages
|
||||
UseWarpPrefix: true
|
||||
|
||||
BlockSpectatorMode: false
|
||||
|
||||
PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
|
||||
ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback
|
||||
|
||||
# Only disables the gateway block places with "/portal gatewayblock" for now
|
||||
# If you want to replace already made portals just use "/portal disablebeacon" and it will run through all the blocks in the area
|
||||
# Reloading the world or chunks that portals are in will also trigger the beacons to be disabled (this is for efficiency reasons)
|
||||
# However these won't trigger in the spawn chunks as they are loaded before any plugins are.
|
||||
DisableGatewayBeam: true
|
||||
|
||||
# Enable or disable special command portals
|
||||
#
|
||||
# n Disabled none, the best just put this to really make sure the fact none are here is specified. It disables any others too
|
||||
# o enable op command portals
|
||||
# p enable permission command portals
|
||||
# c enable console command portals
|
||||
# b enable bungee command portals
|
||||
#
|
||||
CommandLevels: opcb
|
||||
|
||||
# Should the commands being triggered log in the console? (If you have an active server it may cause a bit of spam)
|
||||
CommandLogs: true
|
||||
|
||||
# If you want to use bungee or velocity features
|
||||
EnableProxySupport: false
|
||||
|
||||
# How many seconds after the proxy event fires should the player be teleported (should help with on spawn plugins and such)
|
||||
# 0 is disabled and anything higher causes a delay.
|
||||
ProxyTeleportDelay: 0
|
||||
|
||||
# Just in case you are not using the proxy and don't want the warning message
|
||||
DisableProxyWarning: false
|
||||
|
||||
# Whether the integration with WorldEdit should be enabled.
|
||||
# This will force AdvancedPortals to use WorldEdit selections.
|
||||
WorldEditIntegration: false
|
@ -1,7 +0,0 @@
|
||||
|
||||
# ExampleDestination:
|
||||
# world: it will be the world name
|
||||
# pos:
|
||||
# X:
|
||||
# Y:
|
||||
# Z:
|
@ -1,29 +0,0 @@
|
||||
# Advanced Portals Messages
|
||||
|
||||
# If this is true a custom prefix can be used, (not fully coded yet!!)
|
||||
|
||||
UseCustomPrefix: false
|
||||
|
||||
CustomPrefix: '&a[&eAdvancedPortals&a]'
|
||||
|
||||
CustomPrefixFail: '&c[&7AdvancedPortals&c]'
|
||||
|
||||
# Message sent to player in chat/action bar on warp
|
||||
WarpMessage: '&aYou have warped to &e<warp>&a.'
|
||||
|
||||
# Where to display the message 0 = disabled(replaces PortalWarpMessages), 1 = in chat and 2 = action bar(1.8 and above only, anything lower will print the message that would
|
||||
# generally on the action bar in the chat without a prefix or extra chat formatting)
|
||||
WarpMessageDisplay: 2
|
||||
|
||||
# Message sent to player that has just joined the server trying to use a portal
|
||||
CooldownProtectionMessage: '&cThere is &e<time>&c join cooldown protection left.'
|
||||
|
||||
# Message sent to player that doesn't have permission to use a portal
|
||||
NoPermissionPortal: '&cYou do not have permission to use this portal!'
|
||||
|
||||
# Message sent to player that has a portal cooldown
|
||||
PortalCooldownMessage: '&cPlease wait &e<time> &cuntil attempting to enter this portal again!'
|
||||
|
||||
# Message sent to player when they attempt to break a block close to a portal
|
||||
NoBuildPermission: '&cYou don''t have permission to build here!'
|
||||
|
@ -1,19 +0,0 @@
|
||||
|
||||
# ExamplePortal:
|
||||
# world: it will be the world name
|
||||
# triggerblock: LAVA # will only be used if the hastriggerblock is true and can be id or text
|
||||
# pos1: # dont mess with the data here, if you do it may stop the portal from working.
|
||||
# X:
|
||||
# Y:
|
||||
# Z:
|
||||
# pos2:
|
||||
# X:
|
||||
# Y:
|
||||
# Z:
|
||||
# destination:
|
||||
# issetpoint: true # if this was false point name would not be used and the coordinates would be saved here, it just adds more customisation.
|
||||
# pointname: examplepoint # if issetpoint is false this wont be here and tppos will be.
|
||||
# tppos:
|
||||
# X:
|
||||
# Y:
|
||||
# Z:
|
@ -5,4 +5,3 @@ version=1.0.0
|
||||
|
||||
github=https://github.com/sekwah41/Advanced-Portals
|
||||
curse_project_id=86001
|
||||
version=1.0.0
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
|
||||
networkTimeout=10000
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
296
gradlew
vendored
296
gradlew
vendored
@ -1,129 +1,78 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@ -132,7 +81,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@ -140,105 +89,84 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
176
gradlew.bat
vendored
176
gradlew.bat
vendored
@ -1,92 +1,84 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
@ -62,15 +62,12 @@ command.create.portal.console= You cannot create a portal using the console.
|
||||
command.create.detailedhelp=Format is /portal create (name) [tag:tagvalue] List tags after create in the format tag:value, if your value needs spaces use the format tag:"value with spaces"
|
||||
command.create.complete= The portal has been successfully created.
|
||||
|
||||
command.createdesti.help=Creates destinations
|
||||
command.createdesti.error= There was an error making the destination
|
||||
command.createdesti.console= You cannot create a destination using the
|
||||
console.
|
||||
command.createdesti.detailedhelp=Format is /desti create (name)
|
||||
[tag:tagvalue] List tags after create in the format tag:value, if your
|
||||
value needs spaces use the format tag:"value with spaces"
|
||||
command.createdesti.complete= The destination has been successfully
|
||||
created.
|
||||
command.create.destination.help=Creates destinations
|
||||
command.create.destination.error= There was a problem making the destination
|
||||
command.create.destination.console= You cannot create a destination using the console.
|
||||
command.create.destination.detailedhelp=Format is /desti create (name) [tag:tagvalue] List tags after create in the format tag:value, if your value needs spaces use the format tag:"value with spaces"
|
||||
command.create.destination.prep=&aCreating destination
|
||||
command.create.destination.complete= The destination has been successfully created.
|
||||
|
||||
command.portal.info.complete= Portal information for &e%1$s&a:
|
||||
command.portal.info.notfound= No portal by the name &e%1$s &cwas found.
|
||||
|
@ -40,9 +40,9 @@ translatedata.replaced= Un nouveau fichier &een_GB&a a bien été enregistré.
|
||||
messageprefix.positive=&a[&7AdvancedPortals&a]
|
||||
messageprefix.negative=&c[&7AdvancedPortals&c]
|
||||
|
||||
logger.pluginenable=Advanced portals have been enabled!
|
||||
logger.plugindisable=Advanced portals are being disabled!
|
||||
logger.plugincrafterror=This version of craftbukkit is not yet supported or something went wrong, please post this message with the version number and the above stacktrace in an issue on GitHub v:%1$s
|
||||
logger.pluginenable=Advanced portals a bien été activé !
|
||||
logger.plugindisable=Advanced portals a bien été désactivé !
|
||||
logger.plugincrafterror=Cette version craftbukkit n'est pas supportée, veuillez poster ce message avec le numéro de version et la pile ci-dessus dans un numéro sur GitHub: v:%1$s
|
||||
|
||||
command.noargs= Vous devez spécifier une sous commande, utilisez &e/%1$s help &cpour avoir la liste des commandes possibles.
|
||||
command.subcommand.invalid= Ce n'est pas une sous commande.
|
||||
@ -61,11 +61,11 @@ command.create.console= Vous ne pouvez pas créer un portail en utilisant la con
|
||||
command.create.detailedhelp=Le format est /portal create (name) [tag:tagvalue]
|
||||
command.create.complete= Le portail a bien été créé.
|
||||
|
||||
command.createdesti.help=Creates destinations
|
||||
command.createdesti.error= There was an error making the destination
|
||||
command.createdesti.console= You cannot create a destination using the console.
|
||||
command.createdesti.detailedhelp=Format is /desti create (name) [tag:tagvalue] List tags after create in the format tag:value, if your value needs spaces use the format tag:"value with spaces"
|
||||
command.createdesti.complete= The destination has been successfully created.
|
||||
command.createdesti.help=Crée une destination
|
||||
command.createdesti.error= Une erreur est survenue en créant la destination:
|
||||
command.createdesti.console= Vous ne pouvez pas créer une destination en utilisant la console.
|
||||
command.createdesti.detailedhelp=Le format est /desti create (name) [tag:tagvalue]
|
||||
command.createdesti.complete= La destination a bien été créée.
|
||||
|
||||
command.create.tags=&aTags:
|
||||
|
||||
|
13
package.json
13
package.json
@ -1,13 +0,0 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"@auto-it/conventional-commits": "11.1.6",
|
||||
"@auto-it/exec": "11.1.6",
|
||||
"@auto-it/first-time-contributor": "11.1.6",
|
||||
"@auto-it/gradle": "11.1.6",
|
||||
"@auto-it/released": "11.1.6",
|
||||
"@auto-it/upload-assets": "11.1.6",
|
||||
"auto": "11.1.6",
|
||||
"conventional-changelog-angular": "5.0.13"
|
||||
},
|
||||
"packageManager": "yarn@4.3.1"
|
||||
}
|
39
pom.xml
39
pom.xml
@ -1,39 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.sekwah.advancedportals</groupId>
|
||||
<artifactId>Advanced-Portals-Spigot</artifactId>
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src/</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/Resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<version>1.0.0-snapshot</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.12.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"commitMessagePrefix": "chore(deps):",
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"automerge": true,
|
||||
"automergeType": "branch",
|
||||
"groupName": "Deps",
|
||||
"schedule": ["every weekend"]
|
||||
}
|
||||
]
|
||||
}
|
@ -2,11 +2,15 @@ package com.sekwah.advancedportals.spigot;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||
import com.sekwah.advancedportals.core.util.DataStorage;
|
||||
import com.sekwah.advancedportals.coreconnector.ConnectorDataCollector;
|
||||
import com.sekwah.advancedportals.coreconnector.command.CommandRegister;
|
||||
import com.sekwah.advancedportals.metrics.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.sekwah.advancedportals.core.connector.commands.CommandRegister;
|
||||
import com.sekwah.advancedportals.core.module.AdvancedPortalsModule;
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.util.GameScheduler;
|
||||
import com.sekwah.advancedportals.spigot.commands.subcommands.portal.ImportPortalSubCommand;
|
||||
import com.sekwah.advancedportals.spigot.connector.command.SpigotCommandRegister;
|
||||
import com.sekwah.advancedportals.spigot.connector.container.SpigotServerContainer;
|
||||
import com.sekwah.advancedportals.spigot.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.spigot.warpeffects.SpigotWarpEffects;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@ -15,43 +19,63 @@ import java.util.regex.Pattern;
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
private AdvancedPortalsCore portalsCore;
|
||||
|
||||
/**
|
||||
* Readd this when the injector is actually needed.
|
||||
*/
|
||||
//private Injector injector;
|
||||
private static AdvancedPortalsPlugin instance;
|
||||
|
||||
public static AdvancedPortalsPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public AdvancedPortalsPlugin() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
new Metrics(this);
|
||||
|
||||
Metrics metrics = new Metrics(this);
|
||||
Permissions.hasPermissionManager = true;
|
||||
|
||||
Pattern p = Pattern.compile("\\(MC:\\s([0-9].[0-9]+.?[0-9]+)\\)");
|
||||
Matcher m = p.matcher(Bukkit.getVersion());
|
||||
if(m.find()) {
|
||||
String version = m.group(1);
|
||||
String[] versionNums = version.split("\\.");
|
||||
int[] versionInts = new int[versionNums.length];
|
||||
for(int i=0;i <versionNums.length; i++) {
|
||||
versionInts[i] = Integer.parseInt(versionNums[i]);
|
||||
}
|
||||
this.portalsCore = new AdvancedPortalsCore(this.getDataFolder(),
|
||||
new SpigotInfoLogger(this), new SpigotDataCollector(), versionInts);
|
||||
this.portalsCore.registerCommands(new SpigotCommandRegister(this));
|
||||
}
|
||||
else {
|
||||
this.getLogger().warning("Could not parse mc version from: " + Bukkit.getVersion());
|
||||
this.setEnabled(false);
|
||||
}
|
||||
//injector = Guice.createInjector(new RepositoryModule(this.portalsCore));
|
||||
this.getServer().getPluginManager().registerEvents(new Listeners(), this);
|
||||
String mcVersion = this.getServer().getVersion();
|
||||
Pattern pattern = Pattern.compile("\\(MC: ([\\d.]+)\\)");
|
||||
Matcher matcher = pattern.matcher(mcVersion);
|
||||
var serverContainer = new SpigotServerContainer(this.getServer());
|
||||
this.portalsCore = new AdvancedPortalsCore(
|
||||
matcher.find() ? matcher.group(1) : "0.0.0", this.getDataFolder(),
|
||||
new SpigotInfoLogger(this), serverContainer);
|
||||
AdvancedPortalsModule module = this.portalsCore.getModule();
|
||||
|
||||
module.addInstanceBinding(CommandRegister.class,
|
||||
new SpigotCommandRegister(this));
|
||||
|
||||
Injector injector = module.getInjector();
|
||||
|
||||
injector.injectMembers(this.portalsCore);
|
||||
injector.injectMembers(serverContainer);
|
||||
|
||||
Listeners listeners = injector.getInstance(Listeners.class);
|
||||
injector.injectMembers(listeners);
|
||||
this.getServer().getPluginManager().registerEvents(listeners, this);
|
||||
|
||||
GameScheduler scheduler = injector.getInstance(GameScheduler.class);
|
||||
this.getServer().getScheduler().scheduleSyncRepeatingTask(
|
||||
this, scheduler::tick, 1, 1);
|
||||
|
||||
var warpEffects = new SpigotWarpEffects();
|
||||
injector.injectMembers(warpEffects);
|
||||
warpEffects.registerEffects();
|
||||
|
||||
// Try to do this after setting up everything that would need to be
|
||||
// injected to.
|
||||
this.portalsCore.onEnable();
|
||||
|
||||
this.portalsCore.registerPortalCommand("import",
|
||||
new ImportPortalSubCommand());
|
||||
|
||||
new Metrics(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.portalsCore.onDisable();
|
||||
}
|
||||
|
||||
public AdvancedPortalsCore getPortalsCore() {
|
||||
return portalsCore;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.sekwah.advancedportals.spigot;
|
||||
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||
import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.CoreListeners;
|
||||
import com.sekwah.advancedportals.core.data.PortalLocation;
|
||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.spigot.connector.container.SpigotEntityContainer;
|
||||
import com.sekwah.advancedportals.spigot.connector.container.SpigotPlayerContainer;
|
||||
import com.sekwah.advancedportals.spigot.connector.container.SpigotWorldContainer;
|
||||
import com.sekwah.advancedportals.spigot.utils.ContainerHelpers;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -25,8 +30,8 @@ import java.util.List;
|
||||
* others it's easier to just check directly.
|
||||
*/
|
||||
public class Listeners implements Listener {
|
||||
|
||||
private CoreListeners coreListeners = AdvancedPortalsCore.getInstance().getCoreListeners();
|
||||
@Inject
|
||||
private CoreListeners coreListeners;
|
||||
|
||||
@Inject
|
||||
private PortalServices portalServices;
|
||||
@ -45,13 +50,65 @@ public class Listeners implements Listener {
|
||||
coreListeners.playerLeave(new SpigotPlayerContainer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onMoveEvent(PlayerMoveEvent event) {
|
||||
var to = event.getTo();
|
||||
coreListeners.playerMove(new SpigotPlayerContainer(event.getPlayer()),
|
||||
ContainerHelpers.toPlayerLocation(to));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityPortalEvent(EntityPortalEvent event) {
|
||||
if (!this.coreListeners.entityPortalEvent(
|
||||
new SpigotEntityContainer(event.getEntity()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPortalEvent(PlayerPortalEvent event) {
|
||||
if (!this.coreListeners.playerPortalEvent(
|
||||
new SpigotPlayerContainer(event.getPlayer()), ContainerHelpers.toPlayerLocation(event.getFrom()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDamEvent(EntityDamageEvent event) {
|
||||
if (event.getEntity() instanceof Player
|
||||
&& (event.getCause() == EntityDamageEvent.DamageCause.LAVA
|
||||
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE
|
||||
|| event.getCause()
|
||||
== EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||
if (this.coreListeners.preventEntityCombust(
|
||||
new SpigotEntityContainer(event.getEntity()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onCombustEntityEvent(EntityCombustEvent event) {
|
||||
if (this.coreListeners.preventEntityCombust(
|
||||
new SpigotEntityContainer(event.getEntity()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (!event.isCancelled()) {
|
||||
Location blockloc = event.getBlock().getLocation();
|
||||
this.coreListeners.blockPlace(new SpigotPlayerContainer(event.getPlayer()),
|
||||
new PortalLocation(blockloc.getWorld().getName(), blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()), event.getBlockPlaced().getType().toString(),
|
||||
event.getItemInHand().getType().toString(), event.getItemInHand().getItemMeta().getDisplayName());
|
||||
if (!this.coreListeners.blockPlace(
|
||||
new SpigotPlayerContainer(event.getPlayer()),
|
||||
new BlockLocation(
|
||||
blockloc.getWorld().getName(), blockloc.getBlockX(),
|
||||
blockloc.getBlockY(), blockloc.getBlockZ()),
|
||||
event.getBlockPlaced().getType().toString(),
|
||||
event.getItemInHand().getType().toString(),
|
||||
event.getItemInHand().getItemMeta().getDisplayName())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,12 +134,15 @@ public class Listeners implements Listener {
|
||||
|| event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
&& event.getItem() != null) {
|
||||
Location blockloc = event.getClickedBlock().getLocation();
|
||||
boolean allowEvent = this.coreListeners.playerInteractWithBlock(new SpigotPlayerContainer(event.getPlayer()),
|
||||
event.getClickedBlock().getType().toString(),
|
||||
event.getMaterial().toString(),
|
||||
event.getItem().getItemMeta().getDisplayName(),
|
||||
new PortalLocation(blockloc.getWorld().getName(), blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ()),
|
||||
event.getAction() == Action.LEFT_CLICK_BLOCK);
|
||||
boolean allowEvent = this.coreListeners.playerInteractWithBlock(
|
||||
new SpigotPlayerContainer(event.getPlayer()),
|
||||
event.getClickedBlock().getType().toString(),
|
||||
event.getMaterial().toString(),
|
||||
event.getItem().getItemMeta().getDisplayName(),
|
||||
new BlockLocation(blockloc.getWorld().getName(),
|
||||
blockloc.getBlockX(), blockloc.getBlockY(),
|
||||
blockloc.getBlockZ()),
|
||||
event.getAction() == Action.LEFT_CLICK_BLOCK);
|
||||
event.setCancelled(!allowEvent);
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: ${pluginVersion}
|
||||
author: sekwah41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
api-version: 1.13
|
||||
|
||||
softdepend:
|
||||
- WorldEdit
|
||||
|
||||
commands:
|
||||
advancedportals:
|
||||
description: The main command for the advanced portals
|
||||
aliases: [portals, aportals, portal, ap]
|
||||
usage: /<command>
|
||||
permission: advancedportals.portalcommand
|
||||
destination:
|
||||
description: Can be used to access portal destinations.
|
||||
aliases: [desti]
|
||||
usage: /<command>
|
||||
permission: advancedportals.desti
|
||||
permissions:
|
||||
advancedportals.*:
|
||||
description: Gives access to all commands
|
||||
default: op
|
||||
children:
|
||||
advancedportals.createportal: true
|
||||
advancedportals.portal: true
|
||||
advancedportals.build: true
|
||||
advancedportals.desti: true
|
||||
advancedportals.createportal:
|
||||
description: Allows you to create portals
|
||||
default: op
|
||||
advancedportals.createportal.commandlevel.*:
|
||||
description: Gives access to all level raisers
|
||||
default: op
|
||||
children:
|
||||
advancedportals.createportal.commandlevel.op: true
|
||||
advancedportals.createportal.commandlevel.bungee: true
|
||||
advancedportals.createportal.commandlevel.perms: true
|
||||
advancedportals.createportal.commandlevel.console: true
|
||||
advancedportals.createportal.commandlevel.op:
|
||||
description: Allows you to run portal commands as op
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.perms:
|
||||
description: Allows you to run portal commands with * permission
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.bungee:
|
||||
description: Allows you to run portal commands through bungee
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.console:
|
||||
description: Executes command in the console
|
||||
default: false
|
||||
advancedportals.portal:
|
||||
description: Allows use of portal commands
|
||||
default: op
|
||||
advancedportals.portalcommand:
|
||||
description: Access to the portal command. This is seperate to allow access to portal warps without the rest.
|
||||
default: true
|
||||
advancedportals.build:
|
||||
description: Allows you to build in the portal regions
|
||||
default: op
|
||||
advancedportals.desti:
|
||||
description: Gives access to all desti commands
|
||||
default: op
|
||||
advancedportals.warp:
|
||||
description: Access to the warp command
|
||||
default: op
|
||||
advancedportals.warp.*:
|
||||
description: Access to all warps
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user