mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 17:10:03 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c992724456 | ||
|
|
d704732d45 | ||
|
|
7defc8caaf | ||
|
|
986cf367c0 | ||
|
|
482181b77f | ||
|
|
92b9bba37e | ||
|
|
23236a51de | ||
|
|
fed3f65b03 | ||
|
|
b902e0619f | ||
|
|
373ac74666 | ||
|
|
31dd9a4c54 | ||
|
|
9f67bb23ef | ||
|
|
f5d968959c | ||
|
|
a5e31d37f9 | ||
|
|
a9ed8f58b5 | ||
|
|
37a82d3190 | ||
|
|
acb94288d1 | ||
|
|
43be517f4e | ||
|
|
1b42d3a357 | ||
|
|
934295ce7b | ||
|
|
79c4a9e458 | ||
|
|
689d7b1ed9 | ||
|
|
05f670dc91 | ||
|
|
ed5ebd5fe5 | ||
|
|
23326afbba | ||
|
|
3f55a39e68 | ||
|
|
9b913cd999 | ||
|
|
9c4663da08 | ||
|
|
af5aab4cf9 | ||
|
|
f478ded219 | ||
|
|
b60026b205 | ||
|
|
8883ceadda | ||
|
|
19f4383b4c | ||
|
|
648321e41c | ||
|
|
33bd24dce4 | ||
|
|
589b5583d1 | ||
|
|
8aad0d6cf8 | ||
|
|
6ab86569e8 | ||
|
|
7e8b3da5ae | ||
|
|
50371d292a | ||
|
|
69012648c1 | ||
|
|
559855ceb4 | ||
|
|
6c1991a243 | ||
|
|
f94233462d | ||
|
|
d43f56a55c | ||
|
|
dad206b72f | ||
|
|
8630b94419 | ||
|
|
258f188f36 | ||
|
|
5cb575a519 | ||
|
|
11019d3009 | ||
|
|
2716a838f3 | ||
|
|
b754cffe63 | ||
|
|
04ebbc432f | ||
|
|
30fcc786e7 | ||
|
|
fcfd4c9c68 | ||
|
|
750ce0d205 | ||
|
|
074b322ab1 | ||
|
|
d666b428dd | ||
|
|
557e4f9290 | ||
|
|
0d70413e94 | ||
|
|
55f54afd8f | ||
|
|
5d8c3fd505 | ||
|
|
ffb598d52d | ||
|
|
25579f9517 | ||
|
|
92b948a6d7 | ||
|
|
a20653b786 | ||
|
|
4d9e164121 | ||
|
|
f7fb5301d0 | ||
|
|
93f3beab81 | ||
|
|
7fcd6737ff | ||
|
|
5cfa6cc94c | ||
|
|
b4293e03ae | ||
|
|
6d89ef0fe9 | ||
|
|
99ddc4f062 | ||
|
|
6e7a1b9d5e | ||
|
|
27a4d0c37a | ||
|
|
975dfb77d6 | ||
|
|
0b05f42008 | ||
|
|
2fcd32f5a7 | ||
|
|
ba8499af1a | ||
|
|
8abd61e718 | ||
|
|
0baff556d7 | ||
|
|
5acb7ab7a1 | ||
|
|
01cb217eab | ||
|
|
6c67d35394 | ||
|
|
faf78a4350 | ||
|
|
28e0c2d70e | ||
|
|
12b2b14856 | ||
|
|
b07f596f50 | ||
|
|
f41941863e | ||
|
|
be32fae627 | ||
|
|
2a0508e294 | ||
|
|
207ef16375 | ||
|
|
854078e9c2 | ||
|
|
711e00b35d | ||
|
|
55fc4e3d10 | ||
|
|
3cf4486dae | ||
|
|
0597f3b673 | ||
|
|
7aaaa7f59b | ||
|
|
d71afa7acf | ||
|
|
174e9e58c2 | ||
|
|
de08b2f32f | ||
|
|
438bc4522f | ||
|
|
0251c5f1ad | ||
|
|
1738e0fbc9 | ||
|
|
8727149ae9 | ||
|
|
74320203cf | ||
|
|
7f8f6ed6eb | ||
|
|
131e1ffafe | ||
|
|
874c26baee | ||
|
|
75ce6bd9d4 | ||
|
|
6f9507b000 | ||
|
|
e197818451 | ||
|
|
3146ce77f2 | ||
|
|
a9bc7f99b6 | ||
|
|
db4ee25b2f | ||
|
|
2b33013962 | ||
|
|
9bd60cb6f1 | ||
|
|
d0c3d57414 | ||
|
|
dcce6b4eef | ||
|
|
ce40bcf279 | ||
|
|
cc2aa8a5f3 | ||
|
|
27ebcb9f42 | ||
|
|
29087677cc | ||
|
|
52acd791b8 | ||
|
|
d1be259c95 | ||
|
|
031cb599ab | ||
|
|
b1d0953c9d | ||
|
|
8cce203244 | ||
|
|
8d33fdc6d2 | ||
|
|
1cde77e9f8 | ||
|
|
43094c09b9 | ||
|
|
eb46e1a987 | ||
|
|
26c8d4c74f | ||
|
|
ad90b6ad4c | ||
|
|
d1a6c73257 | ||
|
|
3d752092e7 | ||
|
|
f8efcbf154 | ||
|
|
50f425eea1 | ||
|
|
11c8b53b05 | ||
|
|
8d96a7b77b | ||
|
|
d0679d6032 | ||
|
|
75482d0d46 | ||
|
|
5bf5c69aab | ||
|
|
3fdff5801c | ||
|
|
0e126a6c5c | ||
|
|
4fd11f21fa | ||
|
|
5aeced6023 | ||
|
|
103b351f6f | ||
|
|
6cd8b6608d | ||
|
|
9b0ebda9d7 | ||
|
|
e98550a8ff | ||
|
|
77a25ed1f8 | ||
|
|
88d04b9196 | ||
|
|
0e3f1113df | ||
|
|
9c2348149f | ||
|
|
01334fe135 | ||
|
|
61a96aea7f | ||
|
|
cdf1b4ecc7 | ||
|
|
24302b1116 | ||
|
|
8ccff7d29a | ||
|
|
fe55f49f6c | ||
|
|
17220620c7 | ||
|
|
95fa01fecb | ||
|
|
7f9eb235b1 | ||
|
|
5e3dc4890d | ||
|
|
f8f630ab24 | ||
|
|
ecee161f9b | ||
|
|
6bf5879c4f | ||
|
|
b86dc423ea | ||
|
|
fb1462564d | ||
|
|
24570d9a53 | ||
|
|
be7fb62c11 | ||
|
|
dded55aff9 | ||
|
|
64f3d20caa | ||
|
|
d090c081d8 | ||
|
|
1a2c516523 | ||
|
|
06b07d2026 | ||
|
|
39357fc143 | ||
|
|
efeb69ae0b | ||
|
|
282aa76887 | ||
|
|
2770f8e679 | ||
|
|
068263d5d7 | ||
|
|
debca7df24 | ||
|
|
0dc7635839 | ||
|
|
d92a7da900 | ||
|
|
b6af73fa17 | ||
|
|
6ea6880da1 | ||
|
|
c64a6ac4ba | ||
|
|
c2d57e453e | ||
|
|
2f7be9e1c5 | ||
|
|
72b7cd75b3 | ||
|
|
19ad085378 | ||
|
|
09bd126e31 | ||
|
|
7ddcdbe365 | ||
|
|
c756de7abe | ||
|
|
c8ff3fa4d0 | ||
|
|
8f26fadef4 | ||
|
|
7147517b2b | ||
|
|
53da438f56 | ||
|
|
672bee3f9b | ||
|
|
ff3c97d047 | ||
|
|
8318400461 | ||
|
|
f219eac3a2 | ||
|
|
fd1fe596ab | ||
|
|
1b367774ab | ||
|
|
2fa9274a1c | ||
|
|
beeab60add | ||
|
|
404754286d | ||
|
|
855b220b09 | ||
|
|
85ee06f50f | ||
|
|
ca9ded8434 | ||
|
|
19b141b9f5 | ||
|
|
00f185f5f4 | ||
|
|
a27fdaaea0 | ||
|
|
159a04b18f | ||
|
|
065a44dfd3 | ||
|
|
7fb999e483 | ||
|
|
02cc6a4747 | ||
|
|
58b56535aa | ||
|
|
98b8c35ebf | ||
|
|
a2253ffc2d | ||
|
|
f2e5bf32c1 | ||
|
|
2e32ae845a | ||
|
|
36021cc2e0 | ||
|
|
5d31d04822 | ||
|
|
7ee0c82c98 | ||
|
|
16536afdba | ||
|
|
4cf7ff6787 | ||
|
|
62a781a050 | ||
|
|
c59f2363b5 | ||
|
|
d3fb57e5e1 | ||
|
|
242507da7e | ||
|
|
b06c2e95c4 | ||
|
|
14cd13e059 | ||
|
|
e1e90b4a45 | ||
|
|
7f669ace50 | ||
|
|
8aa07be98b |
No files matched your search
@@ -1,14 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: BenCodez # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
#patreon: # Replace with a single Patreon username
|
||||
#open_collective: # Replace with a single Open Collective username
|
||||
#ko_fi: # Replace with a single Ko-fi username
|
||||
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
#liberapay: # Replace with a single Liberapay username
|
||||
#issuehunt: # Replace with a single IssueHunt username
|
||||
#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
#polar: # Replace with a single Polar username
|
||||
#buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
custom: ["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YQBX25RTXJ5DG"]
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Bug report for VotingPlugin
|
||||
title: ''
|
||||
labels: Possible Bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Versions**
|
||||
Plugin version and spigot version.
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots/Configs**
|
||||
If applicable, add screenshots to help explain your problem and/or configs relating to the issue.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea
|
||||
title: ''
|
||||
labels: Possible Feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
name: Question/Concerns
|
||||
about: Ask about a question or a concern about the plugin
|
||||
title: ''
|
||||
labels: Question/Concern
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Versions**
|
||||
Plugin version and spigot version
|
||||
|
||||
**Relevant information**
|
||||
Configs that relate to the issue in a pastebin.
|
||||
|
||||
**Context**
|
||||
Context about the question/concern
|
||||
@@ -1,11 +0,0 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "maven" # See documentation for possible values
|
||||
directory: "/VotingPlugin/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -0,0 +1,51 @@
|
||||
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
|
||||
name: Deploy Jekyll with GitHub Pages dependencies preinstalled
|
||||
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["gh-pages"]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# Build job
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
- name: Build with Jekyll
|
||||
uses: actions/jekyll-build-pages@v1
|
||||
with:
|
||||
source: ./apidocs
|
||||
destination: ./_site
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
|
||||
# Deployment job
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
@@ -1,41 +0,0 @@
|
||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support documentation.
|
||||
|
||||
name: Java CI with Maven
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
permissions:
|
||||
contents: write # required for dependency submission
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B -f VotingPlugin/pom.xml package
|
||||
|
||||
# Only submit dependency snapshot on push (not on pull_request)
|
||||
- name: Submit Dependency Snapshot
|
||||
if: github.event_name == 'push'
|
||||
uses: advanced-security/maven-dependency-submission-action@v5
|
||||
with:
|
||||
directory: VotingPlugin # path to pom.xml
|
||||
# optional: maven-args: "-DskipTests"
|
||||
@@ -1,24 +0,0 @@
|
||||
name: Deploy Javadoc
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy JavaDoc 🚀
|
||||
uses: MathieuSoysal/Javadoc-publisher.yml@main
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
javadoc-branch: gh-pages
|
||||
java-version: 21
|
||||
target-folder: ''
|
||||
project: maven # or gradle
|
||||
# subdirectories: moduleA moduleB #for subdirectories support, needs to be run with custom command
|
||||
custom-command: mvn -f VotingPlugin/pom.xml deploy -P javadoc javadoc:aggregate
|
||||
javadoc-source-folder: 'VotingPlugin/target/reports/apidocs'
|
||||
@@ -1,27 +0,0 @@
|
||||
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
||||
#
|
||||
# You can adjust the behavior by modifying this file.
|
||||
# For more information, see:
|
||||
# https://github.com/actions/stale
|
||||
name: Mark stale issues and pull requests
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '19 16 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v5
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'Stale issue message'
|
||||
stale-pr-message: 'Stale pull request message'
|
||||
stale-issue-label: 'no-issue-activity'
|
||||
stale-pr-label: 'no-pr-activity'
|
||||
-319
@@ -1,319 +0,0 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
Attribution 3.0 Unported
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
||||
DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
||||
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
||||
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
||||
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
||||
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
||||
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
||||
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
||||
CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
||||
other pre-existing works, such as a translation, adaptation,
|
||||
derivative work, arrangement of music or other alterations of a
|
||||
literary or artistic work, or phonogram or performance and includes
|
||||
cinematographic adaptations or any other form in which the Work may be
|
||||
recast, transformed, or adapted including in any form recognizably
|
||||
derived from the original, except that a work that constitutes a
|
||||
Collection will not be considered an Adaptation for the purpose of
|
||||
this License. For the avoidance of doubt, where the Work is a musical
|
||||
work, performance or phonogram, the synchronization of the Work in
|
||||
timed-relation with a moving image ("synching") will be considered an
|
||||
Adaptation for the purpose of this License.
|
||||
b. "Collection" means a collection of literary or artistic works, such as
|
||||
encyclopedias and anthologies, or performances, phonograms or
|
||||
broadcasts, or other works or subject matter other than works listed
|
||||
in Section 1(f) below, which, by reason of the selection and
|
||||
arrangement of their contents, constitute intellectual creations, in
|
||||
which the Work is included in its entirety in unmodified form along
|
||||
with one or more other contributions, each constituting separate and
|
||||
independent works in themselves, which together are assembled into a
|
||||
collective whole. A work that constitutes a Collection will not be
|
||||
considered an Adaptation (as defined above) for the purposes of this
|
||||
License.
|
||||
c. "Distribute" means to make available to the public the original and
|
||||
copies of the Work or Adaptation, as appropriate, through sale or
|
||||
other transfer of ownership.
|
||||
d. "Licensor" means the individual, individuals, entity or entities that
|
||||
offer(s) the Work under the terms of this License.
|
||||
e. "Original Author" means, in the case of a literary or artistic work,
|
||||
the individual, individuals, entity or entities who created the Work
|
||||
or if no individual or entity can be identified, the publisher; and in
|
||||
addition (i) in the case of a performance the actors, singers,
|
||||
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
||||
play in, interpret or otherwise perform literary or artistic works or
|
||||
expressions of folklore; (ii) in the case of a phonogram the producer
|
||||
being the person or legal entity who first fixes the sounds of a
|
||||
performance or other sounds; and, (iii) in the case of broadcasts, the
|
||||
organization that transmits the broadcast.
|
||||
f. "Work" means the literary and/or artistic work offered under the terms
|
||||
of this License including without limitation any production in the
|
||||
literary, scientific and artistic domain, whatever may be the mode or
|
||||
form of its expression including digital form, such as a book,
|
||||
pamphlet and other writing; a lecture, address, sermon or other work
|
||||
of the same nature; a dramatic or dramatico-musical work; a
|
||||
choreographic work or entertainment in dumb show; a musical
|
||||
composition with or without words; a cinematographic work to which are
|
||||
assimilated works expressed by a process analogous to cinematography;
|
||||
a work of drawing, painting, architecture, sculpture, engraving or
|
||||
lithography; a photographic work to which are assimilated works
|
||||
expressed by a process analogous to photography; a work of applied
|
||||
art; an illustration, map, plan, sketch or three-dimensional work
|
||||
relative to geography, topography, architecture or science; a
|
||||
performance; a broadcast; a phonogram; a compilation of data to the
|
||||
extent it is protected as a copyrightable work; or a work performed by
|
||||
a variety or circus performer to the extent it is not otherwise
|
||||
considered a literary or artistic work.
|
||||
g. "You" means an individual or entity exercising rights under this
|
||||
License who has not previously violated the terms of this License with
|
||||
respect to the Work, or who has received express permission from the
|
||||
Licensor to exercise rights under this License despite a previous
|
||||
violation.
|
||||
h. "Publicly Perform" means to perform public recitations of the Work and
|
||||
to communicate to the public those public recitations, by any means or
|
||||
process, including by wire or wireless means or public digital
|
||||
performances; to make available to the public Works in such a way that
|
||||
members of the public may access these Works from a place and at a
|
||||
place individually chosen by them; to perform the Work to the public
|
||||
by any means or process and the communication to the public of the
|
||||
performances of the Work, including by public digital performance; to
|
||||
broadcast and rebroadcast the Work by any means including signs,
|
||||
sounds or images.
|
||||
i. "Reproduce" means to make copies of the Work by any means including
|
||||
without limitation by sound or visual recordings and the right of
|
||||
fixation and reproducing fixations of the Work, including storage of a
|
||||
protected performance or phonogram in digital form or other electronic
|
||||
medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
||||
limit, or restrict any uses free from copyright or rights arising from
|
||||
limitations or exceptions that are provided for in connection with the
|
||||
copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License,
|
||||
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||
perpetual (for the duration of the applicable copyright) license to
|
||||
exercise the rights in the Work as stated below:
|
||||
|
||||
a. to Reproduce the Work, to incorporate the Work into one or more
|
||||
Collections, and to Reproduce the Work as incorporated in the
|
||||
Collections;
|
||||
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
||||
including any translation in any medium, takes reasonable steps to
|
||||
clearly label, demarcate or otherwise identify that changes were made
|
||||
to the original Work. For example, a translation could be marked "The
|
||||
original work was translated from English to Spanish," or a
|
||||
modification could indicate "The original work has been modified.";
|
||||
c. to Distribute and Publicly Perform the Work including as incorporated
|
||||
in Collections; and,
|
||||
d. to Distribute and Publicly Perform Adaptations.
|
||||
e. For the avoidance of doubt:
|
||||
|
||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme cannot be waived, the Licensor
|
||||
reserves the exclusive right to collect such royalties for any
|
||||
exercise by You of the rights granted under this License;
|
||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme can be waived, the Licensor waives the
|
||||
exclusive right to collect such royalties for any exercise by You
|
||||
of the rights granted under this License; and,
|
||||
iii. Voluntary License Schemes. The Licensor waives the right to
|
||||
collect royalties, whether individually or, in the event that the
|
||||
Licensor is a member of a collecting society that administers
|
||||
voluntary licensing schemes, via that society, from any exercise
|
||||
by You of the rights granted under this License.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now
|
||||
known or hereafter devised. The above rights include the right to make
|
||||
such modifications as are technically necessary to exercise the rights in
|
||||
other media and formats. Subject to Section 8(f), all rights not expressly
|
||||
granted by Licensor are hereby reserved.
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made
|
||||
subject to and limited by the following restrictions:
|
||||
|
||||
a. You may Distribute or Publicly Perform the Work only under the terms
|
||||
of this License. You must include a copy of, or the Uniform Resource
|
||||
Identifier (URI) for, this License with every copy of the Work You
|
||||
Distribute or Publicly Perform. You may not offer or impose any terms
|
||||
on the Work that restrict the terms of this License or the ability of
|
||||
the recipient of the Work to exercise the rights granted to that
|
||||
recipient under the terms of the License. You may not sublicense the
|
||||
Work. You must keep intact all notices that refer to this License and
|
||||
to the disclaimer of warranties with every copy of the Work You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Work, You may not impose any effective technological
|
||||
measures on the Work that restrict the ability of a recipient of the
|
||||
Work from You to exercise the rights granted to that recipient under
|
||||
the terms of the License. This Section 4(a) applies to the Work as
|
||||
incorporated in a Collection, but this does not require the Collection
|
||||
apart from the Work itself to be made subject to the terms of this
|
||||
License. If You create a Collection, upon notice from any Licensor You
|
||||
must, to the extent practicable, remove from the Collection any credit
|
||||
as required by Section 4(b), as requested. If You create an
|
||||
Adaptation, upon notice from any Licensor You must, to the extent
|
||||
practicable, remove from the Adaptation any credit as required by
|
||||
Section 4(b), as requested.
|
||||
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||
Collections, You must, unless a request has been made pursuant to
|
||||
Section 4(a), keep intact all copyright notices for the Work and
|
||||
provide, reasonable to the medium or means You are utilizing: (i) the
|
||||
name of the Original Author (or pseudonym, if applicable) if supplied,
|
||||
and/or if the Original Author and/or Licensor designate another party
|
||||
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
||||
attribution ("Attribution Parties") in Licensor's copyright notice,
|
||||
terms of service or by other reasonable means, the name of such party
|
||||
or parties; (ii) the title of the Work if supplied; (iii) to the
|
||||
extent reasonably practicable, the URI, if any, that Licensor
|
||||
specifies to be associated with the Work, unless such URI does not
|
||||
refer to the copyright notice or licensing information for the Work;
|
||||
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
|
||||
a credit identifying the use of the Work in the Adaptation (e.g.,
|
||||
"French translation of the Work by Original Author," or "Screenplay
|
||||
based on original Work by Original Author"). The credit required by
|
||||
this Section 4 (b) may be implemented in any reasonable manner;
|
||||
provided, however, that in the case of a Adaptation or Collection, at
|
||||
a minimum such credit will appear, if a credit for all contributing
|
||||
authors of the Adaptation or Collection appears, then as part of these
|
||||
credits and in a manner at least as prominent as the credits for the
|
||||
other contributing authors. For the avoidance of doubt, You may only
|
||||
use the credit required by this Section for the purpose of attribution
|
||||
in the manner set out above and, by exercising Your rights under this
|
||||
License, You may not implicitly or explicitly assert or imply any
|
||||
connection with, sponsorship or endorsement by the Original Author,
|
||||
Licensor and/or Attribution Parties, as appropriate, of You or Your
|
||||
use of the Work, without the separate, express prior written
|
||||
permission of the Original Author, Licensor and/or Attribution
|
||||
Parties.
|
||||
c. Except as otherwise agreed in writing by the Licensor or as may be
|
||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||
Publicly Perform the Work either by itself or as part of any
|
||||
Adaptations or Collections, You must not distort, mutilate, modify or
|
||||
take other derogatory action in relation to the Work which would be
|
||||
prejudicial to the Original Author's honor or reputation. Licensor
|
||||
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
||||
of the right granted in Section 3(b) of this License (the right to
|
||||
make Adaptations) would be deemed to be a distortion, mutilation,
|
||||
modification or other derogatory action prejudicial to the Original
|
||||
Author's honor and reputation, the Licensor will waive or not assert,
|
||||
as appropriate, this Section, to the fullest extent permitted by the
|
||||
applicable national law, to enable You to reasonably exercise Your
|
||||
right under Section 3(b) of this License (right to make Adaptations)
|
||||
but not otherwise.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
||||
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
||||
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
||||
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
||||
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
||||
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
|
||||
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
||||
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
a. This License and the rights granted hereunder will terminate
|
||||
automatically upon any breach by You of the terms of this License.
|
||||
Individuals or entities who have received Adaptations or Collections
|
||||
from You under this License, however, will not have their licenses
|
||||
terminated provided such individuals or entities remain in full
|
||||
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
||||
survive any termination of this License.
|
||||
b. Subject to the above terms and conditions, the license granted here is
|
||||
perpetual (for the duration of the applicable copyright in the Work).
|
||||
Notwithstanding the above, Licensor reserves the right to release the
|
||||
Work under different license terms or to stop distributing the Work at
|
||||
any time; provided, however that any such election will not serve to
|
||||
withdraw this License (or any other license that has been, or is
|
||||
required to be, granted under the terms of this License), and this
|
||||
License will continue in full force and effect unless terminated as
|
||||
stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||
the Licensor offers to the recipient a license to the Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||
offers to the recipient a license to the original Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
c. If any provision of this License is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this License, and without further action
|
||||
by the parties to this agreement, such provision shall be reformed to
|
||||
the minimum extent necessary to make such provision valid and
|
||||
enforceable.
|
||||
d. No term or provision of this License shall be deemed waived and no
|
||||
breach consented to unless such waiver or consent shall be in writing
|
||||
and signed by the party to be charged with such waiver or consent.
|
||||
e. This License constitutes the entire agreement between the parties with
|
||||
respect to the Work licensed here. There are no understandings,
|
||||
agreements or representations with respect to the Work not specified
|
||||
here. Licensor shall not be bound by any additional provisions that
|
||||
may appear in any communication from You. This License may not be
|
||||
modified without the mutual written agreement of the Licensor and You.
|
||||
f. The rights granted under, and the subject matter referenced, in this
|
||||
License were drafted utilizing the terminology of the Berne Convention
|
||||
for the Protection of Literary and Artistic Works (as amended on
|
||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
||||
and the Universal Copyright Convention (as revised on July 24, 1971).
|
||||
These rights and subject matter take effect in the relevant
|
||||
jurisdiction in which the License terms are sought to be enforced
|
||||
according to the corresponding provisions of the implementation of
|
||||
those treaty provisions in the applicable national law. If the
|
||||
standard suite of rights granted under applicable copyright law
|
||||
includes additional rights not granted under this License, such
|
||||
additional rights are deemed to be included in the License; this
|
||||
License is not intended to restrict the license of any rights under
|
||||
applicable law.
|
||||
|
||||
|
||||
Creative Commons Notice
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty
|
||||
whatsoever in connection with the Work. Creative Commons will not be
|
||||
liable to You or any party on any legal theory for any damages
|
||||
whatsoever, including without limitation any general, special,
|
||||
incidental or consequential damages arising in connection to this
|
||||
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
||||
Commons has expressly identified itself as the Licensor hereunder, it
|
||||
shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the
|
||||
Work is licensed under the CCPL, Creative Commons does not authorize
|
||||
the use by either party of the trademark "Creative Commons" or any
|
||||
related trademark or logo of Creative Commons without the prior
|
||||
written consent of Creative Commons. Any permitted use will be in
|
||||
compliance with Creative Commons' then-current trademark usage
|
||||
guidelines, as may be published on its website or otherwise made
|
||||
available upon request from time to time. For the avoidance of doubt,
|
||||
this trademark restriction does not form part of this License.
|
||||
|
||||
Creative Commons may be contacted at https://creativecommons.org/.
|
||||
@@ -1,22 +0,0 @@
|
||||
# VotingPlugin
|
||||
Plugin on SpigotMC
|
||||
https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
|
||||
### Maven:
|
||||
|
||||
<repository>
|
||||
<id>BenCodez Repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
Versions:
|
||||
LATEST - latest stable release
|
||||
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
---
|
||||
description: Describe what this custom agent does and when to use it.
|
||||
tools: []
|
||||
---
|
||||
Write instructions for this custom agent. These will guide Copilot on how to respond when this mode is selected.
|
||||
@@ -1,9 +0,0 @@
|
||||
/bin/
|
||||
/target/
|
||||
/doc/
|
||||
/.idea/
|
||||
/*.iml
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.factorypath
|
||||
/.apt_generated_tests/
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>VotingPlugin</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,663 +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.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>7.1</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<build.number>NOTSET</build.number>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.release>21</maven.compiler.release>
|
||||
<velocity.version>3.4.0</velocity.version>
|
||||
</properties>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>bungee.yml</include>
|
||||
<include>votingpluginversion.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<excludes>
|
||||
<exclude>plugin.yml</exclude>
|
||||
<exclude>bungee.yml</exclude>
|
||||
<exclude>votingpluginversion.yml</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<versionRange>[1,)</versionRange>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<release>21</release>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.42</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.6.2</version>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>mysql-connector-java</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.tcoded.folialib</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.simpleapi.folialib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.bencodez.simpleapi</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.simpleapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.bencodez.advancedcore</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.advancedcore</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.pl3x.bukkit.chatapi</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.mrten.mysqlapi</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.mysqlapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.simpleapi.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>xyz.upperlevel.spigot</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.spongepowered.configurate</pattern>
|
||||
<shadedPattern>${project.groupId}.simpleapi.configurate</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.leangen.geantyref</pattern>
|
||||
<shadedPattern>${project.groupId}.simpleapi.geantyref</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<!-- Lets exclude google code, because the
|
||||
server already has this
|
||||
code in it (guava, etc) -->
|
||||
<excludes>
|
||||
<exclude>com.google.*:*</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
<exclude>module-info.class</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>maven-central</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>velocity</id>
|
||||
<url>https://nexus.velocitypowered.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bencodez repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>
|
||||
https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>scarsz</id>
|
||||
<url>https://nexus.scarsz.me/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>26.1.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.42</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.21-R0.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vexsoftware</groupId>
|
||||
<artifactId>nuvotifier-universal</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>be.maximvdw</groupId>
|
||||
<artifactId>mvdwplaceholderapi</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-velocity</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.12.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.21.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.12.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>5.23.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.discordsrv</groupId>
|
||||
<artifactId>discordsrv</artifactId>
|
||||
<version>1.30.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>configurate-core</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>configurate-yaml</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>configurate-gson</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>default</id>
|
||||
<properties>
|
||||
<build.profile.id>default</build.profile.id>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy-snapshot</id>
|
||||
<properties>
|
||||
<build.profile.id>dev-snapshot</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>
|
||||
${project.name}-${build.number}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.12.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<failOnError>false</failOnError>
|
||||
<doclint>none</doclint>
|
||||
<sourcepath>
|
||||
${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>nexus</serverId>
|
||||
<nexusUrl>https://nexus.bencodez.com/nexus/</nexusUrl>
|
||||
<skipStaging>true</skipStaging>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>javadoc</id>
|
||||
<properties>
|
||||
<build.profile.id>javadoc</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.12.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>
|
||||
${project.basedir}/target/delombok</sourcepath>
|
||||
<outputDirectory>
|
||||
${project.basedir}/target/apidocs</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.coderplus.maven.plugins</groupId>
|
||||
<artifactId>copy-rename-maven-plugin</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-file</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceFile>
|
||||
${project.basedir}/target/${project.name}.jar</sourceFile>
|
||||
<destinationFile>
|
||||
${project.basedir}/target/${project.name}-${project.version}.jar</destinationFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<build.profile.id>dev</build.profile.id>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>
|
||||
${user.home}/Documents/Test_Server/plugins</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/target</directory>
|
||||
<includes>
|
||||
<include>VotingPlugin.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<properties>
|
||||
<build.profile.id>deploy</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.coderplus.maven.plugins</groupId>
|
||||
<artifactId>copy-rename-maven-plugin</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-file</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceFile>
|
||||
${project.basedir}/target/${project.name}.jar</sourceFile>
|
||||
<destinationFile>
|
||||
${project.basedir}/target/${project.name}-${project.version}.jar</destinationFile>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.12.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>
|
||||
${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.7.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>nexus</serverId>
|
||||
<nexusUrl>https://nexus.bencodez.com/nexus/</nexusUrl>
|
||||
<skipStaging>true</skipStaging>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -1,734 +0,0 @@
|
||||
// File: com/bencodez/votingplugin/BungeeHandler.java
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.simpleapi.encryption.EncryptionHandler;
|
||||
import com.bencodez.simpleapi.servercomm.codec.JsonEnvelope;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageListener;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttServerComm;
|
||||
import com.bencodez.simpleapi.servercomm.mysql.MySqlMessenger;
|
||||
import com.bencodez.simpleapi.servercomm.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
|
||||
import com.bencodez.simpleapi.sql.data.DataValue;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueBoolean;
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigSpigot;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.VoteTotalsSnapshot;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginWire;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Handler for Bungee/proxy server integration.
|
||||
*/
|
||||
public class BungeeHandler implements Listener {
|
||||
@Getter
|
||||
private ClientHandler clientHandler;
|
||||
|
||||
private EncryptionHandler encryptionHandler;
|
||||
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyCurrent = -2;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyRequired = -2;
|
||||
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private GlobalDataHandler globalDataHandler;
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
@Getter
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Getter
|
||||
private GlobalMessageHandler globalMessageHandler;
|
||||
|
||||
private Thread redisThread;
|
||||
|
||||
@Getter
|
||||
private MySqlMessenger backendMysqlMessenger;
|
||||
|
||||
@Getter
|
||||
private MqttHandler mqttHandler;
|
||||
|
||||
/**
|
||||
* Constructs a new BungeeHandler.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public BungeeHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and processes global data from the global data handler.
|
||||
*/
|
||||
public void checkGlobalData() {
|
||||
HashMap<String, DataValue> data = globalDataHandler.getExact(plugin.getBungeeSettings().getServer());
|
||||
|
||||
if (data.containsKey("ForceUpdate")) {
|
||||
boolean b = checkGlobalDataTimeValue(data.get("ForceUpdate"));
|
||||
if (b) {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "ForceUpdate", false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean forceUpdate = false;
|
||||
|
||||
if (checkGlobalDataTime(TimeType.MONTH, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.WEEK, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.DAY, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<>();
|
||||
dataToSet.put("FinishedProcessing", new DataValueBoolean(true));
|
||||
dataToSet.put("Processing", new DataValueBoolean(false));
|
||||
globalDataHandler.setData(plugin.getBungeeSettings().getServer(), dataToSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks global data for a time type change.
|
||||
*
|
||||
* @param type the time type to check
|
||||
* @param data the global data map
|
||||
* @return true if currently processing a time change
|
||||
*/
|
||||
public boolean checkGlobalDataTime(TimeType type, HashMap<String, DataValue> data) {
|
||||
boolean isProcessing = false;
|
||||
if (data.containsKey(type.toString())) {
|
||||
|
||||
DataValue value = data.get(type.toString());
|
||||
boolean b = checkGlobalDataTimeValue(value);
|
||||
if (b) {
|
||||
long lastUpdated = Long.valueOf(data.get("LastUpdated").getString()).longValue();
|
||||
plugin.debug("LastUpdated: " + lastUpdated);
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastUpdated > 1000 * 60 * 60
|
||||
* 2) {
|
||||
plugin.getLogger().warning("Ignoring bungee time change since it was more than 2 hours ago");
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
return false;
|
||||
}
|
||||
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "Processing", true);
|
||||
isProcessing = true;
|
||||
|
||||
plugin.debug("Detected time change from bungee: " + type.toString());
|
||||
plugin.getTimeChecker().forceChanged(type, false, true, true);
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
|
||||
HashMap<String, Object> fields = new HashMap<>();
|
||||
fields.put("server", plugin.getBungeeSettings().getServer());
|
||||
sendSubChannel("TimeChangeFinished", fields);
|
||||
}
|
||||
}
|
||||
return isProcessing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and extracts the boolean value from a DataValue.
|
||||
*
|
||||
* @param data the data value
|
||||
* @return the boolean value
|
||||
*/
|
||||
public boolean checkGlobalDataTimeValue(DataValue data) {
|
||||
if (data.isBoolean()) {
|
||||
return data.getBoolean();
|
||||
}
|
||||
return Boolean.valueOf(data.getString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes and cleans up all handlers and connections.
|
||||
*/
|
||||
public void close() {
|
||||
if (backendMysqlMessenger != null) {
|
||||
backendMysqlMessenger.shutdown();
|
||||
}
|
||||
|
||||
if (socketHandler != null) {
|
||||
socketHandler.closeConnection();
|
||||
}
|
||||
if (clientHandler != null) {
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and initializes the bungee handler with the configured method.
|
||||
*/
|
||||
public void load() {
|
||||
plugin.debug("Loading bungee handler");
|
||||
|
||||
method = BungeeMethod.getByName(plugin.getBungeeSettings().getBungeeMethod());
|
||||
|
||||
plugin.getLogger().info("Using BungeeMethod: " + method.toString());
|
||||
|
||||
loadGlobalMysql();
|
||||
|
||||
globalMessageHandler = new GlobalMessageHandler() {
|
||||
@Override
|
||||
public void sendMessage(JsonEnvelope envelope) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
try {
|
||||
backendMysqlMessenger.sendToProxy(envelope);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendEnvelope(envelope);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendEnvelopeSocket(envelope);
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
redisHandler.publishEnvelope(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
|
||||
envelope);
|
||||
} else if (method.equals(BungeeMethod.MQTT)) {
|
||||
try {
|
||||
mqttHandler.publishEnvelope(
|
||||
plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/proxy", envelope);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ==========================
|
||||
// Vote / VoteOnline (wire decode)
|
||||
// ==========================
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_VOTE) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
handleWireVote(msg);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_VOTE_ONLINE) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
handleWireVote(msg);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_VOTE_UPDATE) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
// Wire decode
|
||||
VotingPluginWire.VoteUpdate v = VotingPluginWire.readVoteUpdate(msg);
|
||||
|
||||
String playerUuid = v.uuid;
|
||||
if (playerUuid == null || playerUuid.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug("pluginmessaging voteupdate received for " + playerUuid + ": " + v.votePartyCurrent + "/"
|
||||
+ v.votePartyRequired + " on " + v.service);
|
||||
|
||||
// Vote party cache update
|
||||
if (v.votePartyCurrent >= 0 || bungeeVotePartyCurrent == -2) {
|
||||
bungeeVotePartyCurrent = v.votePartyCurrent;
|
||||
}
|
||||
if (v.votePartyRequired >= 0 || bungeeVotePartyRequired == -2) {
|
||||
bungeeVotePartyRequired = v.votePartyRequired;
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(playerUuid));
|
||||
user.cache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
// Optional: update last vote time for a service
|
||||
String service = v.service;
|
||||
long time = v.time;
|
||||
|
||||
if (service != null && !service.isEmpty() && time > 0) {
|
||||
user.setTime(plugin.getVoteSiteManager().getVoteSite(service, true), time);
|
||||
} else if (service != null && !service.isEmpty() && time <= 0
|
||||
&& plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug("Invalid last vote time received from bungee: " + time);
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_BUNGEE_TIME_CHANGE) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_VOTE_BROADCAST) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
Map<String, String> f = msg.getFields();
|
||||
|
||||
final String uuidStr = nvl(f.get(VotingPluginWire.K_UUID));
|
||||
final String playerNameRaw = nvl(f.get(VotingPluginWire.K_PLAYER));
|
||||
final String service = nvl(f.get(VotingPluginWire.K_SERVICE));
|
||||
|
||||
if (uuidStr.isEmpty() || service.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
UUID javaUuid;
|
||||
try {
|
||||
javaUuid = UUID.fromString(uuidStr);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Invalid UUID in VoteBroadcast: " + uuidStr);
|
||||
return;
|
||||
}
|
||||
|
||||
// New fields (May use later)
|
||||
@SuppressWarnings("unused")
|
||||
final long time = readLongSafe(f.get(VotingPluginWire.K_TIME), 0L);
|
||||
@SuppressWarnings("unused")
|
||||
final String totals = nvl(f.get(VotingPluginWire.K_TOTALS));
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSiteManager()
|
||||
.getVoteSite(plugin.getVoteSiteManager().getVoteSiteName(true, service), true);
|
||||
|
||||
if (voteSite == null) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + service + "'");
|
||||
return;
|
||||
}
|
||||
if (!voteSite.isEnabled()) {
|
||||
plugin.debug("Votesite: " + voteSite.getKey() + " is not enabled (VoteBroadcast)");
|
||||
return;
|
||||
}
|
||||
|
||||
// Same user retrieval strategy: UUID + (possibly empty) name
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(javaUuid,
|
||||
playerNameRaw);
|
||||
|
||||
// Keep cache/name current like normal vote path does
|
||||
user.cache();
|
||||
user.updateName(true);
|
||||
|
||||
// Same broadcast logic as PlayerVoteListener
|
||||
if (plugin.getBroadcastHandler() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.isVanished()) {
|
||||
plugin.debug("Not broadcasting vote for vanished user: " + user.getPlayerName());
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean online = user.isOnline(); // same behavior as non-bungee vote path
|
||||
plugin.getBroadcastHandler().broadcastVote(user.getJavaUUID(), user.getPlayerName(),
|
||||
voteSite.getDisplayName(), online);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("Status") {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
String server = nvl(msg.getFields().get("server"));
|
||||
HashMap<String, Object> out = new HashMap<>();
|
||||
out.put("server", server);
|
||||
sendSubChannel("statusokay", out);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("ServerName") {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
String server = nvl(msg.getFields().get("server"));
|
||||
if (!plugin.getOptions().getServer().equals(server)) {
|
||||
plugin.getLogger().warning("Server name doesn't match in BungeeSettings.yml, should be " + server);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBungee") {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
});
|
||||
}
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBroadcast") {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
String broadcast = nvl(msg.getFields().get("broadcast"));
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
|
||||
try {
|
||||
backendMysqlMessenger = new MySqlMessenger("VotingPlugin",
|
||||
plugin.getMysql().getMysql().getConnectionManager().getDataSource(),
|
||||
MySqlMessenger.Mode.BACKEND, plugin.getOptions().getServer(), msg -> {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug("Proxy sent envelope: " + msg.envelope.getSubChannel() + " "
|
||||
+ msg.envelope.getFields());
|
||||
}
|
||||
globalMessageHandler.onMessage(msg.envelope);
|
||||
});
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
redisHandler = new RedisHandler(plugin.getBungeeSettings().getRedisHost(),
|
||||
plugin.getBungeeSettings().getRedisPort(), plugin.getBungeeSettings().getRedisUsername(),
|
||||
plugin.getBungeeSettings().getRedisPassword(), plugin.getBungeeSettings().getRedisdbindex()) {
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
redisThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.isEnabled()) {
|
||||
RedisListener listener = redisHandler.createEnvelopeListener(
|
||||
plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin_"
|
||||
+ plugin.getBungeeSettings().getServer(),
|
||||
(ch, env) -> globalMessageHandler.onMessage(env));
|
||||
redisHandler.loadListener(listener);
|
||||
}
|
||||
}
|
||||
});
|
||||
redisThread.start();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
|
||||
if (plugin.getBungeeSettings().isPluginMessageEncryption()) {
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
plugin.getPluginMessaging().setEncryptionHandler(encryptionHandler);
|
||||
}
|
||||
|
||||
plugin.getPluginMessaging().setDebug(plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler() {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope envelope) {
|
||||
globalMessageHandler.onMessage(envelope);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
clientHandler = new ClientHandler(plugin.getBungeeSettings().getBungeeServerHost(),
|
||||
plugin.getBungeeSettings().getBungeeServerPort(), encryptionHandler,
|
||||
plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
socketHandler = new SocketHandler("vp-socket", plugin.getBungeeSettings().getSpigotServerHost(),
|
||||
plugin.getBungeeSettings().getSpigotServerPort(), encryptionHandler,
|
||||
plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
plugin.getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
@Override
|
||||
public void onReceiveEnvelope(JsonEnvelope envelope) {
|
||||
globalMessageHandler.onMessage(envelope);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.MQTT)) {
|
||||
try {
|
||||
String id = plugin.getBungeeSettings().getMqttClientID();
|
||||
if (id.isEmpty()) {
|
||||
id = plugin.getOptions().getServer();
|
||||
}
|
||||
mqttHandler = new MqttHandler(new MqttServerComm(id, plugin.getBungeeSettings().getMqttBrokerURL(),
|
||||
plugin.getBungeeSettings().getMqttUsername(), plugin.getBungeeSettings().getMqttPassword()), 2);
|
||||
|
||||
mqttHandler.subscribeEnvelopes(
|
||||
plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/"
|
||||
+ plugin.getOptions().getServer(),
|
||||
(topic, envelope) -> globalMessageHandler.onMessage(envelope));
|
||||
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
|
||||
bungeeVotePartyRequired = plugin.getServerData().getBungeeVotePartyRequired();
|
||||
|
||||
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
|
||||
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
|
||||
}
|
||||
}
|
||||
|
||||
private static long readLongSafe(String v, long def) {
|
||||
if (v == null)
|
||||
return def;
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ignored) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire vote handler (Vote + VoteOnline).
|
||||
*/
|
||||
private void handleWireVote(JsonEnvelope msg) {
|
||||
// Strict schema check (wire uses envelope schema, not a "bungeeVersion" field)
|
||||
int schema = msg.getSchema();
|
||||
if (schema != VotingPluginWire.SCHEMA_VERSION) {
|
||||
plugin.getLogger().warning("Incompatible version with bungee/proxy, please update all servers: " + schema
|
||||
+ " != " + VotingPluginWire.SCHEMA_VERSION);
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginWire.Vote v = VotingPluginWire.readVote(msg);
|
||||
|
||||
String uuidStr = v.uuid;
|
||||
String player = v.player;
|
||||
String service = v.service;
|
||||
|
||||
if (uuidStr == null || uuidStr.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug("wire vote received from " + player + "/" + uuidStr + " on " + service);
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuidStr),
|
||||
player);
|
||||
|
||||
VoteTotalsSnapshot text = VoteTotalsSnapshot.parseStorage(v.totals == null ? "" : v.totals);
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
user.cache();
|
||||
|
||||
boolean bungeeBroadcast = v.broadcast;
|
||||
|
||||
// Wire has no "setTotals" flag; treat as always true (so doNotSetTotals =
|
||||
// false)
|
||||
boolean doNotSetTotals = false;
|
||||
|
||||
user.bungeeVotePluginMessaging(service, v.time, text, doNotSetTotals, v.wasOnline, bungeeBroadcast, v.num);
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
if (v.manageTotals) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int _ignored = v.numberOfVotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the global MySQL handler for cross-server data synchronization.
|
||||
*/
|
||||
public void loadGlobalMysql() {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
if (timer != null) {
|
||||
timer.shutdown();
|
||||
try {
|
||||
timer.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
timer.shutdownNow();
|
||||
}
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkGlobalData();
|
||||
}
|
||||
}, 60, 10, TimeUnit.SECONDS);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
globalDataHandler.setString(plugin.getBungeeSettings().getServer(), "LastOnline",
|
||||
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli());
|
||||
}
|
||||
}, 1, 60, TimeUnit.MINUTES);
|
||||
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
|
||||
if (plugin.getBungeeSettings().isGloblalDataUseMainMySQL()
|
||||
&& plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
|
||||
@Override
|
||||
public void debugEx(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugLog(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
plugin.getLogger().info(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
|
||||
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
|
||||
@Override
|
||||
public void debugEx(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugLog(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
plugin.getLogger().info(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
plugin.getTimeChecker().setProcessingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendEnvelopeSocket(JsonEnvelope envelope) {
|
||||
if (clientHandler != null) {
|
||||
clientHandler.sendEnvelope(envelope);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSubChannel(String subChannel, HashMap<String, Object> fields) {
|
||||
JsonEnvelope.Builder b = JsonEnvelope.builder(subChannel).schema(VotingPluginWire.SCHEMA_VERSION);
|
||||
if (fields != null) {
|
||||
for (Map.Entry<String, Object> e : fields.entrySet()) {
|
||||
b.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
globalMessageHandler.sendMessage(b.build());
|
||||
}
|
||||
|
||||
private static String nvl(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
|
||||
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInject;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VotingPluginHooks {
|
||||
private static VotingPluginHooks instance = new VotingPluginHooks();
|
||||
|
||||
public static VotingPluginHooks getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void addCustomRequirement(RequirementInject inject) {
|
||||
getMainClass().getRewardHandler().addInjectedRequirements(inject);
|
||||
}
|
||||
|
||||
public void addCustomReward(RewardInject inject) {
|
||||
getMainClass().getRewardHandler().addInjectedReward(inject);
|
||||
}
|
||||
|
||||
public void backgroundUpdate(Player player) {
|
||||
VotingPluginUser user = getUserManager().getVotingPluginUser(player);
|
||||
user.offVote();
|
||||
user.checkOfflineRewards();
|
||||
}
|
||||
|
||||
public VotingPluginMain getMainClass() {
|
||||
return VotingPluginMain.plugin;
|
||||
}
|
||||
|
||||
public UserManager getUserManager() {
|
||||
return getMainClass().getVotingPluginUserManager();
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,483 +0,0 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.metrics.BStatsMetrics;
|
||||
|
||||
/**
|
||||
* Registers bStats charts for VotingPlugin.
|
||||
* <p>
|
||||
* Updated for VotingPlugin 7.0:
|
||||
* <ul>
|
||||
* <li>Broadcast: Always logs broadcast_type if VoteBroadcast.Type exists. If Type == NONE, ignores other broadcast
|
||||
* settings.</li>
|
||||
* <li>VoteLogging: Only logs VoteLogging charts when VoteLogging.Enabled is true.</li>
|
||||
* <li>No "Unknown" values are emitted; charts are only registered when their data exists.</li>
|
||||
* <li>VoteMilestones chart is bucketed to reduce cardinality.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class VotingPluginMetrics {
|
||||
|
||||
/**
|
||||
* Register bStats metrics.
|
||||
*
|
||||
* @param plugin VotingPlugin main instance
|
||||
*/
|
||||
public void load(final VotingPluginMain plugin) {
|
||||
if (plugin == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final BStatsMetrics metrics = new BStatsMetrics(plugin, 38);
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
|
||||
return "True";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_voteparty", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
return "False";
|
||||
}
|
||||
return "True";
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("placeholder_cache_level", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return plugin.getPlaceholders().getCacheLevel().toString();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votemilestones", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int size = plugin.getVoteMilestonesManager().getConfig().getMilestones().size();
|
||||
return bucketCount(size);
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
|
||||
return "True";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofsites", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getVoteSiteManager().getVoteSitesEnabled().size();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getRewardHandler().getRewards().size();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isAutoCreateVoteSites();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("config_onlinemode", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getOptions().isOnlineMode();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofusers", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = plugin.getUserManager().getAllUUIDs().size();
|
||||
if (total > 800000) {
|
||||
return ">800000";
|
||||
}
|
||||
if (total > 700000) {
|
||||
return "700000-800000";
|
||||
}
|
||||
if (total > 600000) {
|
||||
return "600000-700000";
|
||||
} else if (total > 500000) {
|
||||
return "500000-600000";
|
||||
} else if (total > 400000) {
|
||||
return "400000-500000";
|
||||
} else if (total > 300000) {
|
||||
return "300000-400000";
|
||||
} else if (total > 200000) {
|
||||
return "200000-300000";
|
||||
} else if (total > 100000) {
|
||||
return "100000-200000";
|
||||
} else if (total > 10000) {
|
||||
return ">10000-100000";
|
||||
}
|
||||
return "<10000";
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("data_storage", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return plugin.getOptions().getStorageType().toString();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("DisableCheckOnWorldChange", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getOptions().isDisableCheckOnWorldChange();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterMonthly();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Weekly", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterWeekly();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Daily", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterDaily();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeemethod", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "" + plugin.getBungeeHandler().getMethod().toString();
|
||||
}
|
||||
return "Disabled";
|
||||
}
|
||||
}));
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("perserverrewards", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isPerServerRewards();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("perserverpoints", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isPerServerPoints();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("triggervotifierevent", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isTriggerVotifierEvent();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("globaldata_enabled", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isGloblalDataEnabled();
|
||||
}
|
||||
}));
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("globaldata_usemainmysql", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isGloblalDataUseMainMySQL();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("persitecooldownevents", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isPerSiteCoolDownEvents();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bedrockplayerprefix", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getOptions().getBedrockPlayerPrefix();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("using_dev_build", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getProfile().contains("dev");
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votepointtransfering", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isAllowVotePointTransfers();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votecooldown_check_enabled", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward"));
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("background_task_time_taken", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getLastBackgroundTaskTimeTaken();
|
||||
}
|
||||
}));
|
||||
|
||||
if (!plugin.getBuildNumber().equals("NOTSET")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("dev_build_number", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBuildNumber();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* Broadcast metrics:
|
||||
* - Always log broadcast_type if VoteBroadcast.Type exists (even if NONE)
|
||||
* - If Type == NONE, ignore the rest of the broadcast settings
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
final ConfigurationSection root = safeConfig(plugin);
|
||||
final ConfigurationSection voteBroadcast = getSection(root, "VoteBroadcast");
|
||||
if (voteBroadcast != null && voteBroadcast.isString("Type")) {
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("broadcast_type", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return voteBroadcast.getString("Type");
|
||||
}
|
||||
}));
|
||||
|
||||
final String type = voteBroadcast.getString("Type", null);
|
||||
if (type != null && !"NONE".equalsIgnoreCase(type)) {
|
||||
|
||||
if (voteBroadcast.isString("Duration")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("broadcast_duration", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return voteBroadcast.getString("Duration");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (voteBroadcast.isInt("MaxSitesListed")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("broadcast_max_sites_listed",
|
||||
new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return bucketMaxSites(voteBroadcast.getInt("MaxSitesListed"));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* VoteLogging metrics:
|
||||
* - Only log when VoteLogging.Enabled is true
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
final ConfigurationSection voteLogging = getSection(root, "VoteLogging");
|
||||
if (voteLogging != null && voteLogging.getBoolean("Enabled", false)) {
|
||||
|
||||
if (voteLogging.isInt("PurgeDays")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votelogging_purgedays", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return bucketPurgeDays(voteLogging.getInt("PurgeDays"));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (voteLogging.isBoolean("UseMainMySQL")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votelogging_usemainmysql", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + voteLogging.getBoolean("UseMainMySQL");
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely gets the root configuration section.
|
||||
*
|
||||
* @param plugin plugin instance
|
||||
* @return root config section, or null if inaccessible
|
||||
*/
|
||||
private ConfigurationSection safeConfig(final VotingPluginMain plugin) {
|
||||
try {
|
||||
return plugin.getConfigFile().getData();
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a child section safely.
|
||||
*
|
||||
* @param root root section
|
||||
* @param key child key
|
||||
* @return child section or null
|
||||
*/
|
||||
private ConfigurationSection getSection(final ConfigurationSection root, final String key) {
|
||||
if (root == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return root.getConfigurationSection(key);
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Buckets a milestone count to reduce bStats cardinality.
|
||||
*
|
||||
* @param count count
|
||||
* @return bucket string
|
||||
*/
|
||||
private String bucketCount(final int count) {
|
||||
if (count <= 0) {
|
||||
return "0";
|
||||
}
|
||||
if (count == 1) {
|
||||
return "1";
|
||||
}
|
||||
if (count <= 5) {
|
||||
return "2-5";
|
||||
}
|
||||
if (count <= 10) {
|
||||
return "6-10";
|
||||
}
|
||||
if (count <= 25) {
|
||||
return "11-25";
|
||||
}
|
||||
if (count <= 50) {
|
||||
return "26-50";
|
||||
}
|
||||
if (count <= 100) {
|
||||
return "51-100";
|
||||
}
|
||||
return ">100";
|
||||
}
|
||||
|
||||
/**
|
||||
* Buckets MaxSitesListed to reduce bStats cardinality.
|
||||
*
|
||||
* @param maxSites max sites listed
|
||||
* @return bucket string
|
||||
*/
|
||||
private String bucketMaxSites(final int maxSites) {
|
||||
if (maxSites <= 0) {
|
||||
return "0";
|
||||
}
|
||||
if (maxSites <= 5) {
|
||||
return "1-5";
|
||||
}
|
||||
if (maxSites <= 10) {
|
||||
return "6-10";
|
||||
}
|
||||
if (maxSites <= 25) {
|
||||
return "11-25";
|
||||
}
|
||||
return ">25";
|
||||
}
|
||||
|
||||
/**
|
||||
* Buckets purge days to reduce bStats cardinality.
|
||||
*
|
||||
* @param purgeDays purge days
|
||||
* @return bucket string
|
||||
*/
|
||||
private String bucketPurgeDays(final int purgeDays) {
|
||||
if (purgeDays < 0) {
|
||||
return "disabled";
|
||||
}
|
||||
if (purgeDays == 0) {
|
||||
return "0";
|
||||
}
|
||||
if (purgeDays <= 7) {
|
||||
return "1-7";
|
||||
}
|
||||
if (purgeDays <= 30) {
|
||||
return "8-30";
|
||||
}
|
||||
if (purgeDays <= 90) {
|
||||
return "31-90";
|
||||
}
|
||||
if (purgeDays <= 365) {
|
||||
return "91-365";
|
||||
}
|
||||
return ">365";
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* Defines HOW vote broadcasts are rendered.
|
||||
*
|
||||
* Terminology:
|
||||
* - BroadcastMsg : used when EXACTLY ONE item exists (single-site vote)
|
||||
* - Header : used ONCE when MULTIPLE items exist (batch/interval)
|
||||
* - ListLine : used ONCE PER ITEM when MULTIPLE items exist
|
||||
*
|
||||
* Placeholders (always available):
|
||||
* - %player% : player name (or "Server" for interval summaries)
|
||||
* - %site% : the current site/item for this line
|
||||
* - %sites_count% : number of items in the list
|
||||
* - %sites% : csv of items in the list
|
||||
* - %reason% : internal reason string ("vote", "batch", "interval", etc)
|
||||
*
|
||||
* Extra context placeholders (INTERVAL_SUMMARY_GLOBAL):
|
||||
* - %players% / %numberofplayers%
|
||||
* - %sites% / %numberofsites% (note: %sites% is csv; %numberofsites% is count)
|
||||
*/
|
||||
public final class BroadcastFormat {
|
||||
|
||||
private final String broadcastMsg;
|
||||
private final String header;
|
||||
private final String listLine;
|
||||
|
||||
/**
|
||||
* Constructor for BroadcastFormat.
|
||||
*
|
||||
* @param broadcastMsg the broadcast message template
|
||||
* @param header the header template
|
||||
* @param listLine the list line template
|
||||
*/
|
||||
public BroadcastFormat(String broadcastMsg, String header, String listLine) {
|
||||
this.broadcastMsg = broadcastMsg == null ? "" : broadcastMsg;
|
||||
this.header = header == null ? "" : header;
|
||||
this.listLine = listLine == null ? "" : listLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the broadcast with player name, items, and reason.
|
||||
*
|
||||
* @param playerName the player name
|
||||
* @param items the list of items
|
||||
* @param reason the reason string
|
||||
* @return the rendered list of strings
|
||||
*/
|
||||
public List<String> render(String playerName, List<String> items, String reason) {
|
||||
return render(playerName, items, reason, Collections.<String, String>emptyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the broadcast with player name, items, reason, and context.
|
||||
*
|
||||
* @param playerName the player name
|
||||
* @param items the list of items
|
||||
* @param reason the reason string
|
||||
* @param context additional context placeholders
|
||||
* @return the rendered list of strings
|
||||
*/
|
||||
public List<String> render(String playerName, List<String> items, String reason, Map<String, String> context) {
|
||||
List<String> output = new ArrayList<String>();
|
||||
int count = items == null ? 0 : items.size();
|
||||
|
||||
String csv = "";
|
||||
if (count > 0) {
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (String s : items) {
|
||||
if (s != null && !s.isEmpty()) {
|
||||
joiner.add(s);
|
||||
}
|
||||
}
|
||||
csv = joiner.toString();
|
||||
}
|
||||
|
||||
// SINGLE ITEM → BroadcastMsg
|
||||
if (count == 1 && !broadcastMsg.isEmpty()) {
|
||||
output.add(apply(broadcastMsg, playerName, items.get(0), count, csv, reason, context));
|
||||
return output;
|
||||
}
|
||||
|
||||
// MULTI ITEM → Header + ListLine per item
|
||||
if (!header.isEmpty()) {
|
||||
output.add(apply(header, playerName, "", count, csv, reason, context));
|
||||
}
|
||||
|
||||
if (count > 0 && !listLine.isEmpty()) {
|
||||
for (String s : items) {
|
||||
output.add(apply(listLine, playerName, s, count, csv, reason, context));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private String apply(String template,
|
||||
String player,
|
||||
String item,
|
||||
int count,
|
||||
String csv,
|
||||
String reason,
|
||||
Map<String, String> context) {
|
||||
|
||||
String out = template
|
||||
.replace("%player%", player == null ? "" : player)
|
||||
.replace("%site%", item == null ? "" : item)
|
||||
.replace("%sites_count%", String.valueOf(count))
|
||||
.replace("%sites%", csv == null ? "" : csv)
|
||||
.replace("%reason%", reason == null ? "" : reason);
|
||||
|
||||
if (context != null && !context.isEmpty()) {
|
||||
for (Map.Entry<String, String> e : context.entrySet()) {
|
||||
out = out.replace("%" + e.getKey() + "%", e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -1,443 +0,0 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.time.ParsedDuration;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
/**
|
||||
* Core broadcast logic.
|
||||
*
|
||||
* Decides WHEN to broadcast and builds lines/messages. Uses your existing
|
||||
* "eligible online players" behavior (disable broadcast respected).
|
||||
*
|
||||
* NOTE: Backend servers only.
|
||||
*/
|
||||
public final class BroadcastHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Only used for day-boundary logic (FIRST_VOTE_OF_DAY).
|
||||
*/
|
||||
private final ZoneId zoneId;
|
||||
|
||||
private volatile BroadcastSettings settings;
|
||||
|
||||
// Per-player cooldown tracking
|
||||
private final ConcurrentHashMap<UUID, Instant> lastBroadcastAt = new ConcurrentHashMap<UUID, Instant>();
|
||||
|
||||
// Batch window tracking
|
||||
private final ConcurrentHashMap<UUID, LinkedHashSet<String>> pendingSites = new ConcurrentHashMap<UUID, LinkedHashSet<String>>();
|
||||
private final ConcurrentHashMap<UUID, BukkitTask> pendingFlush = new ConcurrentHashMap<UUID, BukkitTask>();
|
||||
|
||||
// First vote of day tracking
|
||||
private final ConcurrentHashMap<UUID, LocalDate> firstVoteDay = new ConcurrentHashMap<UUID, LocalDate>();
|
||||
|
||||
// Interval summary tracking (uuid -> set of sites during interval)
|
||||
private final ConcurrentHashMap<UUID, LinkedHashSet<String>> intervalSites = new ConcurrentHashMap<UUID, LinkedHashSet<String>>();
|
||||
private volatile BukkitTask intervalTask;
|
||||
|
||||
/**
|
||||
* Constructs a new BroadcastHandler.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
* @param settings the broadcast settings
|
||||
* @param zoneId the time zone ID, or null to use system default
|
||||
*/
|
||||
public BroadcastHandler(VotingPluginMain plugin, BroadcastSettings settings, ZoneId zoneId) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
this.zoneId = zoneId == null ? ZoneId.systemDefault() : zoneId;
|
||||
|
||||
rescheduleIntervalIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the broadcast settings and reschedules interval task if needed.
|
||||
*
|
||||
* @param settings the new broadcast settings
|
||||
*/
|
||||
public void setSettings(BroadcastSettings settings) {
|
||||
this.settings = settings;
|
||||
rescheduleIntervalIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call whenever a vote is received.
|
||||
*
|
||||
* @param uuid player's uuid
|
||||
* @param playerName player name (optional; if null/empty, resolved from Bukkit)
|
||||
* @param siteName vote site name (display name)
|
||||
* @param wasOnline whether the player was online when the vote was received
|
||||
*/
|
||||
public void broadcastVote(UUID uuid, String playerName, String siteName, boolean wasOnline) {
|
||||
BroadcastSettings s = settings;
|
||||
if (s == null || s.isDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Always collect for interval summaries (even if Type isn't interval right
|
||||
// now).
|
||||
recordInterval(uuid, siteName);
|
||||
|
||||
String name = playerName == null || playerName.isEmpty() ? resolveName(uuid) : playerName;
|
||||
|
||||
VoteBroadcastType type = s.getType();
|
||||
|
||||
// New: types that only broadcast if the voting player is online
|
||||
if (type == VoteBroadcastType.EVERY_VOTE_ONLINE_ONLY) {
|
||||
if (!wasOnline) {
|
||||
return;
|
||||
}
|
||||
broadcastNow(name, single(siteName), "vote_online_only", null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == VoteBroadcastType.EVERY_VOTE) {
|
||||
broadcastNow(name, single(siteName), "vote", null);
|
||||
|
||||
} else if (type == VoteBroadcastType.COOLDOWN_PER_PLAYER) {
|
||||
if (checkAndMarkCooldown(uuid, s.getDuration())) {
|
||||
broadcastNow(name, single(siteName), "cooldown", null);
|
||||
}
|
||||
|
||||
} else if (type == VoteBroadcastType.BATCH_WINDOW_PER_PLAYER) {
|
||||
bufferBatch(uuid, name, siteName, s.getDuration());
|
||||
|
||||
} else if (type == VoteBroadcastType.FIRST_VOTE_OF_DAY) {
|
||||
if (markFirstVoteOfDay(uuid)) {
|
||||
broadcastNow(name, single(siteName), "first_day", null);
|
||||
}
|
||||
|
||||
} else if (type == VoteBroadcastType.INTERVAL_SUMMARY_GLOBAL) {
|
||||
// handled by scheduled task
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Broadcast helpers =======================
|
||||
*/
|
||||
|
||||
private void broadcastNow(String playerName, List<String> sites, String reason, Map<String, String> extraContext) {
|
||||
BroadcastSettings s = settings;
|
||||
if (s == null || s.isDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> cleaned = applyMaxSites(sites, s);
|
||||
cleaned.sort(new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String a, String b) {
|
||||
String aa = a == null ? "" : a.toLowerCase(Locale.ROOT);
|
||||
String bb = b == null ? "" : b.toLowerCase(Locale.ROOT);
|
||||
return aa.compareTo(bb);
|
||||
}
|
||||
});
|
||||
|
||||
List<String> lines;
|
||||
if (extraContext == null) {
|
||||
lines = s.getFormat().render(playerName, cleaned, reason);
|
||||
} else {
|
||||
lines = s.getFormat().render(playerName, cleaned, reason, extraContext);
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
broadcastToEligiblePlayers(line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Your reliable broadcast style: - only sends to online players - respects
|
||||
* per-player disable broadcast toggle - runs PlaceholderAPI style per-player
|
||||
* placeholders (if your PlaceholderUtils does) - supports %newline% / %NewLine%
|
||||
* splitting
|
||||
*/
|
||||
private void broadcastToEligiblePlayers(String broadcastMsg) {
|
||||
if (broadcastMsg == null || broadcastMsg.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser u = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (u != null && !u.getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
// If you prefer your manual loop, keep it here (not in main)
|
||||
MiscUtils.getInstance().broadcast(broadcastMsg, players);
|
||||
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(MessageAPI.colorize(broadcastMsg));
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Cooldown logic (fixed millis) =======================
|
||||
*/
|
||||
|
||||
private boolean checkAndMarkCooldown(UUID uuid, ParsedDuration cooldown) {
|
||||
if (cooldown == null || cooldown.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Instant now = Instant.now();
|
||||
Instant last = lastBroadcastAt.get(uuid);
|
||||
|
||||
if (last == null) {
|
||||
lastBroadcastAt.put(uuid, now);
|
||||
return true;
|
||||
}
|
||||
|
||||
Instant next = cooldown.addTo(last);
|
||||
if (!now.isBefore(next)) {
|
||||
lastBroadcastAt.put(uuid, now);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Batch window logic (fixed millis)
|
||||
* =======================
|
||||
*/
|
||||
|
||||
private void bufferBatch(UUID uuid, String playerName, String siteName, ParsedDuration window) {
|
||||
if (siteName != null && !siteName.isEmpty()) {
|
||||
LinkedHashSet<String> set = pendingSites.get(uuid);
|
||||
if (set == null) {
|
||||
LinkedHashSet<String> created = new LinkedHashSet<String>();
|
||||
set = pendingSites.putIfAbsent(uuid, created);
|
||||
if (set == null) {
|
||||
set = created;
|
||||
}
|
||||
}
|
||||
synchronized (set) {
|
||||
set.add(siteName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pendingFlush.containsKey(uuid)) {
|
||||
BukkitTask task = scheduleBatchFlush(uuid, playerName, window);
|
||||
BukkitTask prev = pendingFlush.putIfAbsent(uuid, task);
|
||||
if (prev != null) {
|
||||
task.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BukkitTask scheduleBatchFlush(final UUID uuid, final String playerName, ParsedDuration window) {
|
||||
long delayMs = window == null ? 1L : window.delayMillisFromNow();
|
||||
long ticks = Math.max(1L, delayMs / 50L);
|
||||
|
||||
return Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
flushBatch(uuid, playerName);
|
||||
} finally {
|
||||
pendingFlush.remove(uuid);
|
||||
}
|
||||
}
|
||||
}, ticks);
|
||||
}
|
||||
|
||||
private void flushBatch(UUID uuid, String playerName) {
|
||||
Set<String> set = pendingSites.remove(uuid);
|
||||
if (set == null || set.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> list;
|
||||
synchronized (set) {
|
||||
list = new ArrayList<String>(set);
|
||||
}
|
||||
broadcastNow(playerName, list, "batch", null);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= First vote of day (calendar) =======================
|
||||
*/
|
||||
|
||||
private boolean markFirstVoteOfDay(UUID uuid) {
|
||||
LocalDate today = LocalDate.now(zoneId);
|
||||
LocalDate last = firstVoteDay.putIfAbsent(uuid, today);
|
||||
|
||||
if (last == null) {
|
||||
return true;
|
||||
}
|
||||
if (!last.equals(today)) {
|
||||
firstVoteDay.put(uuid, today);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Interval summary =======================
|
||||
*/
|
||||
|
||||
private void rescheduleIntervalIfNeeded() {
|
||||
if (intervalTask != null) {
|
||||
intervalTask.cancel();
|
||||
intervalTask = null;
|
||||
}
|
||||
|
||||
BroadcastSettings s = settings;
|
||||
if (s == null || s.getType() != VoteBroadcastType.INTERVAL_SUMMARY_GLOBAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
long delayMs = s.getDuration() == null ? 1L : s.getDuration().delayMillisFromNow();
|
||||
long ticks = Math.max(1L, delayMs / 50L);
|
||||
|
||||
intervalTask = Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
broadcastIntervalSummary();
|
||||
}
|
||||
}, ticks, ticks);
|
||||
}
|
||||
|
||||
private void recordInterval(UUID uuid, String siteName) {
|
||||
if (siteName == null || siteName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LinkedHashSet<String> set = intervalSites.get(uuid);
|
||||
if (set == null) {
|
||||
LinkedHashSet<String> created = new LinkedHashSet<String>();
|
||||
set = intervalSites.putIfAbsent(uuid, created);
|
||||
if (set == null) {
|
||||
set = created;
|
||||
}
|
||||
}
|
||||
synchronized (set) {
|
||||
set.add(siteName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interval summary supports extra context placeholders: - %players% /
|
||||
* %numberofplayers% - %sites% / %numberofsites%
|
||||
*/
|
||||
private void broadcastIntervalSummary() {
|
||||
BroadcastSettings s = settings;
|
||||
if (s == null || s.isDisabled() || s.getType() != VoteBroadcastType.INTERVAL_SUMMARY_GLOBAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConcurrentHashMap<UUID, LinkedHashSet<String>> snapshot = new ConcurrentHashMap<UUID, LinkedHashSet<String>>(
|
||||
intervalSites);
|
||||
intervalSites.clear();
|
||||
|
||||
if (snapshot.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> entries = new ArrayList<String>();
|
||||
List<String> players = new ArrayList<String>();
|
||||
LinkedHashSet<String> uniqueSites = new LinkedHashSet<String>();
|
||||
|
||||
for (Map.Entry<UUID, LinkedHashSet<String>> entry : snapshot.entrySet()) {
|
||||
LinkedHashSet<String> siteSet = entry.getValue();
|
||||
if (siteSet == null || siteSet.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = resolveName(entry.getKey());
|
||||
players.add(name);
|
||||
|
||||
int siteCount;
|
||||
synchronized (siteSet) {
|
||||
siteCount = siteSet.size();
|
||||
for (String site : siteSet) {
|
||||
if (site != null && !site.isEmpty()) {
|
||||
uniqueSites.add(site);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entries.add(name + " (" + siteCount + ")");
|
||||
}
|
||||
|
||||
if (entries.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String playersCsv = join(players);
|
||||
String sitesCsv = join(new ArrayList<String>(uniqueSites));
|
||||
|
||||
ConcurrentHashMap<String, String> context = new ConcurrentHashMap<String, String>();
|
||||
context.put("players", playersCsv);
|
||||
context.put("numberofplayers", String.valueOf(players.size()));
|
||||
context.put("sites", sitesCsv);
|
||||
context.put("numberofsites", String.valueOf(uniqueSites.size()));
|
||||
|
||||
broadcastNow("Server", entries, "interval", context);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Utilities =======================
|
||||
*/
|
||||
|
||||
private List<String> single(String site) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (site != null && !site.isEmpty()) {
|
||||
list.add(site);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String> applyMaxSites(List<String> sites, BroadcastSettings s) {
|
||||
if (sites == null) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
int max = s.getMaxSitesListed();
|
||||
if (max <= 0 || sites.size() <= max) {
|
||||
return new ArrayList<String>(sites);
|
||||
}
|
||||
return new ArrayList<String>(sites.subList(0, max));
|
||||
}
|
||||
|
||||
private String resolveName(UUID uuid) {
|
||||
try {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(uuid);
|
||||
String name = op == null ? null : op.getName();
|
||||
return name == null || name.isEmpty() ? "Player" : name;
|
||||
} catch (Exception e) {
|
||||
return "Player";
|
||||
}
|
||||
}
|
||||
|
||||
private String join(List<String> list) {
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (String s : list) {
|
||||
if (s != null && !s.isEmpty()) {
|
||||
joiner.add(s);
|
||||
}
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.time.ParsedDuration;
|
||||
|
||||
/**
|
||||
* Immutable broadcast configuration.
|
||||
*
|
||||
* Type: NONE disables broadcasting.
|
||||
*/
|
||||
public final class BroadcastSettings {
|
||||
|
||||
private final VoteBroadcastType type;
|
||||
private final ParsedDuration duration;
|
||||
private final int maxSitesListed;
|
||||
private final BroadcastFormat format;
|
||||
|
||||
/**
|
||||
* Constructs a BroadcastSettings with the specified parameters.
|
||||
*
|
||||
* @param type the broadcast type
|
||||
* @param duration the broadcast duration
|
||||
* @param maxSitesListed the maximum number of sites to list
|
||||
* @param format the broadcast format
|
||||
*/
|
||||
public BroadcastSettings(VoteBroadcastType type, ParsedDuration duration, int maxSitesListed,
|
||||
BroadcastFormat format) {
|
||||
this.type = type == null ? VoteBroadcastType.NONE : type;
|
||||
this.duration = duration == null ? ParsedDuration.empty() : duration;
|
||||
this.maxSitesListed = Math.max(0, maxSitesListed);
|
||||
this.format = format == null ? new BroadcastFormat("", "", "") : format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the broadcast type.
|
||||
*
|
||||
* @return the broadcast type
|
||||
*/
|
||||
public VoteBroadcastType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the broadcast duration.
|
||||
*
|
||||
* @return the broadcast duration
|
||||
*/
|
||||
public ParsedDuration getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of sites to list.
|
||||
*
|
||||
* @return the maximum number of sites to list
|
||||
*/
|
||||
public int getMaxSitesListed() {
|
||||
return maxSitesListed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the broadcast format.
|
||||
*
|
||||
* @return the broadcast format
|
||||
*/
|
||||
public BroadcastFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether broadcasting is disabled.
|
||||
*
|
||||
* @return true if broadcasting is disabled
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return type == VoteBroadcastType.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads VoteBroadcast settings from config.yml.
|
||||
*
|
||||
* Expected structure: VoteBroadcast: Type: EVERY_VOTE Duration: 2m
|
||||
* MaxSitesListed: 0 Format: BroadcastMsg: '...' Header: '...' ListLine: '...'
|
||||
*
|
||||
* @param sec the configuration section to load from
|
||||
* @return the loaded broadcast settings
|
||||
*/
|
||||
public static BroadcastSettings load(ConfigurationSection sec) {
|
||||
VoteBroadcastType type = VoteBroadcastType.parse(sec == null ? null : sec.getString("Type"),
|
||||
VoteBroadcastType.NONE);
|
||||
|
||||
ParsedDuration duration = ParsedDuration.parse(sec == null ? "2m" : sec.getString("Duration", "2m"),
|
||||
TimeUnit.MINUTES);
|
||||
|
||||
int maxSites = sec == null ? 0 : sec.getInt("MaxSitesListed", 0);
|
||||
|
||||
ConfigurationSection fmt = sec == null ? null : sec.getConfigurationSection("Format");
|
||||
|
||||
String broadcastMsg = fmt == null ? "&6[Vote] &aThanks &e%player% &afor voting on &e%site%&a!"
|
||||
: fmt.getString("BroadcastMsg", "&6[Vote] &aThanks &e%player% &afor voting on &e%site%&a!");
|
||||
|
||||
String header = fmt == null ? "&6[Vote] &a%player% voted! &7(%sites_count%)"
|
||||
: fmt.getString("Header", "&6[Vote] &a%player% voted! &7(%sites_count%)");
|
||||
|
||||
String listLine = fmt == null ? " &7- &e%site%" : fmt.getString("ListLine", " &7- &e%site%");
|
||||
|
||||
return new BroadcastSettings(type, duration, maxSites, new BroadcastFormat(broadcastMsg, header, listLine));
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Defines WHEN vote broadcasts occur.
|
||||
*
|
||||
* Set Type: NONE to disable broadcasting entirely.
|
||||
*/
|
||||
public enum VoteBroadcastType {
|
||||
|
||||
/**
|
||||
* No vote broadcasting.
|
||||
*/
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* Broadcast on every vote (even if the player is offline). Uses
|
||||
* Format.BroadcastMsg (+ optional header/list if you choose).
|
||||
*/
|
||||
EVERY_VOTE,
|
||||
|
||||
/**
|
||||
* Broadcast on every vote ONLY if the voting player is online. Useful when
|
||||
* processing offline votes but you don't want global spam for them.
|
||||
*/
|
||||
EVERY_VOTE_ONLINE_ONLY,
|
||||
|
||||
/**
|
||||
* Broadcast at most once per Duration per player. (Even if they vote multiple
|
||||
* sites inside the cooldown.)
|
||||
*/
|
||||
COOLDOWN_PER_PLAYER,
|
||||
|
||||
/**
|
||||
* Batch sites per player for Duration, then broadcast one message listing
|
||||
* sites.
|
||||
*/
|
||||
BATCH_WINDOW_PER_PLAYER,
|
||||
|
||||
/**
|
||||
* Broadcast only the first vote of the day per player (calendar day).
|
||||
*/
|
||||
FIRST_VOTE_OF_DAY,
|
||||
|
||||
/**
|
||||
* Every Duration, broadcast a global summary of who voted and how many sites.
|
||||
* Uses context placeholders: %players%, %numberofplayers%, %sites%,
|
||||
* %numberofsites%.
|
||||
*/
|
||||
INTERVAL_SUMMARY_GLOBAL;
|
||||
|
||||
/**
|
||||
* Parses a vote broadcast type from a string.
|
||||
* @param s the string to parse
|
||||
* @param def the default value if parsing fails
|
||||
* @return the parsed broadcast type or default
|
||||
*/
|
||||
public static VoteBroadcastType parse(String s, VoteBroadcastType def) {
|
||||
if (s == null || s.trim().isEmpty()) {
|
||||
return def;
|
||||
}
|
||||
try {
|
||||
return VoteBroadcastType.valueOf(s.trim().toUpperCase(Locale.ROOT));
|
||||
} catch (Exception ignored) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
-49
@@ -1,49 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandAdminVote.
|
||||
*/
|
||||
public class CommandAdminVote implements CommandExecutor {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructs a new CommandAdminVote instance.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public CommandAdminVote(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (CommandHandler commandHandler : plugin.getAdminVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandAliases.
|
||||
*/
|
||||
public class CommandAliases implements CommandExecutor {
|
||||
|
||||
private boolean adminCommand;
|
||||
|
||||
/** The cmd handle. */
|
||||
private CommandHandler cmdHandle;
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/**
|
||||
* Constructs a new CommandAliases instance.
|
||||
*
|
||||
* @param cmdHandle the command handler
|
||||
* @param adminCommand whether this is an admin command
|
||||
*/
|
||||
public CommandAliases(CommandHandler cmdHandle, boolean adminCommand) {
|
||||
this.cmdHandle = cmdHandle;
|
||||
this.adminCommand = adminCommand;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
ArrayList<String> argsNew = new ArrayList<>();
|
||||
argsNew.add(cmdHandle.getArgs()[0]);
|
||||
for (String arg : args) {
|
||||
argsNew.add(arg);
|
||||
}
|
||||
plugin.debug("Attempting cmd...");
|
||||
plugin.debug("Inputed args: " + ArrayUtils.makeStringList(argsNew));
|
||||
|
||||
ArrayList<CommandHandler> handles = new ArrayList<>();
|
||||
if (adminCommand) {
|
||||
handles.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
handles.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
|
||||
for (CommandHandler cmdHandle : handles) {
|
||||
if (cmdHandle.getArgs().length > args.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
|
||||
argsNew.set(0, arg);
|
||||
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argsNew.size(); i++) {
|
||||
if (i < cmdHandle.getArgs().length) {
|
||||
if (!cmdHandle.argsMatch(argsNew.get(i), i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
if (cmdHandle.runCommand(sender, ArrayUtils.convert(argsNew))) {
|
||||
plugin.debug("cmd found, ran cmd");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* for (String arg : cmdHandle.getArgs()[0].split("&")) { argsNew.set(0, arg);
|
||||
* if (cmdHandle.runCommand(sender, Utils.getInstance().convertArray(argsNew)))
|
||||
* { plugin.debug( "cmd found, ran cmd"); return true; } }
|
||||
*/
|
||||
|
||||
// invalid command
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
} else {
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-68
@@ -1,68 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandVote.
|
||||
*/
|
||||
public class CommandVote implements CommandExecutor {
|
||||
|
||||
/** The instance. */
|
||||
private static CommandVote instance = new CommandVote();
|
||||
|
||||
/** The plugin. */
|
||||
private static VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of CommandVote.
|
||||
*
|
||||
* @return single instance of CommandVote
|
||||
*/
|
||||
public static CommandVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command vote.
|
||||
*/
|
||||
private CommandVote() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command vote.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public CommandVote(VotingPluginMain plugin) {
|
||||
CommandVote.plugin = plugin;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
for (CommandHandler commandHandler : plugin.getVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,455 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.simpleapi.valuerequest.InputMethod;
|
||||
import com.bencodez.simpleapi.valuerequest.StringListener;
|
||||
import com.bencodez.simpleapi.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.yml.editor.ConfigEditor;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.player.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteVoteMilestones;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.voteshop.AdminVoteVoteShop;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
/**
|
||||
* Admin GUI handler for the voting plugin.
|
||||
*/
|
||||
public class AdminGUI {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminGUI.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
*/
|
||||
public AdminGUI(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI.
|
||||
*
|
||||
* @return ArrayList of buttons
|
||||
*/
|
||||
public ArrayList<BInventoryButton> adminGUIButtons() {
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<>();
|
||||
buttons.add(new BInventoryButton("&cVoteSites",
|
||||
new String[] { "&cOnly enabled sites are listed in this section", "&cMiddle Click to create" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
new ValueRequest(plugin, plugin.getDialogService(), null).requestString(player, "", null, true, "Enter vote site", new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
plugin.getConfigVoteSites().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
openAdminGUIVoteSiteSite(player, plugin.getVoteSiteManager().getVoteSite(value, true));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
openAdminGUIVoteSites(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.CHEST, 1).setName("&cEdit VoteShop")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteShop(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.DIAMOND_BLOCK, 1).setName("&cEdit VoteMilestones")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteMilestones(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit VoteParty")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteParty(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit FirstVote reward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("FirstVote"));
|
||||
}
|
||||
});
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit FirstVoteToday reward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("FirstVoteToday"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AllSites reward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("AllSites"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AlmostAllSites reward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("AlmostAllSites"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AnySiteRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("AnySiteRewards"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit EverySiteReward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("EverySiteReward"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit BungeeVotePartyRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("BungeeVotePartyRewards"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder("GRASS_BLOCK").setName("&cEdit BungeeSettings.yml").addLoreLine("&aCurrently WIP")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ConfigEditor(plugin, plugin.getBungeeSettings()).open(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder("GRASS_BLOCK").setName("&cEdit Config.yml").addLoreLine("&aCurrently WIP")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ConfigEditor(plugin, plugin.getConfigFile(), plugin.getOptions().getYmlConfig(),
|
||||
plugin.getOptions().getClass()).open(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder(Material.CHEST).setName("&cEdit GUI.yml").addLoreLine("&aCurrently WIP")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ConfigEditor(plugin, plugin.getGui()).open(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder("GRASS_BLOCK").setName("&cEdit SpecialRewards.yml").addLoreLine("&aCurrently WIP")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ConfigEditor(plugin, plugin.getSpecialRewardsConfig()).open(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", new String[] {}, new ItemStack(Material.BUCKET, 1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder(Material.STONE, 1).setName("&cBackground task time").addLoreLine("&aClick to see")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.getPlayer().sendMessage("Last background task time: " + plugin.getLastBackgroundTaskTimeTaken());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load hook to add admin GUI buttons.
|
||||
*/
|
||||
public void loadHook() {
|
||||
for (BInventoryButton b : adminGUIButtons()) {
|
||||
com.bencodez.advancedcore.command.gui.AdminGUI.getInstance().addButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote sites.
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
public void openAdminGUIVoteSites(Player player) {
|
||||
BInventory inv = new BInventory("VoteSites");
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSiteManager().getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("Enabled: " + voteSite.isEnabled());
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
|
||||
lore.add("Name: " + voteSite.getDisplayName());
|
||||
lore.add("ServiceSite: " + voteSite.getServiceSite());
|
||||
lore.add("VoteURL: " + voteSite.getVoteURL());
|
||||
lore.add("VoteDelay: " + voteSite.getVoteDelay());
|
||||
|
||||
inv.addButton(count,
|
||||
new BInventoryButton(voteSite.getKey(), ArrayUtils.convert(lore), new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote site site.
|
||||
*
|
||||
* @param player the player
|
||||
* @param voteSite the vote site
|
||||
*/
|
||||
public void openAdminGUIVoteSiteSite(Player player, VoteSite voteSite) {
|
||||
EditGUI inv = new EditGUI("VoteSite: " + voteSite.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", voteSite);
|
||||
|
||||
inv.addButton(new BInventoryButton(voteSite.getItem().setName("&cForce vote")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ArrayList<String> playerNames = new ArrayList<>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
playerNames.add(p.getName());
|
||||
}
|
||||
new ValueRequest(plugin, plugin.getDialogService(), InputMethod.INVENTORY).requestString(
|
||||
event.getWhoClicked(), "", playerNames, true, "Select player", new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
Object ob = PlayerUtils.getPlayerMeta(plugin, player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("Priority", voteSite.getPriority()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().setPriority(voteSite.getKey(), num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("ServiceSite", voteSite.getServiceSite()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setServiceSite(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("Name", voteSite.getDisplayName()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().setDisplayName(voteSite.getKey(), value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("VoteURL", voteSite.getVoteURL()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteURL(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("VoteDelay", voteSite.getVoteDelay()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteDelay(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelayDailyHour", voteSite.getVoteDelayDailyHour()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteDelayDailyHour(siteName, num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("Enabled", voteSite.isEnabled()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setEnabled(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("ForceOffline", voteSite.isGiveOffline()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setForceOffline(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("VoteDelayDaily", voteSite.isVoteDelayDaily()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteDelayDaily(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
if (voteSite.getSiteData().isList("Rewards")) {
|
||||
|
||||
inv.addButton(
|
||||
new EditGUIButton(new EditGUIValueList("Rewards", voteSite.getSiteData().getStringList("Rewards")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player p, ArrayList<String> rewards) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().set(voteSite.getKey(), "Rewards", rewards);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler()
|
||||
.getDirectlyDefined("VoteSites." + voteSite.getKey() + ".Rewards"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (voteSite.getSiteData().isList("CoolDownEndRewards")) {
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueList("CoolDownEndRewards",
|
||||
voteSite.getSiteData().getStringList("CoolDownEndRewards")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player p, ArrayList<String> rewards) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().set(voteSite.getKey(), "CoolDownEndRewards", rewards);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cCoolDownEndRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler()
|
||||
.getDirectlyDefined("VoteSites." + voteSite.getKey() + ".CoolDownEndRewards"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Abstract class for admin vote confirmation dialogs.
|
||||
*/
|
||||
public abstract class AdminVoteConfirmation extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteConfirmation.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param title the title of the confirmation dialog
|
||||
*/
|
||||
public AdminVoteConfirmation(VotingPluginMain plugin, CommandSender player, String title) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aConfirm")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
onConfirm(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&aCancel")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
onDeny(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user confirms the action.
|
||||
*
|
||||
* @param p the player who confirmed
|
||||
*/
|
||||
public abstract void onConfirm(Player p);
|
||||
|
||||
/**
|
||||
* Called when the user denies the action.
|
||||
*
|
||||
* @param p the player who denied
|
||||
*/
|
||||
public abstract void onDeny(Player p);
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* Admin help GUI handler.
|
||||
*/
|
||||
public class AdminVoteHelp extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteHelp.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param page the page number to display
|
||||
*/
|
||||
public AdminVoteHelp(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin help.
|
||||
*
|
||||
* @param sender the sender
|
||||
* @param page the page
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelp(CommandSender sender, int page) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
ArrayList<TextComponent> text = adminHelpText(sender);
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
if ((text.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add(MessageAPI.stringToComp("&6&lVotingPlugin Admin Help " + (page) + "/" + maxPage));
|
||||
msg.add(MessageAPI.stringToComp("&6&l() = Needed"));
|
||||
msg.add(MessageAPI.stringToComp("&6&lAliases: adminvote, av"));
|
||||
|
||||
for (int i = pagesize * (page - 1); (i < text.size()) && (i < ((page) * pagesize)); i++) {
|
||||
msg.add(text.get(i));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin help text.
|
||||
*
|
||||
* @param sender the sender
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
|
||||
if (!requirePerms || cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
msg.add(unsorted.get(cmd));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessageJson(adminHelp(sender, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
}
|
||||
-276
@@ -1,276 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin permissions GUI handler.
|
||||
*/
|
||||
public class AdminVotePerms extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private String playerName;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVotePerms.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVotePerms with player name.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param page the page number
|
||||
* @param playerName the player name to check
|
||||
*/
|
||||
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page, String playerName) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* List permissions for a sender.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return array of permission strings
|
||||
*/
|
||||
public String[] listPerms(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
|
||||
}
|
||||
} else {
|
||||
msg.add(handle.getHelpLineCommand("/vote") + " : " + handle.getPerm().split(Pattern.quote("|"))[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
|
||||
}
|
||||
} else {
|
||||
msg.add(handle.getHelpLineCommand("/av") + " : " + handle.getPerm().split(Pattern.quote("|"))[0]);
|
||||
}
|
||||
}
|
||||
|
||||
for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
if (sender instanceof Player) {
|
||||
Set<String> child = perm.getChildren().keySet();
|
||||
if (child.size() > 0) {
|
||||
if (sender.hasPermission(perm)) {
|
||||
msg.add("&6" + perm.getName() + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + perm.getName() + " : &cfalse");
|
||||
}
|
||||
} else {
|
||||
if (sender.hasPermission(perm)) {
|
||||
msg.add("&6" + perm.getName() + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + perm.getName() + " : &cfalse");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
msg.add(perm.getName());
|
||||
}
|
||||
}
|
||||
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
|
||||
int maxPage = msg.size() / pagesize;
|
||||
if ((msg.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
ArrayList<String> text = new ArrayList<>();
|
||||
|
||||
text.add("&c&lCommand : Permissions " + page + "/" + maxPage);
|
||||
|
||||
for (int i = pagesize * page - pagesize; i < msg.size() && i < pagesize * page; i++) {
|
||||
text.add(msg.get(i));
|
||||
}
|
||||
|
||||
text = ArrayUtils.colorize(text);
|
||||
|
||||
return ArrayUtils.convert(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* List permissions for a specific player.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @param player the player name
|
||||
* @param page the page number
|
||||
* @return list of permission strings
|
||||
*/
|
||||
public ArrayList<String> listPerms(CommandSender sender, String player, int page) {
|
||||
Player p = Bukkit.getPlayer(player);
|
||||
ArrayList<String> text = new ArrayList<>();
|
||||
if (p != null) {
|
||||
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
|
||||
}
|
||||
}
|
||||
|
||||
for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
Set<String> child = perm.getChildren().keySet();
|
||||
if (child.size() > 0) {
|
||||
if (p.hasPermission(perm)) {
|
||||
msg.add("&6" + perm.getName() + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + perm.getName() + " : &cfalse");
|
||||
}
|
||||
} else {
|
||||
if (p.hasPermission(perm)) {
|
||||
msg.add("&6" + perm.getName() + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + perm.getName() + " : &cfalse");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
|
||||
int maxPage = msg.size() / pagesize;
|
||||
if ((msg.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
text.add("&c&lCommand : Permissions for " + player + " " + page + "/" + maxPage);
|
||||
|
||||
for (int i = pagesize * page - pagesize; i < msg.size() && i < pagesize * page; i++) {
|
||||
text.add(msg.get(i));
|
||||
}
|
||||
} else {
|
||||
text.add("&cPlayer not online: " + player);
|
||||
}
|
||||
return ArrayUtils.colorize(text);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* List permissions in developer format.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return array of permission strings in developer format
|
||||
*/
|
||||
public String[] listPermsDev(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("Command");
|
||||
msg.add(" Permissions (seperated by |");
|
||||
msg.add(" Help messasge");
|
||||
msg.add(" ");
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
msg.add(handle.getHelpLineCommand("/vote"));
|
||||
msg.add(" " + handle.getPerm());
|
||||
msg.add(" " + handle.getHelpMessage());
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
msg.add(handle.getHelpLineCommand("/av"));
|
||||
msg.add(" " + handle.getPerm());
|
||||
msg.add(" " + handle.getHelpMessage());
|
||||
}
|
||||
|
||||
for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
msg.add(perm.getName() + " : " + perm.getDescription());
|
||||
}
|
||||
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
|
||||
return ArrayUtils.convert(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
if (playerName != null) {
|
||||
sendMessage(listPerms(sender, playerName, page));
|
||||
} else {
|
||||
sendMessage(listPerms(sender));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
}
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
/**
|
||||
* Admin placeholders GUI handler.
|
||||
*/
|
||||
public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVotePlaceholders.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVotePlaceholders(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "votingplugin_" + identifier + " - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(msg)).build());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "votingplugin_" + identifier + " - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(msg)).build());
|
||||
book.addLayout(layout);
|
||||
|
||||
}
|
||||
|
||||
book.open(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cPlaceholders:");
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("votingplugin_" + identifier + " - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("votingplugin_" + identifier + "");
|
||||
}
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("votingplugin_" + identifier + " - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("votingplugin_" + identifier + "");
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
}
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
/**
|
||||
* Admin placeholders player GUI handler.
|
||||
*/
|
||||
public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVotePlaceholdersPlayer.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public AdminVotePlaceholdersPlayer(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user, identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(value)).build());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
String value = placeholder.placeholderRequest(identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(value)).build());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
book.open(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cPlaceholders:");
|
||||
VotingPluginUser placeholderUser = user;
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
msg.add("votingplugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
|
||||
msg.add("votingplugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
}
|
||||
-189
@@ -1,189 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.user.UserDataFetchMode;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.player.VoteGUI;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
/**
|
||||
* Admin top points GUI handler.
|
||||
*/
|
||||
public class AdminVoteTopPoints extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteTopPoints.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteTopPoints(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topPoints1 = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
|
||||
for (String uuid : plugin.getVotingPluginUserManager().getAllUUIDs()) {
|
||||
VotingPluginUser vpUser = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
vpUser.userDataFetechMode(UserDataFetchMode.NO_CACHE);
|
||||
int points = vpUser.getPoints();
|
||||
if (points > 0) {
|
||||
topPoints1.put(vpUser.getTopVoterPlayer(), points);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topPoints = plugin.getTopVoterHandler().sortByValues(topPoints1,
|
||||
false);
|
||||
|
||||
users = topPoints.entrySet();
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
playerSlots.addAll(customizationPlayerSlots);
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory("Top Points");
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
|
||||
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
BInventoryButton button = new BInventoryButton(playerItem
|
||||
.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (plugin.getGui().isChestVoteTopOpenMainGUIOnClick()) {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey());
|
||||
|
||||
if (customzationEnabled && !playerSlots.isEmpty()) {
|
||||
button.setSlot(playerSlots.remove());
|
||||
}
|
||||
|
||||
inv.setCloseInv(plugin.getGui().isChestVoteTopCloseGUIOnClick());
|
||||
|
||||
inv.addButton(button);
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
if (customzationEnabled) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user)
|
||||
.setSlot(customization.getInt("BackButtonSlot", 0)));
|
||||
} else {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteTop.Customization";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (customization == null || !customzationEnabled || !customization.getBoolean("RemoveBottomBar")) {
|
||||
inv.setPages(true);
|
||||
}
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-252
@@ -1,252 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.simpleapi.valuerequest.InputMethod;
|
||||
import com.bencodez.simpleapi.valuerequest.NumberListener;
|
||||
import com.bencodez.simpleapi.valuerequest.ValueRequest;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote party GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteParty extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteParty.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteParty(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Edit VoteParty");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteParty");
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("Enabled", plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1),
|
||||
new EditGUIValueNumber("VotesRequired", plugin.getSpecialRewardsConfig().getVotePartyVotesRequired()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
setPathData(getKey(), num.intValue());
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.LADDER, 1), new EditGUIValueNumber(
|
||||
"IncreaseVotesRquired", plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRequired()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
setPathData(getKey(), num.intValue());
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.LADDER).setName("&cCurrent increase amount")
|
||||
.addLoreLine("&cCurrent value: " + plugin.getServerData().getVotePartyExtraRequired())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Number> options = new ArrayList<Number>();
|
||||
options.add(Integer.valueOf(0));
|
||||
options.add(Integer.valueOf(10));
|
||||
options.add(Integer.valueOf(50));
|
||||
options.add(Integer.valueOf(100));
|
||||
|
||||
new ValueRequest(plugin, plugin.getDialogService(), InputMethod.INVENTORY).requestNumber(
|
||||
clickEvent.getPlayer(), Integer.valueOf(plugin.getServerData().getVotePartyExtraRequired()),
|
||||
options, true, "Set extra votes", new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(value.intValue());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1), new EditGUIValueNumber(
|
||||
"UserVotesRequired", plugin.getSpecialRewardsConfig().getVotePartyUserVotesRequired()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
setPathData(getKey(), num.intValue());
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("GiveAllPlayers",
|
||||
plugin.getSpecialRewardsConfig().isVotePartyGiveAllPlayers()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean(
|
||||
"GiveOnlinePlayersOnly", plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("ResetEachDay", plugin.getSpecialRewardsConfig().isVotePartyResetEachDay()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("ResetWeekly", plugin.getSpecialRewardsConfig().isVotePartyResetWeekly()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("ResetMonthly", plugin.getSpecialRewardsConfig().isVotePartyResetMonthly()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("OnlyOncePerDay",
|
||||
plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerDay()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean(
|
||||
"ResetExtraVotesMonthly", plugin.getSpecialRewardsConfig().isVotePartyResetExtraVotesMonthly()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("CountFakeVotes",
|
||||
plugin.getSpecialRewardsConfig().isVotePartyCountFakeVotes()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("CountOfflineVotes",
|
||||
plugin.getSpecialRewardsConfig().isVotePartyCountOfflineVotes()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueString("Broadcast", plugin.getSpecialRewardsConfig().getVotePartyBroadcast()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueList("Commands", plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, ArrayList<String> value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")
|
||||
.addLoreLine("&aUse this for per player rewards, also set online only rewards here as well")
|
||||
.addLoreLine("&cTo set rewards to be given to players online only, set RewardType to ONLINE")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("VoteParty.Rewards"));
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getSpecialRewardsConfig().getData().set("VoteParty." + path, value);
|
||||
plugin.getSpecialRewardsConfig().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
}
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
/**
|
||||
* Admin vote player GUI handler.
|
||||
*/
|
||||
public class AdminVoteVotePlayer extends GUIHandler {
|
||||
|
||||
private String playerName;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVotePlayer.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param playerName the player name
|
||||
*/
|
||||
public AdminVoteVotePlayer(VotingPluginMain plugin, CommandSender player, String playerName) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Trigger vote for " + playerName);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Vote|VotingPlugin.Admin");
|
||||
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
inv.addButton(new BInventoryButton(site.getItem().setName(site.getKey())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VoteSite site = (VoteSite) getData("site");
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, playerName, site.getServiceSite(), false);
|
||||
sendMessage(clickEvent.getPlayer(), "&cTriggering vote...");
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
sendMessage(clickEvent.getPlayer(),
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
}
|
||||
}
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (plugin.isYmlError()) {
|
||||
sendMessage(clickEvent.getPlayer(),
|
||||
"&3Detected yml error, please check server log for details");
|
||||
}
|
||||
}
|
||||
}.addData("site", site));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.milestones;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteConfirmation;
|
||||
|
||||
/**
|
||||
* Admin vote milestone remove GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteMilestoneRemove extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteMilestoneRemove.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteMilestoneRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Remove VoteMilestones");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteMilestones");
|
||||
for (final String votes : plugin.getVoteMilestonesManager().getConfig().getMilestones().keySet()) {
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(Material.PAPER, 1).setName(votes).addLoreLine("&c&lClick to remove")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteConfirmation(plugin, clickEvent.getPlayer(), "Remove milestone " + votes + "?") {
|
||||
|
||||
@Override
|
||||
public void onConfirm(Player p) {
|
||||
plugin.getSpecialRewardsConfig().removeVoteMilestone(votes);
|
||||
p.sendMessage("Removed milestone " + votes);
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteVoteMilestones(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-120
@@ -1,120 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.milestones;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.simpleapi.valuerequest.InputMethod;
|
||||
import com.bencodez.simpleapi.valuerequest.NumberListener;
|
||||
import com.bencodez.simpleapi.valuerequest.StringListener;
|
||||
import com.bencodez.simpleapi.valuerequest.ValueRequest;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote milestones GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteMilestones extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteMilestones.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteMilestones(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit VoteMilestones");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteMilestones");
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER)
|
||||
.setName("&cEdit existing vote milestone rewards (Legacy milestones not included)")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
Set<String> keys = plugin.getVoteMilestonesManager().getConfig().getMilestones().keySet();
|
||||
ArrayList<String> milestoneKeys = new ArrayList<String>();
|
||||
for (String key : keys) {
|
||||
if (!key.startsWith("Legacy_")) {
|
||||
milestoneKeys.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
new ValueRequest(plugin, plugin.getDialogService(), InputMethod.INVENTORY).requestString(
|
||||
clickEvent.getPlayer(), "", milestoneKeys, false, "Select milestone", new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("VoteMilestones." + value + ".Rewards"));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd milestone")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ValueRequest(plugin, plugin.getDialogService(), null).requestNumber(player, 0, null, true,
|
||||
"Enter milestone", new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
plugin.getSpecialRewardsConfig().setVoteMilestone(value.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&cRemove milestone")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteMilestoneRemove(plugin, clickEvent.getPlayer()).open();
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-169
@@ -1,169 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select an event filter, then open AdminVoteLogRecent (filtered).
|
||||
*/
|
||||
public class AdminVoteLogEventSelect extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogEventSelect.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
*/
|
||||
public AdminVoteLogEventSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days) {
|
||||
this(plugin, sender, table, user, days, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogEventSelect with page.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogEventSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Events";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
List<VoteLogMysqlTable.VoteLogEvent> events = Arrays.asList(VoteLogMysqlTable.VoteLogEvent.values());
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(events.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= events.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo events")
|
||||
.addLoreLine("&7No events on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
VoteLogMysqlTable.VoteLogEvent ev = events.get(i);
|
||||
inv.addButton(makeEventButton(ev));
|
||||
}
|
||||
}
|
||||
|
||||
// back button
|
||||
if (user != null && plugin.getGui().isChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(7));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEventButton(VoteLogMysqlTable.VoteLogEvent ev) {
|
||||
ItemBuilder item = new ItemBuilder(Material.BOOK).setName("&a" + ev.name())
|
||||
.addLoreLine("&7Click to view recent logs filtered by this event")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days, ev).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-125
@@ -1,125 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Helper class for admin vote log GUI operations.
|
||||
*/
|
||||
public class AdminVoteLogHelpers {
|
||||
/**
|
||||
* Get the material icon for a vote log event.
|
||||
*
|
||||
* @param event the vote log event
|
||||
* @param status the status of the vote
|
||||
* @return the material to use for the icon
|
||||
*/
|
||||
public static Material getMaterialForEvent(VoteLogMysqlTable.VoteLogEvent event, String status) {
|
||||
// Cached entries still override to chest (keeps your current behavior)
|
||||
if ("CACHED".equalsIgnoreCase(status)) {
|
||||
return Material.CHEST;
|
||||
}
|
||||
|
||||
if (event == null) {
|
||||
return Material.PAPER;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case VOTE_RECEIVED:
|
||||
return Material.EMERALD;
|
||||
|
||||
case VOTEMILESTONE:
|
||||
return Material.ANVIL;
|
||||
|
||||
case VOTE_STREAK_REWARD:
|
||||
return Material.FIREWORK_ROCKET;
|
||||
|
||||
case TOP_VOTER_REWARD:
|
||||
return Material.GOLD_BLOCK;
|
||||
|
||||
default:
|
||||
return Material.PAPER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color code for a vote log event.
|
||||
*
|
||||
* @param event the vote log event
|
||||
* @return the color code string
|
||||
*/
|
||||
public static String getEventColor(VoteLogMysqlTable.VoteLogEvent event) {
|
||||
if (event == null) {
|
||||
return "&7";
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case VOTE_RECEIVED:
|
||||
return "&a";
|
||||
case VOTEMILESTONE:
|
||||
return "&6";
|
||||
|
||||
case VOTE_STREAK_REWARD:
|
||||
return "&d";
|
||||
|
||||
case TOP_VOTER_REWARD:
|
||||
return "&c";
|
||||
|
||||
default:
|
||||
return "&7";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a safe string, converting null to empty string.
|
||||
*
|
||||
* @param s the string to check
|
||||
* @return the string or empty string if null
|
||||
*/
|
||||
public static String safe(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string is not null and not empty.
|
||||
*
|
||||
* @param s the string to check
|
||||
* @return true if the string is not empty
|
||||
*/
|
||||
public static boolean notEmpty(String s) {
|
||||
return s != null && !s.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a timestamp in milliseconds to a readable date string.
|
||||
*
|
||||
* @param millis the timestamp in milliseconds
|
||||
* @return the formatted date string
|
||||
*/
|
||||
public static String formatTime(long millis) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date(millis));
|
||||
} catch (Exception e) {
|
||||
return String.valueOf(millis);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a shortened version of a UUID string.
|
||||
*
|
||||
* @param uuid the UUID string
|
||||
* @return the first 8 characters of the UUID or "unknown"
|
||||
*/
|
||||
public static String shortUuid(String uuid) {
|
||||
if (uuid == null || uuid.isEmpty()) {
|
||||
return "unknown";
|
||||
}
|
||||
return uuid.length() > 8 ? uuid.substring(0, 8) : uuid;
|
||||
}
|
||||
|
||||
}
|
||||
-208
@@ -1,208 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin vote log menu GUI handler.
|
||||
*/
|
||||
public class AdminVoteLogMenu extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days; // window used by selectors/stats (0 = all time)
|
||||
|
||||
// Default to "voting" (Vote received)
|
||||
private final VoteLogMysqlTable.VoteLogEvent defaultEvent = VoteLogMysqlTable.VoteLogEvent.VOTE_RECEIVED;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogMenu.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param days the number of days to filter
|
||||
*/
|
||||
public AdminVoteLogMenu(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, int days) {
|
||||
this(plugin, sender, table, null, days);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogMenu with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
*/
|
||||
public AdminVoteLogMenu(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
this.days = Math.max(0, days);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Admin";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.NAME_TAG).setName("&aVotes by Player")
|
||||
.addLoreLine("&7List stored player names").addLoreLine("&7Click a player to view their votelog")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogPlayerSelect(plugin, clickEvent.getPlayer(), table, user, days, 0).open();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.NAME_TAG).setName("&aVotes by Player (Online)")
|
||||
.addLoreLine("&7List online players").addLoreLine("&7Click a player to view their votelog")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogPlayerSelectOnline(plugin, clickEvent.getPlayer(), table, user, days, 0).open();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&aVotes by Service")
|
||||
.addLoreLine("&7List all services found").addLoreLine("&7Click a service to view votelog")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogServiceSelect(plugin, clickEvent.getPlayer(), table, user, days, 0).open();
|
||||
}
|
||||
});
|
||||
|
||||
// NEW: Votes by Server
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&aVotes by Server")
|
||||
.addLoreLine("&7List all servers found").addLoreLine("&7Click a server to view votelog")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogServerSelect(plugin, clickEvent.getPlayer(), table, user, days, 0).open();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.MAP).setName("&aStats")
|
||||
.addLoreLine("&7Overview counts/uniques/top services")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogStats(plugin, clickEvent.getPlayer(), table, user, days, 10).open();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.CLOCK).setName("&aRecent Logs")
|
||||
.addLoreLine("&7Recent logs filtered by event").addLoreLine("&7Default: &f" + defaultEvent.name())
|
||||
.addLoreLine("&8(Use bottom buttons to switch event)")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// Open recent with default event filter
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days, defaultEvent).open();
|
||||
}
|
||||
});
|
||||
|
||||
addEventSwitchButtons(inv);
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void addEventSwitchButtons(BInventory inv) {
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Material.LIME_DYE)
|
||||
.setName("&aEvent: &fVOTE_RECEIVED").addLoreLine("&7Show recent vote received events")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days,
|
||||
VoteLogMysqlTable.VoteLogEvent.VOTE_RECEIVED).open();
|
||||
}
|
||||
}.setSlot(3));
|
||||
|
||||
// More... (open selector)
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Material.BOOK).setName("&aEvent: &fMore...").addLoreLine("&7Pick any event filter")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogEventSelect(plugin, clickEvent.getPlayer(), table, user, days).open();
|
||||
}
|
||||
}.setSlot(4));
|
||||
|
||||
// All events
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Material.GRAY_DYE).setName("&aEvent: &fALL")
|
||||
.addLoreLine("&7Show recent logs for all events")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days, null).open();
|
||||
}
|
||||
}.setSlot(5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-185
@@ -1,185 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog entries for a given player (paged).
|
||||
*
|
||||
* Uses VoteLogMysqlTable instance passed in from CommandLoader.
|
||||
*
|
||||
* Supports input as player name OR uuid string (you decide in CommandLoader
|
||||
* which constructor to call).
|
||||
*/
|
||||
public class AdminVoteLogPlayer extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private final int page;
|
||||
|
||||
private final String playerName;
|
||||
|
||||
private final int days;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogPlayer.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param playerName the player name or UUID
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogPlayer(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, String playerName,
|
||||
int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.playerName = playerName;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Player";
|
||||
if (playerName != null && !playerName.isEmpty()) {
|
||||
title += " &7(" + playerName + ")";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows = table.getByPlayerName(playerName, days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(final VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
Material mat = "CACHED".equalsIgnoreCase(entry.status) ? Material.CHEST : Material.EMERALD;
|
||||
|
||||
String timeStr = AdminVoteLogHelpers.formatTime(entry.voteTime);
|
||||
String uuidShort = AdminVoteLogHelpers.shortUuid(entry.playerUuid);
|
||||
String voteShort = AdminVoteLogHelpers.shortUuid(entry.voteId);
|
||||
|
||||
// keep same name/lore layout you already have
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName("&a" + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.playerName) || AdminVoteLogHelpers.notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + AdminVoteLogHelpers.safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + AdminVoteLogHelpers.safe(entry.service));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + AdminVoteLogHelpers.safe(entry.context));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + AdminVoteLogHelpers.safe(entry.status));
|
||||
}
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + AdminVoteLogHelpers.safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// vote_id is now the correlation id entry.voteId
|
||||
new AdminVoteLogVoteId(plugin, clickEvent.getPlayer(), table, entry.voteId, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-155
@@ -1,155 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select an ONLINE player, then open AdminVoteLogPlayer.
|
||||
*/
|
||||
public class AdminVoteLogPlayerSelect extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogPlayerSelect.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogPlayerSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = Math.max(0, days);
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Players";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Player> online = new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(online.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= online.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo players")
|
||||
.addLoreLine("&7No online players on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
Player p = online.get(i);
|
||||
inv.addButton(makePlayerButton(p));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makePlayerButton(final Player target) {
|
||||
String name = target.getName();
|
||||
|
||||
ItemBuilder item = new ItemBuilder(Material.NAME_TAG).setName("&a" + name)
|
||||
.addLoreLine("&7Click to open votelog for this player")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogPlayer(plugin, clickEvent.getPlayer(), table, name, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-151
@@ -1,151 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select an ONLINE player, then open AdminVoteLogPlayer.
|
||||
*/
|
||||
public class AdminVoteLogPlayerSelectOnline extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogPlayerSelectOnline.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogPlayerSelectOnline(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Players";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Player> online = new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(online.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= online.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo players")
|
||||
.addLoreLine("&7No online players on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
Player p = online.get(i);
|
||||
inv.addButton(makePlayerButton(p));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makePlayerButton(Player target) {
|
||||
String name = target.getName();
|
||||
|
||||
ItemBuilder item = new ItemBuilder(Material.NAME_TAG).setName("&a" + name)
|
||||
.addLoreLine("&7Click to open votelog for this player")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogPlayer(plugin, clickEvent.getPlayer(), table, name, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-255
@@ -1,255 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Recent VoteLog entries (paged).
|
||||
*
|
||||
* Now supports optional event filter + days window.
|
||||
*/
|
||||
public class AdminVoteLogRecent extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int page;
|
||||
|
||||
private final int days; // 0 = all time
|
||||
private final VoteLogMysqlTable.VoteLogEvent event; // null = all events
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogRecent.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogRecent(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, int page) {
|
||||
this(plugin, sender, table, null, page, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogRecent with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogRecent(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int page) {
|
||||
this(plugin, sender, table, user, page, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogRecent with full parameters.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param page the page number
|
||||
* @param days the number of days to filter
|
||||
* @param event the event type to filter
|
||||
*/
|
||||
// NEW constructor used by Menu/EventSelect
|
||||
public AdminVoteLogRecent(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int page, int days, VoteLogMysqlTable.VoteLogEvent event) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
this.page = Math.max(0, page);
|
||||
this.days = Math.max(0, days);
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Recent";
|
||||
if (event != null) {
|
||||
title += " &7(" + event.name() + ")";
|
||||
}
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows;
|
||||
if (event == null) {
|
||||
rows = (days > 0) ? table.getRecentAll(days, needed) : table.getRecent(needed);
|
||||
} else {
|
||||
rows = table.getRecentByEvent(event, days, needed);
|
||||
}
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
addEventSwitchButtons(inv);
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void addEventSwitchButtons(BInventory inv) {
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Material.LIME_DYE)
|
||||
.setName("&aEvent: &fVOTE_RECEIVED").addLoreLine("&7Show recent vote received events")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days,
|
||||
VoteLogMysqlTable.VoteLogEvent.VOTE_RECEIVED).open();
|
||||
}
|
||||
}.setSlot(3));
|
||||
|
||||
// More... (open selector)
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Material.BOOK).setName("&aEvent: &fMore...").addLoreLine("&7Pick any event filter")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogEventSelect(plugin, clickEvent.getPlayer(), table, user, days).open();
|
||||
}
|
||||
}.setSlot(4));
|
||||
|
||||
// All events
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Material.GRAY_DYE).setName("&aEvent: &fALL")
|
||||
.addLoreLine("&7Show recent logs for all events")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days, null).open();
|
||||
}
|
||||
}.setSlot(5));
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(final VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
VoteLogMysqlTable.VoteLogEvent event = entry.event != null ? VoteLogMysqlTable.VoteLogEvent.valueOf(entry.event)
|
||||
: null;
|
||||
|
||||
Material mat = AdminVoteLogHelpers.getMaterialForEvent(event, entry.status);
|
||||
|
||||
String eventColor = AdminVoteLogHelpers.getEventColor(event);
|
||||
|
||||
String timeStr = AdminVoteLogHelpers.formatTime(entry.voteTime);
|
||||
String uuidShort = AdminVoteLogHelpers.shortUuid(entry.playerUuid);
|
||||
String voteShort = AdminVoteLogHelpers.shortUuid(entry.voteId);
|
||||
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName(eventColor + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.playerName) || AdminVoteLogHelpers.notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + AdminVoteLogHelpers.safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + AdminVoteLogHelpers.safe(entry.service));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + AdminVoteLogHelpers.safe(entry.context));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + AdminVoteLogHelpers.safe(entry.status));
|
||||
}
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + AdminVoteLogHelpers.safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogVoteId(plugin, clickEvent.getPlayer(), table, entry.voteId, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-204
@@ -1,204 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog entries for a given server (paged).
|
||||
*
|
||||
* Uses VoteLogMysqlTable instance passed in from CommandLoader.
|
||||
*/
|
||||
public class AdminVoteLogServer extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
private final int page;
|
||||
|
||||
private final String server;
|
||||
private final int days;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServer.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param server the server name
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServer(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, String server,
|
||||
int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.server = server;
|
||||
this.days = Math.max(0, days);
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServer with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param server the server name
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServer(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, String server, int days, int page) {
|
||||
this(plugin, sender, table, server, days, page);
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
BInventory inv = new BInventory("&aVoteLog - Server &7(" + AdminVoteLogHelpers.safe(server) + ")");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows = table.getByServer(server, days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(final VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
VoteLogMysqlTable.VoteLogEvent event = entry.event != null ? VoteLogMysqlTable.VoteLogEvent.valueOf(entry.event)
|
||||
: null;
|
||||
|
||||
Material mat = AdminVoteLogHelpers.getMaterialForEvent(event, entry.status);
|
||||
String eventColor = AdminVoteLogHelpers.getEventColor(event);
|
||||
|
||||
String timeStr = AdminVoteLogHelpers.formatTime(entry.voteTime);
|
||||
String uuidShort = AdminVoteLogHelpers.shortUuid(entry.playerUuid);
|
||||
String voteShort = AdminVoteLogHelpers.shortUuid(entry.voteId);
|
||||
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName(eventColor + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.playerName) || AdminVoteLogHelpers.notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + AdminVoteLogHelpers.safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.server)) {
|
||||
item.addLoreLine("&7Server: &f" + AdminVoteLogHelpers.safe(entry.server));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + AdminVoteLogHelpers.safe(entry.service));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + AdminVoteLogHelpers.safe(entry.context));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + AdminVoteLogHelpers.safe(entry.status));
|
||||
}
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + AdminVoteLogHelpers.safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// vote_id is the correlation id
|
||||
new AdminVoteLogVoteId(plugin, clickEvent.getPlayer(), table, entry.voteId, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-152
@@ -1,152 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select a server (distinct list), then open AdminVoteLogServer.
|
||||
*/
|
||||
public class AdminVoteLogServerSelect extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServerSelect.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServerSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = Math.max(0, days);
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Servers";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<String> servers = table.getDistinctServers(days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(servers.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= servers.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo servers")
|
||||
.addLoreLine("&7No servers on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
String srv = servers.get(i);
|
||||
inv.addButton(makeServerButton(srv));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeServerButton(final String server) {
|
||||
ItemBuilder item = new ItemBuilder(Material.PAPER).setName("&a" + AdminVoteLogHelpers.safe(server))
|
||||
.addLoreLine("&7Click to open votelog for this server")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogServer(plugin, clickEvent.getPlayer(), table, server, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-204
@@ -1,204 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog entries for a given service/site (paged).
|
||||
*
|
||||
* Uses VoteLogMysqlTable instance passed in from CommandLoader.
|
||||
*/
|
||||
public class AdminVoteLogService extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
private final int page;
|
||||
|
||||
private final String service;
|
||||
private final int days;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogService.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param service the service name
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogService(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, String service,
|
||||
int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.service = service;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogService with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param service the service name
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogService(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, String service, int days, int page) {
|
||||
this(plugin, sender, table, service, days, page);
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
BInventory inv = new BInventory("&aVoteLog - Service &7(" + AdminVoteLogHelpers.safe(service) + ")");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows = table.getByService(service, days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(final VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
VoteLogMysqlTable.VoteLogEvent event = entry.event != null ? VoteLogMysqlTable.VoteLogEvent.valueOf(entry.event)
|
||||
: null;
|
||||
|
||||
Material mat = AdminVoteLogHelpers.getMaterialForEvent(event, entry.status);
|
||||
|
||||
String eventColor = AdminVoteLogHelpers.getEventColor(event);
|
||||
|
||||
String timeStr = AdminVoteLogHelpers.formatTime(entry.voteTime);
|
||||
String uuidShort = AdminVoteLogHelpers.shortUuid(entry.playerUuid);
|
||||
String voteShort = AdminVoteLogHelpers.shortUuid(entry.voteId);
|
||||
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName(eventColor + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.playerName) || AdminVoteLogHelpers.notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + AdminVoteLogHelpers.safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + AdminVoteLogHelpers.safe(entry.service));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + AdminVoteLogHelpers.safe(entry.context));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + AdminVoteLogHelpers.safe(entry.status));
|
||||
}
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + AdminVoteLogHelpers.safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// vote_id is the correlation id
|
||||
new AdminVoteLogVoteId(plugin, clickEvent.getPlayer(), table, entry.voteId, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-152
@@ -1,152 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select a service (distinct list), then open AdminVoteLogService.
|
||||
*/
|
||||
public class AdminVoteLogServiceSelect extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServiceSelect.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServiceSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = Math.max(0, days);
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Services";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<String> services = table.getDistinctServices(days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(services.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= services.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo services")
|
||||
.addLoreLine("&7No services on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
String svc = services.get(i);
|
||||
inv.addButton(makeServiceButton(svc));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeServiceButton(final String service) {
|
||||
ItemBuilder item = new ItemBuilder(Material.PAPER).setName("&a" + AdminVoteLogHelpers.safe(service))
|
||||
.addLoreLine("&7Click to open votelog for this service")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogService(plugin, clickEvent.getPlayer(), table, service, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select a service from DB (distinct services), then open
|
||||
* AdminVoteLogService.
|
||||
*/
|
||||
public class AdminVoteLogServiceSelectAll extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServiceSelectAll.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServiceSelectAll(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Services";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<String> services = table.getDistinctServices(days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(services.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= services.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo services")
|
||||
.addLoreLine("&7No services on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
String svc = services.get(i);
|
||||
inv.addButton(makeServiceButton(svc));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeServiceButton(String service) {
|
||||
ItemBuilder item = new ItemBuilder(Material.PAPER).setName("&a" + AdminVoteLogHelpers.safe(service))
|
||||
.addLoreLine("&7Click to open votelog for this service")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogService(plugin, clickEvent.getPlayer(), table, service, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-239
@@ -1,239 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog stats overview.
|
||||
*
|
||||
* Uses VoteLogMysqlTable instance passed in from CommandLoader.
|
||||
*
|
||||
* Shows: - total / immediate / cached counts (VoteLogCounts) - unique voters -
|
||||
* top services - top servers
|
||||
*/
|
||||
public class AdminVoteLogStats extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
|
||||
private final int topServicesLimit;
|
||||
private final int topServersLimit;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogStats.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param days the number of days to filter
|
||||
*/
|
||||
public AdminVoteLogStats(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, int days) {
|
||||
this(plugin, sender, table, null, days, 10, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogStats with user and top services limit.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param topServicesLimit the maximum number of top services to display
|
||||
*/
|
||||
public AdminVoteLogStats(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int topServicesLimit) {
|
||||
this(plugin, sender, table, user, days, topServicesLimit, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogStats with full parameters.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param topServicesLimit the maximum number of top services to display
|
||||
* @param topServersLimit the maximum number of top servers to display
|
||||
*/
|
||||
public AdminVoteLogStats(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int topServicesLimit, int topServersLimit) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
this.days = Math.max(0, days);
|
||||
this.topServicesLimit = topServicesLimit <= 0 ? 10 : topServicesLimit;
|
||||
this.topServersLimit = topServersLimit <= 0 ? 10 : topServersLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Stats";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
// counts
|
||||
VoteLogMysqlTable.VoteLogCounts counts = table.getCounts(days);
|
||||
long uniques = table.getUniqueVoters(days);
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BOOK).setName("&aOverview")
|
||||
.addLoreLine("&7Total Votes: &f" + counts.total).addLoreLine("&7Immediate: &f" + counts.immediate)
|
||||
.addLoreLine("&7Cached: &f" + counts.cached).addLoreLine("&7Unique Voters: &f" + uniques)
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
// top services header
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.MAP).setName("&aTop Services")
|
||||
.addLoreLine("&7Top " + topServicesLimit + " services/sites:")
|
||||
.addLoreLine("&8(Click does nothing)")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
int shownServices = 0;
|
||||
for (VoteLogMysqlTable.ServiceCount sc : table.getTopServices(days, topServicesLimit)) {
|
||||
shownServices++;
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER)
|
||||
.setName("&a#" + shownServices + " &f" + AdminVoteLogHelpers.safe(sc.service))
|
||||
.addLoreLine("&7Votes: &f" + sc.votes)
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op (could open AdminVoteLogService in future)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (shownServices == 0) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo service data")
|
||||
.addLoreLine("&7No services found in the log.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// top servers header
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&aTop Servers")
|
||||
.addLoreLine("&7Top " + topServersLimit + " servers:").addLoreLine("&8(Click does nothing)")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
int shownServers = 0;
|
||||
for (VoteLogMysqlTable.ServerCount sc : table.getTopServers(days, topServersLimit)) {
|
||||
shownServers++;
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER)
|
||||
.setName("&a#" + shownServers + " &f" + AdminVoteLogHelpers.safe(sc.server))
|
||||
.addLoreLine("&7Votes: &f" + sc.votes)
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op (could open AdminVoteLogServer in future)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (shownServers == 0) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo server data")
|
||||
.addLoreLine("&7No servers found in the log.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-257
@@ -1,257 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog entries for a given voteId (paged).
|
||||
*
|
||||
* vote_id is NOT unique; this shows ALL rows for the correlation id.
|
||||
*/
|
||||
public class AdminVoteLogVoteId extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
private final int page;
|
||||
|
||||
private final String voteId;
|
||||
private final int days;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogVoteId.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param voteId the vote ID to filter
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogVoteId(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, String voteId,
|
||||
int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.voteId = voteId;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogVoteId with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param voteId the vote ID to filter
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogVoteId(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, String voteId, int days, int page) {
|
||||
this(plugin, sender, table, voteId, days, page);
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - VoteId";
|
||||
if (voteId != null && !voteId.isEmpty()) {
|
||||
title += " &7(" + shortId(voteId) + ")";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (voteId == null || voteId.isEmpty()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo voteId provided")
|
||||
.addLoreLine("&7Missing voteId.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
|
||||
// vote_id is not unique -> show ALL rows for it (paged)
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows = table.getByVoteIdAll(voteId, days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
VoteLogMysqlTable.VoteLogEvent event = entry.event != null ? VoteLogMysqlTable.VoteLogEvent.valueOf(entry.event)
|
||||
: null;
|
||||
|
||||
Material mat = AdminVoteLogHelpers.getMaterialForEvent(event, entry.status);
|
||||
|
||||
String eventColor = AdminVoteLogHelpers.getEventColor(event);
|
||||
|
||||
String timeStr = formatTime(entry.voteTime);
|
||||
String uuidShort = shortId(entry.playerUuid);
|
||||
String voteShort = shortId(entry.voteId);
|
||||
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName(eventColor + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
// Only add lore lines when the value is actually set / meaningful
|
||||
// (prevents blank/0/default noise)
|
||||
if (notEmpty(entry.playerName) || notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
|
||||
if (notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + safe(entry.service));
|
||||
}
|
||||
|
||||
if (notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + safe(entry.context));
|
||||
}
|
||||
|
||||
if (notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + safe(entry.status));
|
||||
}
|
||||
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
|
||||
if (notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// read-only
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private String formatTime(long millis) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date(millis));
|
||||
} catch (Exception e) {
|
||||
return String.valueOf(millis);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean notEmpty(String s) {
|
||||
return s != null && !s.trim().isEmpty();
|
||||
}
|
||||
|
||||
private String shortId(String s) {
|
||||
if (s == null || s.isEmpty()) {
|
||||
return "unknown";
|
||||
}
|
||||
return s.length() > 8 ? s.substring(0, 8) : s;
|
||||
}
|
||||
|
||||
private String safe(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.voteshop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.simpleapi.valuerequest.StringListener;
|
||||
import com.bencodez.simpleapi.valuerequest.ValueRequest;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote shop GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteShop extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteShop.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteShop(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit VoteShop");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DIAMOND).setName("&cEdit existing item")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteShopItems(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd voteshop item")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ValueRequest(plugin, plugin.getDialogService(), null).requestString(player, "", null, true,
|
||||
"Enter item name", new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
plugin.getShopFile().createShop(value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&cRemove item")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteShopItemRemove(plugin, clickEvent.getPlayer()).open();
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-179
@@ -1,179 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.voteshop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote shop item GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
|
||||
private String identifier;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteShopItem.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param identifier the item identifier
|
||||
*/
|
||||
public AdminVoteVoteShopItem(VotingPluginMain plugin, CommandSender player, String identifier) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Edit VoteShop Item: " + identifier);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
// to add
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Identifier_Name",
|
||||
plugin.getShopFile().getShopIdentifierIdentifierName(identifier)) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.OAK_DOOR, 1),
|
||||
new EditGUIValueString("Permission", plugin.getShopFile().getVoteShopPermission(identifier)) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1),
|
||||
new EditGUIValueNumber("Cost", plugin.getShopFile().getShopIdentifierCost(identifier)) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
setPathData(getKey(), num.intValue());
|
||||
}
|
||||
}));
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.BARRIER, 1),
|
||||
new EditGUIValueNumber("Limit", plugin.getShopFile().getShopIdentifierLimit(identifier)) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
setPathData(getKey(), num.intValue());
|
||||
}
|
||||
}));
|
||||
|
||||
// display item
|
||||
ConfigurationSection displayItemData = plugin.getShopFile().getShopIdentifierSection(identifier);
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(displayItemData.getString("Material")).setAmount(1),
|
||||
new EditGUIValueString("Material", displayItemData.getString("Material")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueString("Name", displayItemData.getString("Name")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.BOOK, 1),
|
||||
new EditGUIValueList("Lore", displayItemData.getStringList("Lore")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, ArrayList<String> value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(player.getInventory().getItemInMainHand().clone()).addLoreLine("&cClick to add")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ItemBuilder item = new ItemBuilder(clickEvent.getPlayer().getInventory().getItemInMainHand().clone());
|
||||
Map<String, Object> map = item.getConfiguration(false);
|
||||
for (Entry<String, Object> entry : map.entrySet()) {
|
||||
setPathData(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(player.getInventory().getItemInMainHand().clone())
|
||||
.addLoreLine("&cClick to add with exact data")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ItemBuilder item = new ItemBuilder(clickEvent.getPlayer().getInventory().getItemInMainHand().clone());
|
||||
Map<String, Object> map = item.getConfiguration(true);
|
||||
for (Entry<String, Object> entry : map.entrySet()) {
|
||||
setPathData("ItemStack." + entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("Shop." + identifier + ".Rewards"));
|
||||
}
|
||||
});
|
||||
|
||||
// implement item reward?
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getShopFile().getData().set("Shop." + identifier + "." + path, value);
|
||||
plugin.getShopFile().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.voteshop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteConfirmation;
|
||||
|
||||
/**
|
||||
* Admin vote shop item remove GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteShopItemRemove.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteShopItemRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit VoteShop Remove Item");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
|
||||
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier))
|
||||
.addLoreLine("&c&lClick to remove")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteConfirmation(plugin, clickEvent.getPlayer(),
|
||||
"Remove shop item " + identifier + "?") {
|
||||
|
||||
@Override
|
||||
public void onConfirm(Player p) {
|
||||
plugin.getShopFile().removeShop(identifier);
|
||||
p.sendMessage("Removed " + identifier);
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteVoteShop(plugin, p).open();
|
||||
}
|
||||
}.open();
|
||||
|
||||
}
|
||||
}.addData("ident", identifier));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.voteshop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote shop items GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteShopItems extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteShopItems.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteShopItems(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit VoteShop Items");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
|
||||
for (String identifier : plugin.getShopFile().getShopIdentifiers()) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteShopItem(plugin, clickEvent.getPlayer(), (String) getData("ident"))
|
||||
.open(GUIMethod.CHEST);
|
||||
|
||||
}
|
||||
}.addData("ident", identifier));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-165
@@ -1,165 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
/**
|
||||
* GUI handler for vote best/streak display.
|
||||
*/
|
||||
public class VoteBest extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructs a new vote best GUI.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public VoteBest(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add(plugin.getConfigFile().getFormatCommandsVoteBestTitle());
|
||||
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteBestLines());
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("HighestDailyTotal", "" + user.getHighestDailyTotal());
|
||||
placeholders.put("HighestWeeklyTotal", "" + user.getHighestWeeklyTotal());
|
||||
placeholders.put("HighestMonthlyTotal", "" + user.getHighestMonthlyTotal());
|
||||
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
|
||||
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
|
||||
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("HighestDailyTotal", "" + user.getHighestDailyTotal())
|
||||
.placeholder("HighestWeeklyTotal", "" + user.getHighestWeeklyTotal())
|
||||
.placeholder("HighestMonthlyTotal", "" + user.getHighestMonthlyTotal())
|
||||
.title(plugin.getGui().getChestVoteBestName())
|
||||
.body(plugin.getConfigFile().getFormatCommandsVoteBestTitle())
|
||||
.columns(2)
|
||||
.button(plugin.getGui().getChestVoteBestDayBestItem().getName(),
|
||||
"&7Best daily total: &e%HighestDailyTotal%",
|
||||
payload -> {
|
||||
})
|
||||
.button(plugin.getGui().getChestVoteBestWeekBestItem().getName(),
|
||||
"&7Best weekly total: &e%HighestWeeklyTotal%",
|
||||
payload -> {
|
||||
})
|
||||
.button(plugin.getGui().getChestVoteBestMonthBestItem().getName(),
|
||||
"&7Best monthly total: &e%HighestMonthlyTotal%",
|
||||
payload -> {
|
||||
})
|
||||
.button(plugin.getGui().isChestVoteBestBackButton() ? "&eBack" : "",
|
||||
plugin.getGui().isChestVoteBestBackButton() ? "&7Return to previous menu" : "",
|
||||
payload -> {
|
||||
if (plugin.getGui().isChestVoteBestBackButton()) {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
}
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteBestName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestDayBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestWeekBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestMonthBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteBestBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
String guiPath = "VoteBest";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodBest().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
-284
@@ -1,284 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
/**
|
||||
* GUI handler for vote interface.
|
||||
*/
|
||||
public class VoteGUI extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructs a new vote GUI.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public VoteGUI(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
if (this.user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("points", "" + user.getPoints()).placeholder("player", user.getPlayerName())
|
||||
.placeholder("top", plugin.getConfigFile().getVoteTopDefault())
|
||||
.placeholder("sitesavailable", "" + user.getSitesNotVotedOn())
|
||||
.title(plugin.getGui().getChestVoteGUIName()).body("&7Select an option").columns(2);
|
||||
|
||||
for (final String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
ItemBuilder builder = getItemSlot(slot, player);
|
||||
|
||||
String buttonText = builder.getName();
|
||||
String tooltip = "";
|
||||
|
||||
if (builder.getLore() != null && !builder.getLore().isEmpty()) {
|
||||
tooltip = builder.getLore().get(0);
|
||||
}
|
||||
|
||||
dialog.button(buttonText, tooltip, payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
|
||||
|
||||
if (cmd.equalsIgnoreCase("none")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cmd.equals("")) {
|
||||
clicked.performCommand(cmd);
|
||||
} else {
|
||||
plugin.getCommandLoader().processSlotClick(clicked, user, slot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item for a specific GUI slot.
|
||||
*
|
||||
* @param slot the slot name
|
||||
* @param player the player
|
||||
* @return the item builder for the slot
|
||||
*/
|
||||
private ItemBuilder getItemSlot(String slot, Player player) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteGUISlotSection(slot));
|
||||
|
||||
String[] lore = new String[1];
|
||||
lore = ArrayUtils.convert(plugin.getGui().getChestVoteGUISlotLore(slot));
|
||||
|
||||
String str = plugin.getConfigFile().getVoteTopDefault();
|
||||
if (lore.length == 0) {
|
||||
if (MessageAPI.startsWithIgnoreCase(slot, "url")) {
|
||||
lore = new String[] { "&aClick me" };
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "next")) {
|
||||
lore = ArrayUtils.convert(new VoteNext(plugin, player, user).getChat(player));
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "last")) {
|
||||
lore = ArrayUtils.convert(new VoteLast(plugin, player, user).getChat(player));
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "total")) {
|
||||
lore = ArrayUtils.convert(new VoteTotal(plugin, player, user).getChat(player));
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "top")) {
|
||||
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterMonthly(1);
|
||||
} else if (str.equalsIgnoreCase("weekly")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterWeekly(1);
|
||||
} else if (str.equalsIgnoreCase("daily")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterDaily(1);
|
||||
} else {
|
||||
lore = plugin.getTopVoterHandler().topVoterAllTime(1);
|
||||
}
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
String[] today = new VoteToday(plugin, player, user, 1).voteTodayGUI();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
if (today.length > 0) {
|
||||
for (int i = today.length - 1; i < today.length && list.size() < 10 && i >= 0; i--) {
|
||||
list.add(today[i]);
|
||||
}
|
||||
}
|
||||
lore = ArrayUtils.convert(list);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
lore = new String[] { "Click to view help" };
|
||||
}
|
||||
}
|
||||
builder.setLore(ArrayUtils.convert(lore));
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
/*
|
||||
* BookWrapper book = new
|
||||
* BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
*
|
||||
* // url - click to open Layout urlLayout = new Layout(new
|
||||
* ArrayList<String>(Arrays.asList("[Json]")));
|
||||
* urlLayout.replaceTextComponent("[Json]",
|
||||
* BookUtil.TextBuilder.of(book.colorize("Click me")).onClick(BookUtil.
|
||||
* ClickAction.runCommand("/vote url"))
|
||||
* .onHover(BookUtil.HoverAction.showText("Clicking me opens url GUI")).build())
|
||||
* ; book.addLayout(urlLayout); book.addLine();
|
||||
*
|
||||
* // next - click to open for (VoteSite site : plugin.getVoteSites()) { Layout
|
||||
* nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
* nextLayout.replaceTextComponent("[Json]",
|
||||
* BookUtil.TextBuilder.of(site.getDisplayName())
|
||||
* .onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
* .onHover(BookUtil.HoverAction.showText(user.voteCommandNextInfo(site))).build
|
||||
* ()); book.addLayout(nextLayout); } book.addLine();
|
||||
*
|
||||
* // total - click to open
|
||||
*
|
||||
* // top = click to open
|
||||
*
|
||||
* // today - click to open
|
||||
*
|
||||
* // shop - click to open
|
||||
*
|
||||
* book.open(player);
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
// not available
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (this.user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteGUIName());
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (player.getUniqueId().toString().equals(user.getUUID())) {
|
||||
inv.requirePermission("VotingPlugin.Commands.Vote.GUI");
|
||||
} else {
|
||||
inv.requirePermission("VotingPlugin.Commands.Vote.GUI.Other");
|
||||
}
|
||||
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
|
||||
for (final String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
ItemBuilder builder = getItemSlot(slot, player);
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
|
||||
if (cmd.equalsIgnoreCase("none")) {
|
||||
return;
|
||||
}
|
||||
if (!cmd.equals("")) {
|
||||
event.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.performCommand(cmd);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, slot);
|
||||
}
|
||||
String prefix = "";
|
||||
if (event.getButton().getBuilder().isConditional()) {
|
||||
prefix = "Item.";
|
||||
}
|
||||
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
prefix + event.getButton().getLastRewardsPath(player)))) {
|
||||
plugin.getRewardHandler().giveReward(
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
prefix + event.getButton().getLastRewardsPath(player)),
|
||||
new RewardOptions().addPlaceholder("identifier", slot));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
ItemBuilder item = getItemSlot(slot, player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
item.addPlaceholder("points", "" + user.getPoints());
|
||||
item.addPlaceholder("player", user.getPlayerName());
|
||||
item.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
item.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
return item;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
String guiPath = "VoteGUI";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
-162
@@ -1,162 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* GUI handler for vote help display.
|
||||
*/
|
||||
public class VoteHelp extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructs a new vote help GUI.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param player the command sender
|
||||
* @param page the page number
|
||||
*/
|
||||
public VoteHelp(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates help text with hover support.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return list of text components for help
|
||||
*/
|
||||
public ArrayList<TextComponent> helpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
String colorStr = plugin.getConfigFile().getFormatCommandsVoteHelpHoverColor();
|
||||
ChatColor hoverColor = null;
|
||||
try {
|
||||
hoverColor = ChatColor.of(colorStr);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Failed to get color for hover help message");
|
||||
e.printStackTrace();
|
||||
hoverColor = ChatColor.AQUA;
|
||||
}
|
||||
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
|
||||
if (!requirePerms || cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote",
|
||||
plugin.getConfigFile().getFormatCommandsVoteHelpLine(), hoverColor));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
msg.add(unsorted.get(cmd));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates legacy help text without hover support.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return list of text components for help
|
||||
*/
|
||||
public ArrayList<TextComponent> helpTextLegacy(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
|
||||
if (!requirePerms || cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"),
|
||||
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
msg.add(unsorted.get(cmd));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessageJson(voteHelpText(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates vote help text with pagination.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return list of text components for help
|
||||
*/
|
||||
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
ArrayList<TextComponent> text = new ArrayList<>();
|
||||
text = helpText(sender);
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
if ((text.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add(MessageAPI
|
||||
.stringToComp(plugin.getConfigFile().getFormatCommandsVoteHelpTitle() + " " + page + "/" + maxPage));
|
||||
|
||||
for (int i = pagesize * (page - 1); (i < text.size()) && (i < ((page) * pagesize)); i++) {
|
||||
msg.add(text.get(i));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
-186
@@ -1,186 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
/**
|
||||
* GUI handler for displaying last vote information.
|
||||
*/
|
||||
public class VoteLast extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructs a new VoteLast GUI handler.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public VoteLast(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
msg.add(MessageAPI.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(), "%player%",
|
||||
playerName));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
msg.add(user.voteCommandLastLine(voteSite));
|
||||
}
|
||||
}
|
||||
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName()).title(plugin.getGui().getChestVoteLastName())
|
||||
.body(plugin.getConfigFile().getFormatCommandsVoteLastTitle()).columns(2);
|
||||
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (site.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dialog.placeholder("sitename", site.getDisplayName()).button(site.getDisplayName(),
|
||||
user.voteCommandLastLine(site), payload -> {
|
||||
|
||||
if (plugin.getGui().isChestVoteLastClickableLinks()) {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
|
||||
if (clicked != null) {
|
||||
VotingPluginUser clickedUser = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(clicked);
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("voteurl", site.getVoteURL());
|
||||
placeholders.put("sitename", site.getDisplayName());
|
||||
placeholders.put("player", clicked.getName());
|
||||
|
||||
clickedUser.sendMessage(plugin.getGui().getChestVoteURLURLText(), placeholders);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteLastBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteLastName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (plugin.getGui().isChestVoteLastClickableLinks()) {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(player);
|
||||
user.sendMessage(
|
||||
PlaceholderUtils
|
||||
.replacePlaceHolder(
|
||||
PlaceholderUtils.replacePlaceHolder(
|
||||
PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui()
|
||||
.getChestVoteURLURLText(),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"sitename", site.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player p) {
|
||||
return site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteLast";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteLastBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodLast().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
-197
@@ -1,197 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
/**
|
||||
* GUI handler for displaying next vote information.
|
||||
*/
|
||||
public class VoteNext extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructs a new VoteNext GUI handler.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public VoteNext(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
msg.add(MessageAPI.colorize(MessageAPI
|
||||
.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteNextTitle(), "%player%", playerName)));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
|
||||
|
||||
msgLine = MessageAPI.replaceIgnoreCase(msgLine, "%info%", user.voteCommandNextInfo(voteSite));
|
||||
|
||||
msgLine = MessageAPI.replaceIgnoreCase(msgLine, "%SiteName%", voteSite.getDisplayName());
|
||||
msg.add(MessageAPI.colorize(msgLine));
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName()).title(plugin.getGui().getChestVoteNextName())
|
||||
.body(plugin.getConfigFile().getFormatCommandsVoteNextTitle()).columns(2);
|
||||
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (site.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
|
||||
|
||||
if (siteNameDisplay.isEmpty()) {
|
||||
siteNameDisplay = site.getDisplayName();
|
||||
}
|
||||
|
||||
dialog.placeholder("sitename", site.getDisplayName()).placeholder("SiteName", site.getDisplayName())
|
||||
.placeholder("info", user.voteCommandNextInfo(site))
|
||||
.button(siteNameDisplay, user.voteCommandNextInfo(site), payload -> {
|
||||
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
|
||||
if (clicked != null) {
|
||||
clicked.sendMessage(user.voteCommandNextInfo(site));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteNextBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
// add colors/config options
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
|
||||
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
.onHover(BookUtil.HoverAction.showText(user.voteCommandNextInfo(site))).build());
|
||||
book.addLayout(nextLayout);
|
||||
}
|
||||
}
|
||||
book.addLine();
|
||||
|
||||
book.open(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteNextName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
|
||||
if (siteNameDisplay.isEmpty()) {
|
||||
siteNameDisplay = site.getDisplayName();
|
||||
}
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(plugin,
|
||||
site.getItem().setName(siteNameDisplay)
|
||||
.setLore(PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteNextLine(), "time",
|
||||
user.voteCommandNextInfo(site)))
|
||||
.setAmountNone(1),
|
||||
1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1)
|
||||
.addPlaceholder("player", user.getPlayerName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteNext";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteNextBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodNext().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
-260
@@ -1,260 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.voteshop.VoteShopManager;
|
||||
import com.bencodez.votingplugin.voteshop.service.VoteShopPurchaseResult;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategory;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategoryButton;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopDefinition;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopEntry;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopExtraItem;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopItem;
|
||||
|
||||
/**
|
||||
* Main vote shop GUI.
|
||||
*/
|
||||
public class VoteShop extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Creates the GUI.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
* @param player the sender
|
||||
* @param user the user
|
||||
*/
|
||||
public VoteShop(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
VoteShopManager manager = plugin.getVoteShopManager();
|
||||
VoteShopDefinition definition = manager.getDefinition();
|
||||
|
||||
if (!definition.isEnabled()) {
|
||||
player.sendMessage(MessageAPI.colorize(definition.getDisabledMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser currentUser = getUser(player);
|
||||
BInventory inv = new BInventory(definition.getTitle());
|
||||
inv.addPlaceholder("points", String.valueOf(currentUser.getPoints()));
|
||||
inv.addPlaceholder("sitesavailable", String.valueOf(currentUser.getSitesNotVotedOn()));
|
||||
inv.dontClose();
|
||||
|
||||
for (VoteShopEntry entry : definition.getMainEntries().values()) {
|
||||
if (entry instanceof VoteShopItem) {
|
||||
addItemButton(inv, player, currentUser, (VoteShopItem) entry, null);
|
||||
} else if (entry instanceof VoteShopCategoryButton) {
|
||||
addCategoryButton(inv, player, currentUser, (VoteShopCategoryButton) entry);
|
||||
}
|
||||
}
|
||||
|
||||
for (VoteShopExtraItem extraItem : definition.getExtraItems().values()) {
|
||||
addExtraItemButton(inv, player, currentUser, extraItem);
|
||||
}
|
||||
|
||||
if (definition.isBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(currentUser));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param item the item
|
||||
* @param category the category, null for main shop
|
||||
*/
|
||||
protected void addItemButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopItem item, final VoteShopCategory category) {
|
||||
VoteShopPurchaseResult validation = plugin.getVoteShopManager().getPurchaseService().validatePurchase(player,
|
||||
currentUser, item);
|
||||
boolean hasPermission = plugin.getVoteShopManager().getPurchaseService().hasPermission(player,
|
||||
item.getPermission());
|
||||
|
||||
if ((!hasPermission && item.isHideOnNoPermission()) || (validation == VoteShopPurchaseResult.LIMIT_REACHED
|
||||
&& plugin.getVoteShopManager().getDefinition().isHideLimitedReached())) {
|
||||
return;
|
||||
}
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(item.getDisplaySection())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
VotingPluginUser clickedUser = getUser(event.getPlayer());
|
||||
if (plugin.getConfigFile().isExtraVoteShopCheck()) {
|
||||
clickedUser.cache();
|
||||
}
|
||||
|
||||
if (item.isNotBuyable()) {
|
||||
clickedUser.sendMessage(plugin.getConfigFile().getFormatShopNotPurchasable());
|
||||
return;
|
||||
}
|
||||
|
||||
VoteShopPurchaseResult clickValidation = plugin.getVoteShopManager().getPurchaseService()
|
||||
.validatePurchase(event.getPlayer(), clickedUser, item);
|
||||
if (clickValidation != VoteShopPurchaseResult.SUCCESS) {
|
||||
plugin.getVoteShopManager().getPurchaseService().sendFailureMessage(event.getPlayer(), clickedUser,
|
||||
item, clickValidation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.isRequireConfirmation()) {
|
||||
if (plugin.getShopFile().isShopConfirmPurchaseUseDialog()) {
|
||||
new VoteShopConfirm(plugin, event.getPlayer(), clickedUser, item, category)
|
||||
.open(GUIMethod.DIALOG);
|
||||
return;
|
||||
} else {
|
||||
new VoteShopConfirm(plugin, event.getPlayer(), clickedUser, item, category)
|
||||
.open(GUIMethod.CHEST);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
handlePurchase(event.getPlayer(), clickedUser, item, category);
|
||||
}
|
||||
}.addData("identifier", item.getIdentifier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a category button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param button the button
|
||||
*/
|
||||
protected void addCategoryButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopCategoryButton button) {
|
||||
boolean hasPermission = plugin.getVoteShopManager().getPurchaseService().hasPermission(player,
|
||||
button.getPermission());
|
||||
if (!hasPermission && button.isHideOnNoPermission()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final VoteShopCategory category = plugin.getVoteShopManager().getCategory(button.getCategoryId());
|
||||
if (category == null) {
|
||||
plugin.extraDebug(
|
||||
"VoteShop: missing category '" + button.getCategoryId() + "' for entry " + button.getIdentifier());
|
||||
return;
|
||||
}
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(button.getDisplaySection())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
new VoteShopCategoryMenu(plugin, event.getPlayer(), currentUser, category).open(GUIMethod.CHEST);
|
||||
}
|
||||
}.addData("identifier", button.getIdentifier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an extra item button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param extraItem the extra item
|
||||
*/
|
||||
protected void addExtraItemButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopExtraItem extraItem) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(extraItem.getDisplaySection())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, currentUser, extraItem.getIdentifier());
|
||||
new RewardBuilder(plugin.getShopFile().getData(),
|
||||
"ExtraItems." + extraItem.getIdentifier() + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a completed purchase.
|
||||
*
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param item the item
|
||||
* @param category the category or null
|
||||
*/
|
||||
protected void handlePurchase(Player player, VotingPluginUser currentUser, VoteShopItem item,
|
||||
VoteShopCategory category) {
|
||||
VoteShopPurchaseResult result = plugin.getVoteShopManager().purchase(player, currentUser, item);
|
||||
if (result != VoteShopPurchaseResult.SUCCESS) {
|
||||
plugin.getVoteShopManager().getPurchaseService().sendFailureMessage(player, currentUser, item, result);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCommandLoader().processSlotClick(player, currentUser, item.getIdentifier());
|
||||
if (plugin.getVoteShopManager().getDefinition().isReopenGuiOnPurchase()) {
|
||||
if (category != null) {
|
||||
new VoteShopCategoryMenu(plugin, player, currentUser, category).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
plugin.getCommandLoader().processSlotClick(player, currentUser, "shop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current user.
|
||||
*
|
||||
* @param player the player
|
||||
* @return the user
|
||||
*/
|
||||
protected VotingPluginUser getUser(Player player) {
|
||||
if (user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
return plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-167
@@ -1,167 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategory;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategoryButton;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopEntry;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopItem;
|
||||
|
||||
/**
|
||||
* Vote shop category GUI.
|
||||
*/
|
||||
public class VoteShopCategoryMenu extends GUIHandler {
|
||||
|
||||
private VoteShopCategory category;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Creates the GUI.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
* @param player the sender
|
||||
* @param user the user
|
||||
* @param category the category
|
||||
*/
|
||||
public VoteShopCategoryMenu(VotingPluginMain plugin, CommandSender player, VotingPluginUser user,
|
||||
VoteShopCategory category) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (!plugin.getVoteShopManager().getDefinition().isEnabled()) {
|
||||
player.sendMessage(MessageAPI.colorize(plugin.getVoteShopManager().getDefinition().getDisabledMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser currentUser = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
BInventory inv = new BInventory(category.getName());
|
||||
inv.addPlaceholder("points", String.valueOf(currentUser.getPoints()));
|
||||
inv.addPlaceholder("sitesavailable", String.valueOf(currentUser.getSitesNotVotedOn()));
|
||||
inv.dontClose();
|
||||
|
||||
for (VoteShopEntry entry : category.getEntries().values()) {
|
||||
if (entry instanceof VoteShopItem) {
|
||||
addItemButton(inv, player, currentUser, (VoteShopItem) entry);
|
||||
} else if (entry instanceof VoteShopCategoryButton) {
|
||||
addCategoryButton(inv, player, currentUser, (VoteShopCategoryButton) entry);
|
||||
}
|
||||
}
|
||||
|
||||
if (category.isBackButton()) {
|
||||
addBackButton(inv, player, currentUser, category.getId());
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
private void addBackButton(BInventory inv, Player player, VotingPluginUser user, String category) {
|
||||
|
||||
if (!plugin.getShopFile().isCategoryBackButtonEnabled(category)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection section = plugin.getShopFile().getCategoryBackButtonItem(category);
|
||||
|
||||
if (section == null) {
|
||||
section = plugin.getShopFile().getDefaultBackButtonItem();
|
||||
}
|
||||
|
||||
ItemBuilder builder;
|
||||
|
||||
if (section != null) {
|
||||
builder = new ItemBuilder(section);
|
||||
} else {
|
||||
builder = new ItemBuilder(Material.ARROW);
|
||||
builder.setName("&cBack");
|
||||
}
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
new VoteShop(plugin, player, user).open();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param item the item
|
||||
*/
|
||||
protected void addItemButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopItem item) {
|
||||
new VoteShop(plugin, player, currentUser).addItemButton(inv, player, currentUser, item, category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a category button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param button the button
|
||||
*/
|
||||
protected void addCategoryButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopCategoryButton button) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(button.getDisplaySection())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
VoteShopCategory target = plugin.getVoteShopManager().getCategory(button.getCategoryId());
|
||||
if (target != null) {
|
||||
new VoteShopCategoryMenu(plugin, event.getPlayer(), currentUser, target).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-158
@@ -1,158 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.simpleapi.player.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.voteshop.service.VoteShopPurchaseResult;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategory;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopItem;
|
||||
|
||||
/**
|
||||
* Confirmation GUI for vote shop purchases.
|
||||
*/
|
||||
public class VoteShopConfirm extends GUIHandler {
|
||||
|
||||
private VoteShopCategory category;
|
||||
|
||||
private VoteShopItem item;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Creates the GUI.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
* @param player the sender
|
||||
* @param user the user
|
||||
* @param item the item
|
||||
* @param category the category or null
|
||||
*/
|
||||
public VoteShopConfirm(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, VoteShopItem item,
|
||||
VoteShopCategory category) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.item = item;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(final Player player) {
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "ident", item.getIdentifier());
|
||||
BInventory inv = new BInventory(plugin.getShopFile().getShopConfirmPurchaseTitle());
|
||||
inv.dontClose();
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseYesItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.cache();
|
||||
VoteShopPurchaseResult result = plugin.getVoteShopManager().purchase(player, user, item);
|
||||
if (result != VoteShopPurchaseResult.SUCCESS) {
|
||||
plugin.getVoteShopManager().getPurchaseService().sendFailureMessage(player, user, item, result);
|
||||
returnToPrevious(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCommandLoader().processSlotClick(player, user, item.getIdentifier());
|
||||
if (item.isCloseGUI()) {
|
||||
event.closeInventory();
|
||||
} else {
|
||||
returnToPrevious(event.getPlayer());
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseNoItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (item.isCloseGUI()) {
|
||||
event.closeInventory();
|
||||
} else {
|
||||
returnToPrevious(event.getPlayer());
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "ident", item.getIdentifier());
|
||||
|
||||
plugin.getDialogService().confirmation(player).placeholder("player", user.getPlayerName())
|
||||
.placeholder("identifier", item.getIdentifier())
|
||||
.title(plugin.getShopFile().getShopConfirmPurchaseTitle())
|
||||
.body("&7Confirm purchase of &e%identifier%&7?")
|
||||
.yesText(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseYesItem()).getName())
|
||||
.noText(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseNoItem()).getName())
|
||||
.onYes(payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.cache();
|
||||
VoteShopPurchaseResult result = plugin.getVoteShopManager().purchase(clicked, user, item);
|
||||
if (result != VoteShopPurchaseResult.SUCCESS) {
|
||||
plugin.getVoteShopManager().getPurchaseService().sendFailureMessage(clicked, user, item,
|
||||
result);
|
||||
returnToPrevious(clicked);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCommandLoader().processSlotClick(clicked, user, item.getIdentifier());
|
||||
if (!item.isCloseGUI()) {
|
||||
returnToPrevious(clicked);
|
||||
}
|
||||
}).onNo(payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
returnToPrevious(clicked);
|
||||
}
|
||||
}).open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns to the previous GUI.
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
protected void returnToPrevious(Player player) {
|
||||
if (category != null) {
|
||||
new VoteShopCategoryMenu(plugin, player, user, category).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
-203
@@ -1,203 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteStreak extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteStreak(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("DailyStreak", "" + user.getDayVoteStreak())
|
||||
.placeholder("WeeklyStreak", "" + user.getWeekVoteStreak())
|
||||
.placeholder("MonthlyStreak", "" + user.getMonthVoteStreak())
|
||||
.placeholder("BestDailyStreak", "" + user.getBestDayVoteStreak())
|
||||
.placeholder("BestWeeklyStreak", "" + user.getBestWeekVoteStreak())
|
||||
.placeholder("BestMonthlyStreak", "" + user.getBestMonthVoteStreak())
|
||||
.title(plugin.getGui().getChestVoteStreakName())
|
||||
.body(plugin.getConfigFile().getFormatCommandsVoteStreakTitle())
|
||||
.columns(2);
|
||||
|
||||
dialog.button(plugin.getGui().getChestVoteStreakCurrentDayStreakItem().getName(),
|
||||
"&7Current daily streak: &e%DailyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakCurrentWeekStreakItem().getName(),
|
||||
"&7Current weekly streak: &e%WeeklyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakCurrentMonthStreakItem().getName(),
|
||||
"&7Current monthly streak: &e%MonthlyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakHighestDayStreakItem().getName(),
|
||||
"&7Best daily streak: &e%BestDailyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakHighestWeekStreakItem().getName(),
|
||||
"&7Best weekly streak: &e%BestWeeklyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakHighestMonthStreakItem().getName(),
|
||||
"&7Best monthly streak: &e%BestMonthlyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteStreakBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add(plugin.getConfigFile().getFormatCommandsVoteStreakTitle());
|
||||
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteStreakLines());
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("DailyStreak", "" + user.getDayVoteStreak());
|
||||
placeholders.put("WeeklyStreak", "" + user.getWeekVoteStreak());
|
||||
placeholders.put("MonthlyStreak", "" + user.getMonthVoteStreak());
|
||||
|
||||
placeholders.put("BestDailyStreak", "" + user.getBestDayVoteStreak());
|
||||
placeholders.put("BestWeeklyStreak", "" + user.getBestWeekVoteStreak());
|
||||
placeholders.put("BestMonthlyStreak", "" + user.getBestMonthVoteStreak());
|
||||
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
|
||||
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
|
||||
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteStreakName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
String guiPath = "VoteStreak";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteStreakBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodStreak().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
-247
@@ -1,247 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
public class VoteToday extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteToday(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName()).placeholder("page", "" + page)
|
||||
.title(plugin.getGui().getChestVoteTodayName())
|
||||
.body(String.join("\n", plugin.getConfigFile().getFormatCommandsVoteTodayTitle())).columns(2);
|
||||
|
||||
for (TopVoterPlayer topPlayer : plugin.getVoteToday().keySet()) {
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(topPlayer).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(topPlayer).get(voteSite).format(formatter);
|
||||
|
||||
final UUID uuid = topPlayer.getUuid();
|
||||
|
||||
dialog.placeholder("player", topPlayer.getPlayerName()).placeholder("votesite", voteSite.getKey())
|
||||
.placeholder("sitename", voteSite.getDisplayName())
|
||||
.placeholder("SiteName", voteSite.getDisplayName())
|
||||
.placeholder("VoteSite", voteSite.getDisplayName()).placeholder("time", timeString)
|
||||
.placeholder("Time", timeString).button("&e" + topPlayer.getPlayerName(),
|
||||
plugin.getConfigFile().getFormatCommandsVoteTodayLine(), payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
VotingPluginUser clickedUser = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(uuid);
|
||||
new VoteGUI(plugin, clicked, clickedUser).open(
|
||||
GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTodayBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
String[] voteToday = voteToday();
|
||||
|
||||
int maxPage = voteToday.length / pagesize;
|
||||
if ((voteToday.length % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("page", "" + page);
|
||||
placeholders.put("maxpage", "" + maxPage);
|
||||
|
||||
for (String m : plugin.getConfigFile().getFormatCommandsVoteTodayTitle()) {
|
||||
msg.add(m);
|
||||
}
|
||||
|
||||
page--;
|
||||
|
||||
for (int i = pagesize * page; (i < voteToday.length) && (i < ((page + 1) * pagesize)); i++) {
|
||||
msg.add(voteToday[i]);
|
||||
}
|
||||
|
||||
return ArrayUtils.colorize(PlaceholderUtils.replacePlaceHolder(msg, placeholders));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTodayName());
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", voteSite.getKey());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("SiteName", voteSite.getDisplayName());
|
||||
placeholders.put("VoteSite", voteSite.getDisplayName());
|
||||
placeholders.put("time", timeString);
|
||||
placeholders.put("Time", timeString);
|
||||
|
||||
ItemBuilder item;
|
||||
if (plugin.getGui().isChestVoteTodayUseSkull()) {
|
||||
item = new ItemBuilder(user.getPlayerHead());
|
||||
} else {
|
||||
item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
|
||||
}
|
||||
|
||||
String title = PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
|
||||
placeholders);
|
||||
String lore = PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayLine(),
|
||||
placeholders);
|
||||
|
||||
item.setName(title);
|
||||
item.setLore(lore);
|
||||
|
||||
final UUID uuid = user.getUuid();
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
new VoteGUI(plugin, player, user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteToday";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTodayBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodToday().toUpperCase()));
|
||||
}
|
||||
|
||||
public String[] voteToday() {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", voteSite.getKey());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
// msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
|
||||
// timeString);
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
return ArrayUtils.convert(msg);
|
||||
}
|
||||
|
||||
public String[] voteTodayGUI() {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
LocalDateTime mostRecent = null;
|
||||
VoteSite mostRecentSite = null;
|
||||
for (Entry<VoteSite, LocalDateTime> entry : plugin.getVoteToday().get(user).entrySet()) {
|
||||
if (mostRecent == null || entry.getValue().isAfter(mostRecent)) {
|
||||
mostRecent = entry.getValue();
|
||||
mostRecentSite = entry.getKey();
|
||||
}
|
||||
}
|
||||
if (mostRecent != null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = mostRecent.format(formatter);
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", mostRecentSite.getKey());
|
||||
placeholders.put("sitename", mostRecentSite.getDisplayName());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
return ArrayUtils.convert(msg);
|
||||
}
|
||||
|
||||
}
|
||||
-285
@@ -1,285 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private TopVoter top;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTopVoter(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, TopVoter top, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.top = top;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
|
||||
String topVoter = top.getName();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topVotes = (LinkedHashMap<TopVoterPlayer, Integer>) plugin.getTopVoter(top)
|
||||
.clone();
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("topvoter", topVoter)
|
||||
.title(plugin.getGui().getChestVoteTopName())
|
||||
.body("&7Viewing &e%topvoter% &7top voters")
|
||||
.columns(2);
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : topVotes.entrySet()) {
|
||||
final TopVoterPlayer topPlayer = entry.getKey();
|
||||
final int votes = entry.getValue();
|
||||
final int position = pos;
|
||||
|
||||
dialog.placeholder("position", "" + position)
|
||||
.placeholder("player", topPlayer.getPlayerName())
|
||||
.placeholder("votes", "" + votes)
|
||||
.button(plugin.getGui().getChestVoteTopItemName(),
|
||||
plugin.getGui().getChestVoteTopItemLore(),
|
||||
payload -> {
|
||||
if (plugin.getGui().isChestVoteTopOpenMainGUIOnClick()) {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, topPlayer.getUser()).open(
|
||||
GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}
|
||||
});
|
||||
pos++;
|
||||
}
|
||||
|
||||
dialog.button("&eNext", "&7View next top voter board", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteTopVoter(plugin, clicked, user, top.next(), 0).open(GUIMethod.DIALOG);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.button("&ePrevious", "&7View previous top voter board", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteTopVoter(plugin, clicked, user, top.prev(), 0).open(GUIMethod.DIALOG);
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterAllTime(page));
|
||||
case Daily:
|
||||
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterDaily(page));
|
||||
case Monthly:
|
||||
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterMonthly(page));
|
||||
case Weekly:
|
||||
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterWeekly(page));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
|
||||
String topVoter = top.getName();
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topVotes = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(top).clone();
|
||||
users = topVotes.entrySet();
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
playerSlots.addAll(customizationPlayerSlots);
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", topVoter);
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
|
||||
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
BInventoryButton button = new BInventoryButton(playerItem
|
||||
.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (plugin.getGui().isChestVoteTopOpenMainGUIOnClick()) {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey());
|
||||
|
||||
if (customzationEnabled && !playerSlots.isEmpty()) {
|
||||
button.setSlot(playerSlots.remove());
|
||||
}
|
||||
|
||||
inv.setCloseInv(plugin.getGui().isChestVoteTopCloseGUIOnClick());
|
||||
|
||||
inv.addButton(button);
|
||||
pos++;
|
||||
}
|
||||
|
||||
TopVoter newTops = top;
|
||||
ArrayList<String> tops = plugin.getGui().getChestVoteTopSwitchItemTopVoters();
|
||||
if (!tops.isEmpty()) {
|
||||
for (String name : tops) {
|
||||
newTops.getSwitchItems().add(TopVoter.getTopVoter(name));
|
||||
}
|
||||
}
|
||||
|
||||
final TopVoter cur = newTops;
|
||||
if (!customzationEnabled) {
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
if (customzationEnabled) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user)
|
||||
.setSlot(customization.getInt("BackButtonSlot", 0)));
|
||||
} else {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteTop.Customization";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (customization == null || !customzationEnabled || !customization.getBoolean("RemoveBottomBar")) {
|
||||
inv.setPages(true);
|
||||
}
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
-143
@@ -1,143 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTopVoterLastMonth(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = plugin.getLastMonthTopVoter().entrySet();
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("topvoter", "Last Month")
|
||||
.title(plugin.getGui().getChestVoteTopName())
|
||||
.body("&7Viewing &eLast Month &7top voters")
|
||||
.columns(2);
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
final TopVoterPlayer topPlayer = entry.getKey();
|
||||
final int votes = entry.getValue();
|
||||
final int position = pos;
|
||||
|
||||
dialog.placeholder("position", "" + position)
|
||||
.placeholder("player", topPlayer.getPlayerName())
|
||||
.placeholder("votes", "" + votes)
|
||||
.button(plugin.getGui().getChestVoteTopItemName(),
|
||||
plugin.getGui().getChestVoteTopItemLore(),
|
||||
payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, topPlayer.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
});
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
|
||||
users = plugin.getLastMonthTopVoter().entrySet();
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", "Last Month");
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-225
@@ -1,225 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.time.YearMonth;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class VoteTopVoterPreviousMonths extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
private int index = -1;
|
||||
|
||||
public VoteTopVoterPreviousMonths(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int index) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
Set<YearMonth> months = plugin.getPreviousMonthsTopVoters().keySet();
|
||||
List<YearMonth> yearMonthList = months.stream().sorted(Collections.reverseOrder()).collect(Collectors.toList());
|
||||
|
||||
if (index < 0 || yearMonthList.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
|
||||
return;
|
||||
}
|
||||
|
||||
if (yearMonthList.size() <= index) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data for requested index");
|
||||
return;
|
||||
}
|
||||
|
||||
YearMonth yearMonth = yearMonthList.get(index);
|
||||
|
||||
if (!plugin.getPreviousMonthsTopVoters().containsKey(yearMonth)) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = plugin.getPreviousMonthsTopVoters().get(yearMonth).entrySet();
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("topvoter", yearMonth.toString())
|
||||
.title(plugin.getGui().getChestVoteTopName())
|
||||
.body("&7Viewing &e%topvoter% &7top voters")
|
||||
.columns(2);
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
final TopVoterPlayer topPlayer = entry.getKey();
|
||||
final int votes = entry.getValue();
|
||||
final int position = pos;
|
||||
|
||||
dialog.placeholder("position", "" + position)
|
||||
.placeholder("player", topPlayer.getPlayerName())
|
||||
.placeholder("votes", "" + votes)
|
||||
.button(plugin.getGui().getChestVoteTopItemName(),
|
||||
plugin.getGui().getChestVoteTopItemLore(),
|
||||
payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, topPlayer.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
});
|
||||
pos++;
|
||||
}
|
||||
|
||||
dialog.button("&eNext Month", "&7View older month", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteTopVoterPreviousMonths(plugin, clicked, user, index + 1).open(GUIMethod.DIALOG);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.button("&ePrevious Month", "&7View newer month", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteTopVoterPreviousMonths(plugin, clicked, user, index - 1).open(GUIMethod.DIALOG);
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void next(int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
Set<YearMonth> months = plugin.getPreviousMonthsTopVoters().keySet();
|
||||
|
||||
List<YearMonth> yearMonthList = months.stream().sorted(Collections.reverseOrder()).collect(Collectors.toList());
|
||||
YearMonth yearMonth = null;
|
||||
|
||||
if (index < 0) {
|
||||
if (!yearMonthList.isEmpty()) {
|
||||
yearMonth = yearMonthList.get(0);
|
||||
}
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
|
||||
return;
|
||||
}
|
||||
if (yearMonthList.size() <= index) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data for requested index");
|
||||
return;
|
||||
}
|
||||
yearMonth = yearMonthList.get(index);
|
||||
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
if (!plugin.getPreviousMonthsTopVoters().containsKey(yearMonth)) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
|
||||
return;
|
||||
}
|
||||
users = plugin.getPreviousMonthsTopVoters().get(yearMonth).entrySet();
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", yearMonth.toString());
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem())
|
||||
.addPlaceholder("Top", yearMonth.toString())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoterPreviousMonths(plugin, player, user, index + 1).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoterPreviousMonths(plugin, player, user, index - 1).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-152
@@ -1,152 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTotal extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTotal(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("DailyTotal", "" + user.getTotal(TopVoter.Daily))
|
||||
.placeholder("WeeklyTotal", "" + user.getTotal(TopVoter.Weekly))
|
||||
.placeholder("MonthlyTotal", "" + user.getTotal(TopVoter.Monthly))
|
||||
.placeholder("AllTimeTotal", "" + user.getTotal(TopVoter.AllTime))
|
||||
.title(plugin.getGui().getChestVoteTotalName()).body("&7Vote totals for %player%").columns(2);
|
||||
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
|
||||
dialog.placeholder("topvoter", top.getName()).placeholder("Total", "" + user.getTotal(top))
|
||||
.button("%topvoter%", "&7Total: &e%Total%", payload -> {
|
||||
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
|
||||
if (clicked != null) {
|
||||
clicked.sendMessage("&e" + top.getName() + ": &a" + user.getTotal(top));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTotalBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
int daily = user.getTotal(TopVoter.Daily);
|
||||
int weekly = user.getTotal(TopVoter.Weekly);
|
||||
int month = user.getTotal(TopVoter.Monthly);
|
||||
int all = user.getTotal(TopVoter.AllTime);
|
||||
|
||||
for (String s : plugin.getConfigFile().getFormatCommandsVoteTotal()) {
|
||||
String str = MessageAPI.replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
|
||||
str = MessageAPI.replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
|
||||
str = MessageAPI.replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
|
||||
str = MessageAPI.replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
|
||||
str = MessageAPI.replaceIgnoreCase(str, "%player%", user.getPlayerName());
|
||||
msg.add(str);
|
||||
}
|
||||
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// future release?
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTotalName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin,
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()),
|
||||
1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player arg0) {
|
||||
return new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName())
|
||||
.addPlaceholder("player", user.getPlayerName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String guiPath = "VoteTotal";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTotalBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTotal().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
-379
@@ -1,379 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.MessageBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
public class VoteURL extends GUIHandler {
|
||||
|
||||
private boolean json;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteURL(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, boolean json) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.json = json;
|
||||
if (user == null && player instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return getChat(sender, false);
|
||||
}
|
||||
|
||||
public ArrayList<String> getChat(CommandSender sender, boolean bypassCanVote) {
|
||||
ArrayList<String> sites = new ArrayList<>();
|
||||
|
||||
List<String> title = plugin.getConfigFile().getFormatCommandsVoteText();
|
||||
if (title != null) {
|
||||
sites.addAll(title);
|
||||
}
|
||||
if (plugin.getConfigFile().isFormatCommandsVoteAutoInputSites()) {
|
||||
int counter = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
if (voteSite.getPermissionToView().isEmpty()
|
||||
|| sender.hasPermission(voteSite.getPermissionToView())) {
|
||||
if (!plugin.getConfigFile().isFormatCommandsVoteOnlyShowSitesToVote()
|
||||
|| user.canVoteSite(voteSite) || bypassCanVote) {
|
||||
counter++;
|
||||
String voteURL = voteSite.getVoteURL(json);
|
||||
MessageBuilder message = new MessageBuilder(
|
||||
plugin.getConfigFile().getFormatCommandsVoteURLS());
|
||||
message.replacePlaceholder("num", Integer.toString(counter))
|
||||
.replacePlaceholder("url", voteURL)
|
||||
.replacePlaceholder("SiteName", voteSite.getDisplayName());
|
||||
if (user != null && user.getPlayerName() != null) {
|
||||
message.replacePlaceholder("player", "" + user.getPlayerName())
|
||||
.replacePlaceholder("Next", "" + user.voteCommandNextInfo(voteSite));
|
||||
}
|
||||
|
||||
sites.add(message.colorize().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (user != null) {
|
||||
HashMap<String, String> phs = new HashMap<>();
|
||||
phs.put("DailyTotal", "" + user.getTotal(TopVoter.Daily));
|
||||
phs.put("WeekTotal", "" + user.getTotal(TopVoter.Weekly));
|
||||
phs.put("MonthTotal", "" + user.getTotal(TopVoter.Monthly));
|
||||
phs.put("Total", "" + user.getTotal(TopVoter.AllTime));
|
||||
|
||||
sites = PlaceholderUtils.replacePlaceHolder(sites, phs);
|
||||
}
|
||||
|
||||
return ArrayUtils.colorize(sites);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
VotingPluginUser currentUser = this.user;
|
||||
|
||||
if (currentUser == null) {
|
||||
currentUser = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
|
||||
String body = "&7Select a vote site";
|
||||
|
||||
if (plugin.getConfigFile().getFormatCommandsVoteText() != null
|
||||
&& !plugin.getConfigFile().getFormatCommandsVoteText().isEmpty()) {
|
||||
body = String.join("\n", plugin.getConfigFile().getFormatCommandsVoteText());
|
||||
}
|
||||
|
||||
final VotingPluginUser finalUser = currentUser;
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", finalUser.getPlayerName())
|
||||
.placeholder("DailyTotal", "" + finalUser.getTotal(TopVoter.Daily))
|
||||
.placeholder("WeekTotal", "" + finalUser.getTotal(TopVoter.Weekly))
|
||||
.placeholder("MonthTotal", "" + finalUser.getTotal(TopVoter.Monthly))
|
||||
.placeholder("Total", "" + finalUser.getTotal(TopVoter.AllTime))
|
||||
.title(plugin.getGui().getChestVoteURLName()).body(body).columns(2);
|
||||
|
||||
if (plugin.getGui().isChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
boolean canViewAll;
|
||||
if (plugin.getGui().isChestVoteURLAllUrlsButtonrequireAllSitesVoted()) {
|
||||
canViewAll = finalUser.canVoteAny();
|
||||
} else {
|
||||
canViewAll = finalUser.canVoteAll();
|
||||
}
|
||||
|
||||
String allColor = canViewAll ? "&a" : "&c";
|
||||
|
||||
dialog.button(allColor + "All Voting Sites", "&7Show all vote URLs", payload -> {
|
||||
VotingPluginUser payloadUser = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
json = true;
|
||||
payloadUser.sendMessage(getChat(player, false));
|
||||
});
|
||||
}
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (voteSite.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
if (!voteSite.getPermissionToView().isEmpty() && !player.hasPermission(voteSite.getPermissionToView())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean canVote = finalUser.canVoteSite(voteSite);
|
||||
String color = canVote ? "&a" : "&c";
|
||||
|
||||
dialog.placeholder("sitename", voteSite.getDisplayName())
|
||||
.placeholder("SiteName", voteSite.getDisplayName())
|
||||
.placeholder("servicesite", voteSite.getServiceSite())
|
||||
.placeholder("ServiceSite", voteSite.getServiceSite())
|
||||
.placeholder("VoteDelay", "" + voteSite.getVoteDelay())
|
||||
.placeholder("VoteHour", "" + voteSite.getVoteDelayDailyHour())
|
||||
.placeholder("Next", finalUser.voteCommandNextInfo(voteSite))
|
||||
.button(color + voteSite.getDisplayName(),
|
||||
canVote ? "&aClick to view vote link" : "&c" + finalUser.voteCommandNextInfo(voteSite),
|
||||
payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
VotingPluginUser clickedUser = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(clicked);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("voteurl", voteSite.getVoteURL());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("player", clicked.getName());
|
||||
placeholders.put("servicesite", voteSite.getServiceSite());
|
||||
placeholders.put("VoteDelay", "" + voteSite.getVoteDelay());
|
||||
placeholders.put("VoteHour", "" + voteSite.getVoteDelayDailyHour());
|
||||
clickedUser.sendMessage(plugin.getGui().getChestVoteURLURLText(), placeholders);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteURLBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> player.performCommand("vote gui"));
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
private ItemBuilder getItemAll() {
|
||||
ItemBuilder builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLAlreadyVotedAllUrlsButtonItemSection());
|
||||
if (plugin.getGui().isChestVoteURLAllUrlsButtonrequireAllSitesVoted()) {
|
||||
if (user.canVoteAny()) {
|
||||
builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteAllUrlsButtonItemSection());
|
||||
}
|
||||
} else {
|
||||
if (user.canVoteAll()) {
|
||||
builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteAllUrlsButtonItemSection());
|
||||
}
|
||||
}
|
||||
|
||||
if (!builderAll.hasCustomDisplayName()) {
|
||||
builderAll.setName("&4All Voting Sites");
|
||||
}
|
||||
if (!builderAll.hasCustomLore()) {
|
||||
builderAll.setLore("&cClick Me");
|
||||
}
|
||||
int slot = plugin.getGui().getChestVoteURLAllUrlsButtonSlot();
|
||||
if (slot >= 0) {
|
||||
builderAll.setSlot(slot);
|
||||
}
|
||||
return builderAll;
|
||||
}
|
||||
|
||||
private ItemBuilder getItemVoteSite(VoteSite voteSite) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteURLAlreadyVotedItemSection());
|
||||
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteItemSection());
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteNameCanVote());
|
||||
} else {
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteName());
|
||||
builder.addLoreLine(plugin.getGui().getChestVoteURLNextVote());
|
||||
}
|
||||
builder.addPlaceholder("ServiceSite", voteSite.getServiceSite());
|
||||
builder.addPlaceholder("Name", voteSite.getDisplayName());
|
||||
builder.addPlaceholder("VoteDelay", "" + voteSite.getVoteDelay());
|
||||
builder.addPlaceholder("VoteHour", "" + voteSite.getVoteDelayDailyHour());
|
||||
builder.addPlaceholder("Info", user.voteCommandNextInfo(voteSite));
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
if (plugin.getGui().isBookVoteURLBookGUIManual()) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUITopLayout());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
int i = 1;
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
if (site.getPermissionToView().isEmpty() || player.hasPermission(site.getPermissionToView())) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout())
|
||||
.addPlaceholder("sitename", site.getDisplayName()).addPlaceholder("num", "" + i);
|
||||
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
|
||||
ChatColor color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUIAlreadyVotedColor());
|
||||
if (user.canVoteSite(site)) {
|
||||
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
|
||||
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
|
||||
}
|
||||
String url = PlaceholderUtils.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
|
||||
site.getVoteURLJsonStrip(), "player", user.getPlayerName()), "num", "" + i);
|
||||
layout.replaceTextComponent("[UrlText]",
|
||||
BookUtil.TextBuilder.of(text).color(color).onClick(BookUtil.ClickAction.openUrl(url))
|
||||
.onHover(BookUtil.HoverAction.showText(url)).build());
|
||||
book.addLayout(layout);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
book.open(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteURLName());
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
for (final String str : plugin.getGui().getChestVoteURLExtraItems()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteURLExtraItemsItem(str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteURL.ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = getItemAll();
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builderAll, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.closeInventory();
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(event.getPlayer());
|
||||
json = true;
|
||||
if (event.getClick().equals(ClickType.SHIFT_LEFT)
|
||||
|| event.getClick().equals(ClickType.SHIFT_RIGHT)) {
|
||||
user.sendMessage(getChat(player, true));
|
||||
} else {
|
||||
user.sendMessage(getChat(player, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return getItemAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
|
||||
for (final VoteSite voteSite : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
if (voteSite.getPermissionToView().isEmpty() || player.hasPermission(voteSite.getPermissionToView())) {
|
||||
ItemBuilder builder = getItemVoteSite(voteSite);
|
||||
if (startSlot >= 0) {
|
||||
if (inv.isSlotTaken(startSlot)) {
|
||||
boolean found = false;
|
||||
while (!found) {
|
||||
startSlot++;
|
||||
if (!inv.isSlotTaken(startSlot)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.setSlot(startSlot);
|
||||
startSlot++;
|
||||
}
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.closeInventory();
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("voteurl", voteSite.getVoteURL());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("player", player.getName());
|
||||
placeholders.put("servicesite", voteSite.getServiceSite());
|
||||
placeholders.put("VoteDelay", "" + voteSite.getVoteDelay());
|
||||
placeholders.put("VoteHour", "" + voteSite.getVoteDelayDailyHour());
|
||||
user.sendMessage(plugin.getGui().getChestVoteURLURLText(), placeholders);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return getItemVoteSite(voteSite);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteURLBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodURL().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
public class VoteURLVoteSite extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
private String voteSite;
|
||||
|
||||
public VoteURLVoteSite(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, String voteSite) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.voteSite = voteSite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (!plugin.getVoteSiteManager().isVoteSite(voteSite)) {
|
||||
player.sendMessage("Not a valid votesite");
|
||||
return;
|
||||
}
|
||||
VoteSite site = plugin.getVoteSiteManager().getVoteSite(voteSite, true);
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteURLSiteName());
|
||||
inv.addPlaceholder("site", site.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", site);
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Material.BOW).setName("&4URL").addLoreLine("Click to see URL")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VoteSite site = (VoteSite) clickEvent.getMeta("VoteSite");
|
||||
clickEvent.getWhoClicked().sendMessage(site.getVoteURL());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin,
|
||||
new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site)),
|
||||
1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new VoteURL(plugin, clickEvent.getPlayer(), user, true).open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player arg0) {
|
||||
return new ItemBuilder(Material.COMPASS).setName("&4Next Vote")
|
||||
.addLoreLine(user.voteCommandNextInfo(site));
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(Material.CLOCK).setName("&4Last Vote").addLoreLine(user.voteCommandLastLine(site))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new VoteURL(plugin, clickEvent.getPlayer(), user, true).open();
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteURLBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
if (!plugin.getVoteSiteManager().isVoteSite(voteSite)) {
|
||||
player.sendMessage("Not a valid votesite");
|
||||
return;
|
||||
}
|
||||
|
||||
VoteSite site = plugin.getVoteSiteManager().getVoteSite(voteSite, true);
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName()).placeholder("site", site.getDisplayName())
|
||||
.placeholder("sitename", site.getDisplayName()).placeholder("SiteName", site.getDisplayName())
|
||||
.placeholder("servicesite", site.getServiceSite()).placeholder("ServiceSite", site.getServiceSite())
|
||||
.placeholder("VoteDelay", "" + site.getVoteDelay())
|
||||
.placeholder("VoteHour", "" + site.getVoteDelayDailyHour())
|
||||
.placeholder("Next", user.voteCommandNextInfo(site)).placeholder("Last", user.voteCommandLastLine(site))
|
||||
.title(plugin.getGui().getChestVoteURLSiteName()).body("&7Site: &e%site%").columns(2);
|
||||
|
||||
dialog.button("&4URL", "&7Click to see URL", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
clicked.sendMessage(site.getVoteURL());
|
||||
}
|
||||
});
|
||||
|
||||
dialog.button("&4Next Vote", "%Next%", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteURL(plugin, clicked, user, true).open();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.button("&4Last Vote", "%Last%", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteURL(plugin, clicked, user, true).open();
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteURLBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteURL(plugin, clicked, user, true).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.tabcompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.AdvancedCoreTabCompleteHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* The Class AdminVoteTabCompleter.
|
||||
*/
|
||||
public class AdminVoteTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
List<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(),
|
||||
sender, args, args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
return tab;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-141
@@ -1,141 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.tabcompleter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Filters VotingPlugin command aliases from tab completion when aliases are
|
||||
* disabled.
|
||||
* <p>
|
||||
* This listener ONLY hides aliases that are explicitly listed in VotingPlugin's
|
||||
* plugin.yml under the "aliases:" section for the "vote" and "adminvote"
|
||||
* commands.
|
||||
* <p>
|
||||
* It will NOT hide unrelated commands such as "/votechallenge" unless that
|
||||
* exact command name is an alias defined in VotingPlugin's plugin.yml.
|
||||
*/
|
||||
public class AliasCommandFilterListener implements Listener {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Cached lowercase alias names (without '/') that should be hidden when alias
|
||||
* loading is disabled.
|
||||
*/
|
||||
private final Set<String> aliasesToHide;
|
||||
|
||||
/**
|
||||
* Creates a new listener and caches aliases from VotingPlugin's plugin.yml.
|
||||
*
|
||||
* @param plugin VotingPlugin main instance
|
||||
*/
|
||||
public AliasCommandFilterListener(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.aliasesToHide = buildAliasesToHide(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes VotingPlugin aliases from the player's available command list when
|
||||
* alias loading is disabled.
|
||||
*
|
||||
* @param event Bukkit command send event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
// Only hide when aliases feature is disabled
|
||||
if (plugin.getConfigFile().isLoadCommandAliases()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove ONLY exact alias command names (not "vote*" prefixes)
|
||||
event.getCommands().removeIf(this::shouldHideCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a specific command should be hidden.
|
||||
*
|
||||
* @param cmd Command name (without '/'), possibly namespaced (e.g.
|
||||
* "otherplugin:vote")
|
||||
* @return true if the command should be hidden
|
||||
*/
|
||||
private boolean shouldHideCommand(String cmd) {
|
||||
String name = cmd.toLowerCase(Locale.ROOT);
|
||||
|
||||
// Never touch namespaced commands (otherplugin:vote)
|
||||
if (name.contains(":")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Always keep the primary commands visible
|
||||
if (name.equals("vote") || name.equals("adminvote")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Hide only exact aliases defined in VotingPlugin plugin.yml
|
||||
return aliasesToHide.contains(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the set of aliases to hide from VotingPlugin's plugin.yml.
|
||||
* <p>
|
||||
* Bukkit exposes the plugin.yml "commands" section via
|
||||
* {@code plugin.getDescription().getCommands()}. Each command entry is a map
|
||||
* that may contain an "aliases" key.
|
||||
*
|
||||
* @param plugin VotingPlugin main instance
|
||||
* @return a lowercase set of alias command names
|
||||
*/
|
||||
private Set<String> buildAliasesToHide(VotingPluginMain plugin) {
|
||||
Set<String> aliases = new HashSet<>();
|
||||
|
||||
Map<String, Map<String, Object>> commands = plugin.getDescription().getCommands();
|
||||
if (commands == null || commands.isEmpty()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
// Only consider aliases for these main commands
|
||||
addAliasesFor(commands, "vote", aliases);
|
||||
addAliasesFor(commands, "adminvote", aliases);
|
||||
|
||||
return Collections.unmodifiableSet(aliases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds aliases for a given command from the plugin.yml commands map into the
|
||||
* provided set.
|
||||
*
|
||||
* @param commandsMap full commands map from PluginDescriptionFile
|
||||
* @param commandName the primary command to read aliases for (e.g. "vote")
|
||||
* @param out output set to add lowercase alias names into
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void addAliasesFor(Map<String, Map<String, Object>> commandsMap, String commandName,
|
||||
Set<String> out) {
|
||||
Map<String, Object> cmdInfo = commandsMap.get(commandName);
|
||||
if (cmdInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object aliasesObj = cmdInfo.get("aliases");
|
||||
if (aliasesObj instanceof String) {
|
||||
// plugin.yml also allows a single alias as a string
|
||||
out.add(((String) aliasesObj).toLowerCase(Locale.ROOT));
|
||||
} else if (aliasesObj instanceof Collection) {
|
||||
for (Object o : (Collection<Object>) aliasesObj) {
|
||||
if (o != null) {
|
||||
out.add(o.toString().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-114
@@ -1,114 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.tabcompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.command.TabCompleteHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* The Class AliasesTabCompleter.
|
||||
*/
|
||||
public class AliasesTabCompleter implements TabCompleter {
|
||||
|
||||
private boolean adminCommand;
|
||||
|
||||
/** The cmd handle. */
|
||||
public CommandHandler cmdHandle;
|
||||
|
||||
/** The plugin. */
|
||||
VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] argsIn) {
|
||||
ArrayList<String> msgArray = new ArrayList<>();
|
||||
msgArray.add("");
|
||||
for (String arg : argsIn) {
|
||||
msgArray.add(arg);
|
||||
}
|
||||
|
||||
String[] args = ArrayUtils.convert(msgArray);
|
||||
|
||||
ArrayList<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<>();
|
||||
|
||||
if (adminCommand) {
|
||||
cmdHandlers.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
cmdHandlers.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
ConcurrentHashMap<String, ArrayList<String>> tabCompletes = TabCompleteHandler.getInstance()
|
||||
.getTabCompleteOptions();
|
||||
for (CommandHandler cmdHandle : cmdHandlers) {
|
||||
if (cmdHandle.getArgs().length >= argsIn.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
|
||||
// plugin.debug("Found cmd... attempting to get tab
|
||||
// complete");
|
||||
args[0] = arg;
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argsIn.length; i++) {
|
||||
if (args.length >= i) {
|
||||
if (!cmdHandle.argsMatch(args[i], i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
|
||||
cmds.addAll(cmdHandle.getTabCompleteOptions(sender, args, argsIn.length, tabCompletes));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String str : cmds) {
|
||||
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the command handler for this tab completer.
|
||||
*
|
||||
* @param cmd the command handler
|
||||
* @param adminCommand whether this is an admin command
|
||||
* @return this tab completer instance
|
||||
*/
|
||||
public AliasesTabCompleter setCMDHandle(CommandHandler cmd, boolean adminCommand) {
|
||||
cmdHandle = cmd;
|
||||
this.adminCommand = adminCommand;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.tabcompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.AdvancedCoreTabCompleteHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteTabCompleter.
|
||||
*/
|
||||
public class VoteTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
ArrayList<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender,
|
||||
args, args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Configuration file for Bungee/proxy settings.
|
||||
*/
|
||||
public class BungeeSettings extends YMLFile {
|
||||
|
||||
@ConfigDataBoolean(path = "BungeeDebug")
|
||||
@Getter
|
||||
private boolean bungeeDebug = false;
|
||||
|
||||
@ConfigDataString(path = "BungeeMethod")
|
||||
@Getter
|
||||
private String bungeeMethod = "PLUGINMESSAGING";
|
||||
|
||||
@ConfigDataString(path = "Redis.Host")
|
||||
@Getter
|
||||
private String redisHost = "";
|
||||
|
||||
@ConfigDataString(path = "Redis.Username")
|
||||
@Getter
|
||||
private String redisUsername = "";
|
||||
|
||||
@ConfigDataInt(path = "Redis.Db-Index")
|
||||
@Getter
|
||||
private int redisdbindex = 0;
|
||||
|
||||
@ConfigDataString(path = "PluginMessageChannel")
|
||||
@Getter
|
||||
private String pluginMessagingChannel = "vp:vp";
|
||||
|
||||
@ConfigDataBoolean(path = "PluginMessageEncryption")
|
||||
@Getter
|
||||
private boolean pluginMessageEncryption = false;
|
||||
|
||||
@ConfigDataString(path = "Redis.Prefix")
|
||||
@Getter
|
||||
private String redisPrefix = "";
|
||||
|
||||
@ConfigDataString(path = "Redis.Password")
|
||||
@Getter
|
||||
private String redisPassword = "";
|
||||
|
||||
@ConfigDataInt(path = "Redis.Port")
|
||||
@Getter
|
||||
private int redisPort = 6379;
|
||||
|
||||
@ConfigDataString(path = "MQTT.ClientID")
|
||||
@Getter
|
||||
private String mqttClientID = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.BrokerURL")
|
||||
@Getter
|
||||
private String mqttBrokerURL = "tcp://localhost:1883";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Username")
|
||||
@Getter
|
||||
private String mqttUsername = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Password")
|
||||
@Getter
|
||||
private String mqttPassword = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Prefix")
|
||||
@Getter
|
||||
private String mqttPrefix = "";
|
||||
|
||||
@ConfigDataString(path = "BungeeServer.Host")
|
||||
@Getter
|
||||
private String bungeeServerHost = "";
|
||||
|
||||
@ConfigDataInt(path = "BungeeServer.Port")
|
||||
@Getter
|
||||
private int bungeeServerPort = 1297;
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerPoints")
|
||||
@Getter
|
||||
private boolean perServerPoints = false;
|
||||
|
||||
@ConfigDataBoolean(path = "GiveExtraAllSitesRewards")
|
||||
@Getter
|
||||
private boolean giveExtraAllSitesRewards = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerRewards")
|
||||
@Getter
|
||||
private boolean perServerRewards = false;
|
||||
|
||||
@ConfigDataBoolean(path = "RemoveInvalidUsers")
|
||||
@Getter
|
||||
private boolean removeInvalidUsers = false;
|
||||
|
||||
@ConfigDataString(path = "Server")
|
||||
@Getter
|
||||
private String server = "PleaseSet";
|
||||
|
||||
@ConfigDataString(path = "SpigotServer.Host")
|
||||
@Getter
|
||||
private String spigotServerHost = "";
|
||||
|
||||
@ConfigDataInt(path = "SpigotServer.Port")
|
||||
@Getter
|
||||
private int spigotServerPort = 1298;
|
||||
|
||||
@ConfigDataBoolean(path = "TriggerVotifierEvent")
|
||||
@Getter
|
||||
private boolean triggerVotifierEvent = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseBungeecord", secondPath = "UseBungeecoord")
|
||||
@Getter
|
||||
private boolean useBungeecoord = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VotifierBypass")
|
||||
@Getter
|
||||
private boolean votifierBypass = false;
|
||||
|
||||
@ConfigDataBoolean(path = "GlobalData.UseMainMySQL")
|
||||
@Getter
|
||||
private boolean globlalDataUseMainMySQL = true;
|
||||
|
||||
@ConfigDataBoolean(path = "GlobalData.Enabled")
|
||||
@Getter
|
||||
private boolean globlalDataEnabled = false;
|
||||
|
||||
@ConfigDataListString(path = "BungeeVotePartyGlobalCommands")
|
||||
@Getter
|
||||
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructs a new BungeeSettings.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public BungeeSettings(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
setIgnoreCase(plugin.getConfigFile().isCaseInsensitiveYMLFiles());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server name formatted for storage.
|
||||
*
|
||||
* @return the formatted server name
|
||||
*/
|
||||
public String getServerNameStorage() {
|
||||
return getServer().replace("-", "_");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
getPlugin().saveResource("BungeeSettings.yml", true);
|
||||
}
|
||||
}
|
||||
@@ -1,954 +0,0 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataLong;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceholderCacheLevel;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Config.
|
||||
*/
|
||||
public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataBoolean(path = "AddCustomCommands")
|
||||
@Getter
|
||||
private boolean addCustomCommands = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AddTotals")
|
||||
@Getter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AddTotalsOffline")
|
||||
@Getter
|
||||
private boolean addTotalsOffline = true;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadInteralExpansion")
|
||||
@Getter
|
||||
private boolean loadInteralExpansion = true;
|
||||
|
||||
@ConfigDataBoolean(path = "PerSiteCoolDownEvents")
|
||||
@Getter
|
||||
private boolean perSiteCoolDownEvents = false;
|
||||
|
||||
@ConfigDataInt(path = "LimitVotePoints")
|
||||
@Getter
|
||||
private int limitVotePoints = -1;
|
||||
|
||||
/** Whether YAML files should be case insensitive. */
|
||||
@ConfigDataBoolean(path = "CaseInsensitiveYMLFiles")
|
||||
@Getter
|
||||
public boolean caseInsensitiveYMLFiles = false;
|
||||
|
||||
@ConfigDataBoolean(path = "QueueVotesDuringTimeChange")
|
||||
@Getter
|
||||
private boolean queueVotesDuringTimeChange = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AdvancedServiceSiteHandling")
|
||||
@Getter
|
||||
private boolean advancedServiceSiteHandling = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnjoined")
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PreloadSkulls")
|
||||
@Getter
|
||||
private boolean preloadSkulls = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVEnabled = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.AllTime.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterAllTimeEnabled = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.AllTime.NewMessageOnUpdate")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterAllTimeNewMessageOnUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Monthly.NewMessageOnUpdate")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterMonthlyNewMessageOnUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Weekly.NewMessageOnUpdate")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterWeeklyNewMessageOnUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Daily.NewMessageOnUpdate")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterDailyNewMessageOnUpdate = false;
|
||||
|
||||
@ConfigDataLong(path = "DiscordSRV.TopVoter.AllTime.Channel")
|
||||
@Getter
|
||||
private long discordSRVTopVoterAllTimeChannel = 0;
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.AllTime.Title")
|
||||
@Getter
|
||||
private String discordSRVTopVoterAllTimeTitle = "All Time Top Voters";
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.AllTime.RankDisplay")
|
||||
@Getter
|
||||
private String discordSRVTopVoterAllTimeRankDisplay = "%rank%: %player% - %votes% Votes";
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Monthly.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterMonthlyEnabled = false;
|
||||
|
||||
@ConfigDataLong(path = "DiscordSRV.TopVoter.Monthly.Channel")
|
||||
@Getter
|
||||
private long discordSRVTopVoterMonthlyChannel = 0;
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Monthly.Title")
|
||||
@Getter
|
||||
private String discordSRVTopVoterMonthlyTitle = "Top Voters of the Month";
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Monthly.RankDisplay")
|
||||
@Getter
|
||||
private String discordSRVTopVoterMonthlyRankDisplay = "%rank%: %player% - %votes% Votes";
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Weekly.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterWeeklyEnabled = false;
|
||||
|
||||
@ConfigDataLong(path = "DiscordSRV.TopVoter.Weekly.Channel")
|
||||
@Getter
|
||||
private long discordSRVTopVoterWeeklyChannel = 0;
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Weekly.Title")
|
||||
@Getter
|
||||
private String discordSRVTopVoterWeeklyTitle = "Top Voters of the Week";
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Weekly.RankDisplay")
|
||||
@Getter
|
||||
private String discordSRVTopVoterWeeklyRankDisplay = "%rank%: %player% - %votes% Votes";
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Daily.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterDailyEnabled = false;
|
||||
|
||||
@ConfigDataLong(path = "DiscordSRV.TopVoter.Daily.Channel")
|
||||
@Getter
|
||||
private long discordSRVTopVoterDailyChannel = 0;
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Daily.Title")
|
||||
@Getter
|
||||
private String discordSRVTopVoterDailyTitle = "Top Voters of the Day";
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Daily.RankDisplay")
|
||||
@Getter
|
||||
private String discordSRVTopVoterDailyRankDisplay = "%rank%: %player% - %votes% Votes";
|
||||
|
||||
// VoteLogging configuration section - minimal options mirror Config.yml
|
||||
@ConfigDataBoolean(path = "VoteLogging.Enabled")
|
||||
@Getter
|
||||
private boolean voteLoggingEnabled = false;
|
||||
|
||||
@ConfigDataInt(path = "VoteLogging.PurgeDays")
|
||||
@Getter
|
||||
private int voteLoggingPurgeDays = 30;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteLogging.UseMainMySQL")
|
||||
@Getter
|
||||
private boolean voteLoggingUseMainMySQL = true;
|
||||
|
||||
/**
|
||||
* Gets the vote logging configuration section.
|
||||
*
|
||||
* @return the vote logging configuration section
|
||||
*/
|
||||
public ConfigurationSection getVoteLoggingSection() {
|
||||
if (!getData().isConfigurationSection("VoteLogging")) {
|
||||
getData().createSection("VoteLogging");
|
||||
}
|
||||
return getData().getConfigurationSection("VoteLogging");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if DiscordSRV top voter is enabled.
|
||||
*
|
||||
* @param topVoter the top voter type
|
||||
* @return true if enabled
|
||||
*/
|
||||
public boolean isDiscordSRVTopVoterEnabled(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return isDiscordSRVTopVoterAllTimeEnabled();
|
||||
case Monthly:
|
||||
return isDiscordSRVTopVoterMonthlyEnabled();
|
||||
case Weekly:
|
||||
return isDiscordSRVTopVoterWeeklyEnabled();
|
||||
case Daily:
|
||||
return isDiscordSRVTopVoterDailyEnabled();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if DiscordSRV top voter should send a new message on update.
|
||||
*
|
||||
* @param topVoter the top voter type
|
||||
* @return true if new message should be sent
|
||||
*/
|
||||
public boolean isDiscordSRVTopVoterNewMessageOnUpdate(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return isDiscordSRVTopVoterAllTimeNewMessageOnUpdate();
|
||||
case Monthly:
|
||||
return isDiscordSRVTopVoterMonthlyNewMessageOnUpdate();
|
||||
case Weekly:
|
||||
return isDiscordSRVTopVoterWeeklyNewMessageOnUpdate();
|
||||
case Daily:
|
||||
return isDiscordSRVTopVoterDailyNewMessageOnUpdate();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DiscordSRV top voter channel ID.
|
||||
*
|
||||
* @param topVoter the top voter type
|
||||
* @return the channel ID
|
||||
*/
|
||||
public long getDiscordSRVTopVoterChannel(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return getDiscordSRVTopVoterAllTimeChannel();
|
||||
case Monthly:
|
||||
return getDiscordSRVTopVoterMonthlyChannel();
|
||||
case Weekly:
|
||||
return getDiscordSRVTopVoterWeeklyChannel();
|
||||
case Daily:
|
||||
return getDiscordSRVTopVoterDailyChannel();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DiscordSRV top voter title.
|
||||
*
|
||||
* @param topVoter the top voter type
|
||||
* @return the title
|
||||
*/
|
||||
public String getDiscordSRVTopVoterTitle(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return getDiscordSRVTopVoterAllTimeTitle();
|
||||
case Monthly:
|
||||
return getDiscordSRVTopVoterMonthlyTitle();
|
||||
case Weekly:
|
||||
return getDiscordSRVTopVoterWeeklyTitle();
|
||||
case Daily:
|
||||
return getDiscordSRVTopVoterDailyTitle();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DiscordSRV top voter rank display format.
|
||||
*
|
||||
* @param topVoter the top voter type
|
||||
* @return the rank display format
|
||||
*/
|
||||
public String getDiscordSRVTopVoterRankDisplay(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return getDiscordSRVTopVoterAllTimeRankDisplay();
|
||||
case Monthly:
|
||||
return getDiscordSRVTopVoterMonthlyRankDisplay();
|
||||
case Weekly:
|
||||
return getDiscordSRVTopVoterWeeklyRankDisplay();
|
||||
case Daily:
|
||||
return getDiscordSRVTopVoterDailyRankDisplay();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowVotePointTransfers")
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlternateUUIDLookup")
|
||||
@Getter
|
||||
private boolean alternateUUIDLookup = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysCloseInventory")
|
||||
@Getter
|
||||
private boolean alwaysCloseInventory = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraVoteShopCheck")
|
||||
@Getter
|
||||
private boolean extraVoteShopCheck = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysUpdate")
|
||||
@Getter
|
||||
private boolean alwaysUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCreateVoteSites")
|
||||
@Getter
|
||||
private boolean autoCreateVoteSites = true;
|
||||
|
||||
@ConfigDataBoolean(path = "CountFakeVotes")
|
||||
@Getter
|
||||
private boolean countFakeVotes = true;
|
||||
|
||||
@ConfigDataString(path = "DelayBetweenUpdates")
|
||||
@Getter
|
||||
private String delayBetweenUpdates = "3m";
|
||||
|
||||
@ConfigDataBoolean(path = "DisableAdvancedTab")
|
||||
@Getter
|
||||
private boolean disableAdvancedTab = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableCoolDownCheck")
|
||||
@Getter
|
||||
private boolean disableCoolDownCheck = false;
|
||||
|
||||
@ConfigDataListString(path = "DisabledCommands")
|
||||
@Getter
|
||||
private ArrayList<String> disabledCommands = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "DisabledDefaultPermissions")
|
||||
@Getter
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "CachedPlaceholders")
|
||||
@Getter
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "DisableInteractEvent")
|
||||
@Getter
|
||||
private boolean disableInteractEvent = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableNoServiceSiteMessage")
|
||||
@Getter
|
||||
private boolean disableNoServiceSiteMessage = false;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.AdminVote.Points.PlayerRemoved")
|
||||
@Getter
|
||||
private String formatCommandsAdminVotePointsPlayerRemoved = "&c%amount% voting points have been removed from you";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.AdminVote.Points.PlayerGiven")
|
||||
@Getter
|
||||
private String formatCommandsAdminVotePointsPlayerGiven = "&cYou have been given %amount% voting points";
|
||||
|
||||
@ConfigDataBoolean(path = "DisableUpdateChecking")
|
||||
@Getter
|
||||
private boolean disableUpdateChecking = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraAllSitesCheck")
|
||||
@Getter
|
||||
private boolean extraAllSitesCheck = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CloseInventoryOnVote")
|
||||
@Getter
|
||||
private boolean closeInventoryOnVote = true;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraBackgroundUpdate")
|
||||
@Getter
|
||||
private boolean extraBackgroundUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.ForceLinks")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteForceLinks = true;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.LastVoted")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLastVoted = "%times% ago";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NotEnoughPoints")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsNotEnoughPoints = "&cNot enough points";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NotJoinedServer")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsNotJoinedServer = "&c%player% has not joined the server";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NumberLowerThanZero")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsNumberLowerThanZero = "&cNumber of points needs to be greater than 0";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.TransferFrom")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsTransferFrom = "&c%transfer% points given to %touser%";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.TransferTo")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsTransferTo = "&cYou received %transfer points from %fromuser%";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.Line", defaultValue = "&3%SiteName%: &6%timeSince% ago")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLine;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.NeverVoted", defaultValue = "Never voted")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastNeverVoted;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.Last.IncludeSeconds")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteLastIncludeSeconds = true;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.TimeFormat", defaultValue = "%amount% %TimeType%")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastTimeFormat;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Today.Line")
|
||||
@Getter
|
||||
private String formatCommandsVoteTodayLine = "&6%player% : %VoteSite% : %Time%";
|
||||
|
||||
@ConfigDataListString(path = "Format.Commands.Vote.Today.Title")
|
||||
@Getter
|
||||
private ArrayList<String> formatCommandsVoteTodayTitle = ArrayUtils
|
||||
.convert(new String[] { "&cToday's Votes %page%/%maxpage%", "&cPlayerName : VoteSite : Time" });
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Disabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastDisabled = "&cYou will no longer see vote broadcasts";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Enabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastEnabled = "&cYou will now see vote broadcasts";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleReminders.Disabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleRemindersDisabled = "&cVote reminders disabled";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleReminders.Enabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleRemindersEnabled = "&cVote reminders enabled";
|
||||
|
||||
@Getter
|
||||
private int formatPageSize = 10;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Day", defaultValue = "Day")
|
||||
@Getter
|
||||
private String formatTimeFormatsDay;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Days", defaultValue = "Days")
|
||||
@Getter
|
||||
private String formatTimeFormatsDays;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hour", defaultValue = "Hour")
|
||||
@Getter
|
||||
private String formatTimeFormatsHour;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hours", defaultValue = "Hours")
|
||||
@Getter
|
||||
private String formatTimeFormatsHours;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minute", defaultValue = "Minute")
|
||||
@Getter
|
||||
private String formatTimeFormatsMinute;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minutes", defaultValue = "Minutes")
|
||||
@Getter
|
||||
private String formatTimeFormatsMinutes;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Second", defaultValue = "Second")
|
||||
@Getter
|
||||
private String formatTimeFormatsSecond;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Seconds", defaultValue = "Seconds")
|
||||
@Getter
|
||||
private String formatTimeFormatsSeconds;
|
||||
|
||||
@ConfigDataBoolean(path = "LimitMonthlyVotes")
|
||||
@Getter
|
||||
private boolean limitMonthlyVotes = false;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadCommandAliases")
|
||||
@Getter
|
||||
private boolean loadCommandAliases = true;
|
||||
|
||||
@ConfigDataInt(path = "MaxiumNumberOfTopVotersToLoad")
|
||||
@Getter
|
||||
private int MaxiumNumberOfTopVotersToLoad = 1000;
|
||||
|
||||
@ConfigDataBoolean(path = "OverrideVersionDisable")
|
||||
@Getter
|
||||
private boolean overrideVersionDisable = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PreventRepeatMilestones")
|
||||
@Getter
|
||||
private boolean preventRepeatMilestones = false;
|
||||
|
||||
@ConfigDataBoolean(path = "OfflineVotesLimit.Enabled")
|
||||
@Getter
|
||||
private boolean offlineVotesLimitEnabled = false;
|
||||
|
||||
@ConfigDataInt(path = "OfflineVotesLimit.Amount")
|
||||
@Getter
|
||||
private int offlineVotesLimitAmount = 5;
|
||||
|
||||
@ConfigDataBoolean(path = "UpdateWithPlayersOnlineOnly")
|
||||
@Getter
|
||||
private boolean updateWithPlayersOnlineOnly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseHighestTotals")
|
||||
@Getter
|
||||
private boolean useHighestTotals = true;
|
||||
|
||||
@ConfigDataBoolean(path = "UseJavascriptPlaceholders")
|
||||
@Getter
|
||||
private boolean useJavascriptPlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseVoteGUIMainCommand")
|
||||
@Getter
|
||||
private boolean useVoteGUIMainCommand = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseVoteStreaks")
|
||||
@Getter
|
||||
private boolean useVoteStreaks = true;
|
||||
|
||||
@ConfigDataListString(path = "VotingBroadcastBlacklist")
|
||||
@Getter
|
||||
private ArrayList<String> votingBroadcastBlacklist = new ArrayList<>();
|
||||
|
||||
@ConfigDataKeys(path = "CustomCommands")
|
||||
@Getter
|
||||
private Set<String> customCommands = new HashSet<>();
|
||||
|
||||
@ConfigDataKeys(path = "CustomPlaceholderReturns")
|
||||
@Getter
|
||||
private Set<String> customPlaceholderReturns = new HashSet<>();
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.AutoInputSites")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteAutoInputSites = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.OnlyShowSitesToVote")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteOnlyShowSitesToVote = false;
|
||||
|
||||
@ConfigDataListString(path = "Format.Commands.Vote.Best.Lines")
|
||||
@Getter
|
||||
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<>();
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Best.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteBestTitle = "&3&l%player% Best Votes";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Help.HoverColor")
|
||||
@Getter
|
||||
private String formatCommandsVoteHelpHoverColor = "AQUA";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Help.Line")
|
||||
@Getter
|
||||
private String formatCommandsVoteHelpLine = "&6%Command% - &6%HelpMessage%";
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.Help.RequirePermission")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteHelpRequirePermission = false;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Help.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteHelpTitle = "&6Voting Player Help";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastTitle = "&3&l%player% Last Vote Times:";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.CanVote")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextInfoCanVote = "Go Vote!";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.Error")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextInfoError = "";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.TimeUntilVote")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextInfoTime = "&cCould not caculate time until next vote!";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.VoteDelayDaily")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextInfoVoteDelayDaily = "%hours% Hours and %minutes% Minutes";
|
||||
|
||||
@ConfigDataString(path = "PlaceholderCacheLevel", options = { "AUTO", "SPECIFIC", "NONE" })
|
||||
@Getter
|
||||
private String placeholderCacheLevelString = "AUTO";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Layout")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextLayout = "&3%SiteName%: &6%info%";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextTitle = "&3&l%player% Next Votes:";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Streak.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteStreakTitle = "&3&l%player% Vote Streak";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Sites")
|
||||
@Getter
|
||||
private String formatCommandsVoteURLS = "&4%num%: &c&l%SiteName% - &c%url%";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Points")
|
||||
@Getter
|
||||
private String formatCommandsVotePoints = "&a%Player% currently has &a&l%Points%&a Points!";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Top.Line")
|
||||
@Getter
|
||||
private String formatCommandsVoteTopLine = "&c%num%: &6%player%, %votes%";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Top.Title")
|
||||
@Getter
|
||||
private String formatCommandVoteTopTitle = "&3Top %Top% Voters %page%/%maxpages%";
|
||||
|
||||
@ConfigDataString(path = "Format.NextPage")
|
||||
@Getter
|
||||
private String formatNextPage = "&aNext Page";
|
||||
|
||||
@ConfigDataString(path = "Format.NoPerms")
|
||||
@Getter
|
||||
private String formatNoPerms = "&cYou do not have enough permission!";
|
||||
|
||||
@ConfigDataString(path = "Format.NotNumber")
|
||||
@Getter
|
||||
private String formatNotNumber = "&cError on &6%arg%&c, number expected!";
|
||||
|
||||
@ConfigDataString(path = "Format.PrevPage")
|
||||
@Getter
|
||||
private String formatPrevPage = "&aPrevious Page";
|
||||
|
||||
@ConfigDataString(path = "Format.ShopFailed")
|
||||
@Getter
|
||||
private String formatShopFailedMsg = "&cYou do not have %Points% points to purhcase this!";
|
||||
|
||||
@ConfigDataString(path = "Format.ShopNotPurchasable")
|
||||
@Getter
|
||||
private String formatShopNotPurchasable = "&cThis item is not buyable!";
|
||||
|
||||
@ConfigDataString(path = "Format.ShopPurchase")
|
||||
@Getter
|
||||
private String formatShopPurchaseMsg = "&aYou bought the %Identifier% for %Points% Points!";
|
||||
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line1")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine1 = "TopVoter: %SiteName%";
|
||||
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line2")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine2 = "#%position%";
|
||||
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line3")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine3 = "%player%";
|
||||
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line4")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine4 = "%votes% Votes";
|
||||
|
||||
@ConfigDataString(path = "Format.Signs.RightClickMessage")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignRightClickMessage = "&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cin &c&l%SiteName%";
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormat")
|
||||
@Getter
|
||||
private String formatTimeFormat = "EEE, d MMM yyyy HH:mm";
|
||||
|
||||
@ConfigDataString(path = "Format.TopVoter.AllTime")
|
||||
@Getter
|
||||
private String formatTopVoterAllTime = "AllTime";
|
||||
|
||||
@ConfigDataString(path = "Format.TopVoter.Daily")
|
||||
@Getter
|
||||
private String formatTopVoterDaily = "Daily";
|
||||
|
||||
@ConfigDataString(path = "Format.TopVoter.Monthly")
|
||||
@Getter
|
||||
private String formatTopVoterMonthly = "Monthly";
|
||||
|
||||
@ConfigDataString(path = "Format.TopVoterAwardMsg")
|
||||
@Getter
|
||||
private String formatTopVoterRewardMsg = "&aYou came in %place% in top voters of the month! Here is an award!";
|
||||
|
||||
@ConfigDataString(path = "Format.TopVoter.Weekly")
|
||||
@Getter
|
||||
private String formatTopVoterWeekly = "Weekly";
|
||||
|
||||
@ConfigDataString(path = "Format.UserNotExist")
|
||||
@Getter
|
||||
private String formatUserNotExist = "&cUser does not exist: %player%";
|
||||
|
||||
@ConfigDataString(path = "Format.InvalidCommand.Vote")
|
||||
@Getter
|
||||
private String formatInvalidCommandVote = "&4No valid arguments, see /vote help!";
|
||||
@ConfigDataString(path = "Format.InvalidCommand.AdminVote")
|
||||
@Getter
|
||||
private String formatInvalidCommandAdminVote = "&4No valid arguments, see /adminvote help!";
|
||||
@ConfigDataBoolean(path = "GiveDefaultPermission")
|
||||
@Getter
|
||||
private boolean giveDefaultPermission = true;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.AllTime")
|
||||
@Getter
|
||||
private boolean loadTopVoterAllTime = true;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.Monthly")
|
||||
@Getter
|
||||
private boolean loadTopVoterMonthly = true;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.Daily")
|
||||
@Getter
|
||||
private boolean loadTopVoterDaily = false;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.Weekly")
|
||||
@Getter
|
||||
private boolean loadTopVoterWeekly = false;
|
||||
|
||||
@ConfigDataInt(path = "PointsOnVote")
|
||||
@Getter
|
||||
private int pointsOnVote = 1;
|
||||
|
||||
@ConfigDataBoolean(path = "PurgeNoDataOnStartup")
|
||||
@Getter
|
||||
private boolean purgeNoDataOnStartup = false;
|
||||
|
||||
@ConfigDataBoolean(path = "StoreMonthTotalsWithDate")
|
||||
@Getter
|
||||
private boolean storeMonthTotalsWithDate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseMonthDateTotalsAsPrimaryTotal")
|
||||
@Getter
|
||||
private boolean useMonthDateTotalsAsPrimaryTotal = false;
|
||||
|
||||
@ConfigDataString(path = "RequestAPI.DefaultMethod")
|
||||
@Getter
|
||||
private String requestAPIDefaultMethod = "ANVIL";
|
||||
|
||||
@ConfigDataListString(path = "RequestAPI.DisabledMethods")
|
||||
@Getter
|
||||
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "StoreTopVoters.Daily")
|
||||
@Getter
|
||||
private boolean storeTopVotersDaily = false;
|
||||
|
||||
@ConfigDataBoolean(path = "StoreTopVoters.Weekly")
|
||||
@Getter
|
||||
private boolean storeTopVotersWeekly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "TopVoterAwardsTies")
|
||||
@Getter
|
||||
private boolean topVoterAwardsTies = true;
|
||||
|
||||
@ConfigDataBoolean(path = "TopVoterIgnorePermission")
|
||||
@Getter
|
||||
private boolean topVoterIgnorePermission = false;
|
||||
|
||||
@ConfigDataString(path = "VoteTopDefault")
|
||||
@Getter
|
||||
private String voteTopDefault = "Monthly";
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysProcessAsyncPlaceholders")
|
||||
@Getter
|
||||
private boolean alwaysProcessAsyncPlaceholders = false;
|
||||
|
||||
/**
|
||||
* Constructs a new Config.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public Config(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Config.yml"));
|
||||
setIgnoreCase(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the black list.
|
||||
*
|
||||
* @return the black list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getBlackList() {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom commands configuration section.
|
||||
*
|
||||
* @param ident the command identifier
|
||||
* @return the configuration section
|
||||
*/
|
||||
public ConfigurationSection getCustomCommands(String ident) {
|
||||
return getData().getConfigurationSection("CustomCommands." + ident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom placeholder return keys.
|
||||
*
|
||||
* @param placeholder the placeholder name
|
||||
* @return set of return keys
|
||||
*/
|
||||
public Set<String> getCustomPlaceholderReturns(String placeholder) {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a custom placeholder return value.
|
||||
*
|
||||
* @param placeholder the placeholder name
|
||||
* @param returnString the return key
|
||||
* @return the return value
|
||||
*/
|
||||
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
|
||||
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote party.
|
||||
*
|
||||
* @return the commands vote party
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteParty() {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Party", msg);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote streak lines format.
|
||||
*
|
||||
* @return list of format lines
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteStreakLines() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote text.
|
||||
*
|
||||
* @return the commands vote text
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteText() {
|
||||
ArrayList<String> str = new ArrayList<>();
|
||||
str.add("&4&lVote for our server!");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Text", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote total format lines.
|
||||
*
|
||||
* @return list of format lines
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotal() {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.Total", new ArrayList<>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&l%player% Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote total all format lines.
|
||||
*
|
||||
* @return list of format lines
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotalAll() {
|
||||
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.TotalAll",
|
||||
new ArrayList<>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&lServer Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote help.
|
||||
*
|
||||
* @return the vote help
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatVoteHelp() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a top voter type should be loaded.
|
||||
*
|
||||
* @param top the top voter type
|
||||
* @return true if should be loaded
|
||||
*/
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return isLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return isLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return isLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return isLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the placeholder cache level.
|
||||
*
|
||||
* @return the cache level
|
||||
*/
|
||||
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
|
||||
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
getPlugin().saveResource("Config.yml", true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,608 +0,0 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.time.ParsedDuration;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ConfigVoteSites.
|
||||
*/
|
||||
public class ConfigVoteSites extends YMLFile {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigVoteSites.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
*/
|
||||
public ConfigVoteSites(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "VoteSites.yml"));
|
||||
setIgnoreCase(plugin.getConfigFile().isCaseInsensitiveYMLFiles());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate vote site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
*/
|
||||
public void generateVoteSite(String siteName) {
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replaceAll("[\\.\\s]+", "_");
|
||||
|
||||
plugin.getLogger().warning("VoteSite " + siteName + " does not exist with the servicesite '" + org
|
||||
+ "', creating one, set AutoCreateVoteSites to false to prevent this");
|
||||
setEnabled(siteName, true);
|
||||
setServiceSite(siteName, org);
|
||||
setVoteURL(siteName, "VoteURL");
|
||||
setVoteDelay(siteName, "24h");
|
||||
set(siteName, "DisplayItem.Material", "STONE");
|
||||
set(siteName, "DisplayItem.Amount", 1);
|
||||
set(siteName, "Rewards.Messages.Player", "&aThanks for voting on %ServiceSite%!");
|
||||
|
||||
plugin.loadVoteSites();
|
||||
|
||||
plugin.addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteSites." + siteName + ".Rewards") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
plugin.getConfigVoteSites().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return plugin.getConfigVoteSites().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
plugin.getConfigVoteSites().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
plugin.getConfigVoteSites().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.addDirectlyDefinedRewards(
|
||||
new DirectlyDefinedReward("VoteSites." + siteName + ".CoolDownEndRewards") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
plugin.getConfigVoteSites().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return plugin.getConfigVoteSites().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
plugin.getConfigVoteSites().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
plugin.getConfigVoteSites().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.hasPermission("VotingPlugin.Admin.GenerateServiceSite") || p.isOp()) {
|
||||
p.sendMessage(MessageAPI.colorize("&cGenerating votesite for service site " + siteName
|
||||
+ ", please check console for details"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the data
|
||||
*/
|
||||
public ConfigurationSection getData(String siteName) {
|
||||
if (!getData().isConfigurationSection("VoteSites." + siteName)) {
|
||||
plugin.getLogger().warning("VoteSites." + siteName + " is not a configuration section");
|
||||
}
|
||||
return getData().getConfigurationSection("VoteSites." + siteName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name for a site.
|
||||
*
|
||||
* @param site the site name
|
||||
* @return the display name
|
||||
*/
|
||||
public String getDisplayName(String site) {
|
||||
return getData(site).getString("Name");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path to the every site reward.
|
||||
*
|
||||
* @return the every site reward path
|
||||
*/
|
||||
public String getEverySiteRewardPath() {
|
||||
return "EverySiteReward";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item configuration for a site.
|
||||
*
|
||||
* @param site the site name
|
||||
* @return the item configuration
|
||||
*/
|
||||
public ConfigurationSection getItem(String site) {
|
||||
if (getData(site).isConfigurationSection("DisplayItem")) {
|
||||
return getData(site).getConfigurationSection("DisplayItem");
|
||||
}
|
||||
return getData(site).getConfigurationSection("Item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the permission required to view a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the permission to view
|
||||
*/
|
||||
public String getPermissionToView(String siteName) {
|
||||
return getData(siteName).getString("PermissionToView", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the priority
|
||||
*/
|
||||
public int getPriority(String siteName) {
|
||||
return getData(siteName).getInt("Priority");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the rewards
|
||||
*/
|
||||
public String getRewardsPath(String siteName) {
|
||||
return "VoteSites." + siteName + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the service site
|
||||
*/
|
||||
public String getServiceSite(String siteName) {
|
||||
return getData(siteName).getString("ServiceSite");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay for a site.
|
||||
*
|
||||
* @param site the site name
|
||||
* @return the vote delay
|
||||
*/
|
||||
public ParsedDuration getVoteDelay(String site) {
|
||||
ConfigurationSection sec = getData(site);
|
||||
|
||||
// NEW FORMAT (string)
|
||||
if (sec.isString("VoteDelay")) {
|
||||
return ParsedDuration.parse(sec.getString("VoteDelay"), TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
// LEGACY FORMAT (numbers)
|
||||
double hours = sec.getDouble("VoteDelay", 0);
|
||||
double minutes = sec.getDouble("VoteDelayMin", 0);
|
||||
|
||||
long millis = (long) (hours * 60 * 60 * 1000) + (long) (minutes * 60 * 1000);
|
||||
|
||||
return ParsedDuration.ofMillis(millis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay daily hour for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the vote delay daily hour
|
||||
*/
|
||||
public int getVoteDelayDailyHour(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayDailyHour", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site enabled.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the vote site enabled
|
||||
*/
|
||||
public boolean getVoteSiteEnabled(String siteName) {
|
||||
return getData(siteName).getBoolean("Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site file.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the vote site file
|
||||
*/
|
||||
public File getVoteSiteFile(String siteName) {
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator + "VoteSites", siteName + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(ChatColor.RED + "Could not create VoteSites/" + siteName + ".yml!");
|
||||
|
||||
}
|
||||
}
|
||||
return dFile;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to give rewards offline for a site.
|
||||
*
|
||||
* @param site the site name
|
||||
* @return true if rewards should be given offline
|
||||
*/
|
||||
public boolean getVoteSiteGiveOffline(String site) {
|
||||
return getData(site).getBoolean("ForceOffline", getData(site).getBoolean("GiveOffline"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether a site is hidden.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return true if the site is hidden
|
||||
*/
|
||||
public boolean getVoteSiteHidden(String siteName) {
|
||||
return getData(siteName).getBoolean("Hidden");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to ignore can vote check for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return true if can vote check should be ignored
|
||||
*/
|
||||
public boolean getVoteSiteIgnoreCanVote(String siteName) {
|
||||
return getData(siteName).getBoolean("IgnoreCanVote");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether vote delay resets daily for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return true if vote delay resets daily
|
||||
*/
|
||||
public boolean getVoteSiteResetVoteDelayDaily(String siteName) {
|
||||
return getData(siteName).getBoolean("VoteDelayDaily");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote sites load.
|
||||
*
|
||||
* @return the vote sites load
|
||||
*/
|
||||
public ArrayList<VoteSite> getVoteSitesLoad() {
|
||||
ArrayList<VoteSite> voteSites = new ArrayList<>();
|
||||
ArrayList<String> voteSiteNames = getVoteSitesNames(true);
|
||||
if (voteSiteNames != null) {
|
||||
for (String site : voteSiteNames) {
|
||||
if (getVoteSiteEnabled(site) && !site.equalsIgnoreCase("null")) {
|
||||
if (!siteCheck(site)) {
|
||||
plugin.getLogger().warning("Failed to load site " + site + ", see above");
|
||||
} else {
|
||||
VoteSite voteSite = new VoteSite(plugin, site);
|
||||
plugin.debug(voteSite.loadingDebug());
|
||||
voteSites.add(voteSite);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(voteSites, new Comparator<VoteSite>() {
|
||||
@Override
|
||||
public int compare(VoteSite v1, VoteSite v2) {
|
||||
int v1P = v1.getPriority();
|
||||
int v2P = v2.getPriority();
|
||||
|
||||
if (v1P < v2P) {
|
||||
return 1;
|
||||
}
|
||||
if (v1P > v2P) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
return voteSites;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the names of vote sites.
|
||||
*
|
||||
* @param checkEnabled whether to check if sites are enabled
|
||||
* @return the list of vote site names
|
||||
*/
|
||||
public ArrayList<String> getVoteSitesNames(boolean checkEnabled) {
|
||||
ArrayList<String> siteNames = new ArrayList<>();
|
||||
|
||||
if (!getData().isConfigurationSection("VoteSites")) {
|
||||
return siteNames;
|
||||
}
|
||||
|
||||
siteNames = ArrayUtils.convert(getData().getConfigurationSection("VoteSites").getKeys(false));
|
||||
|
||||
for (int i = siteNames.size() - 1; i >= 0; i--) {
|
||||
String site = siteNames.get(i);
|
||||
String path = "VoteSites." + site;
|
||||
|
||||
if (!getData().isConfigurationSection(path)) {
|
||||
plugin.getLogger().warning(path + " is not a configuration section, please remove");
|
||||
siteNames.remove(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (site.equalsIgnoreCase("null") || (!getVoteSiteEnabled(site) && checkEnabled) || !siteCheck(site)) {
|
||||
siteNames.remove(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return siteNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL(String siteName) {
|
||||
return getData(siteName).getString("VoteURL", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to wait until vote delay for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return true if should wait until vote delay
|
||||
*/
|
||||
public boolean getWaitUntilVoteDelay(String siteName) {
|
||||
return getData(siteName).getBoolean("WaitUntilVoteDelay", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is service site good.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return true, if is service site good
|
||||
*/
|
||||
public boolean isServiceSiteGood(String siteName) {
|
||||
if (getServiceSite(siteName) == null || getServiceSite(siteName).equals("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is vote URL good.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return true, if is vote URL good
|
||||
*/
|
||||
public boolean isVoteURLGood(String siteName) {
|
||||
if (getVoteURL(siteName) == null || getVoteURL(siteName).equals("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("VoteSites.yml", true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename vote site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param newName the new name
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean renameVoteSite(String siteName, String newName) {
|
||||
return getVoteSiteFile(siteName)
|
||||
.renameTo(new File(plugin.getDataFolder() + File.separator + "VoteSites", newName + ".yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param path the path
|
||||
* @param value the value
|
||||
*/
|
||||
public void set(String siteName, String path, Object value) {
|
||||
// String playerName = user.getPlayerName();
|
||||
ConfigurationSection data = getData(siteName);
|
||||
if (data == null) {
|
||||
getData().createSection("VoteSites." + siteName);
|
||||
data = getData(siteName);
|
||||
}
|
||||
data.set(path, value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cumulative rewards.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setCumulativeRewards(String siteName, ArrayList<String> value) {
|
||||
set(siteName, "Cumulative.Rewards", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cumulative votes for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setCumulativeVotes(String siteName, int value) {
|
||||
set(siteName, "Cumulative.Votes", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display name for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setDisplayName(String siteName, String value) {
|
||||
set(siteName, "Name", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param disabled the disabled
|
||||
*/
|
||||
public void setEnabled(String siteName, boolean disabled) {
|
||||
set(siteName, "Enabled", disabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to force offline for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setForceOffline(String siteName, boolean value) {
|
||||
set(siteName, "ForceOffline", value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setPriority(String siteName, int value) {
|
||||
set(siteName, "Priority", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rewards.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setRewards(String siteName, ArrayList<String> value) {
|
||||
set(siteName, "Rewards", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the service site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param serviceSite the service site
|
||||
*/
|
||||
public void setServiceSite(String siteName, String serviceSite) {
|
||||
set(siteName, "ServiceSite", serviceSite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote delay.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param voteDelay the vote delay
|
||||
*/
|
||||
public void setVoteDelay(String siteName, String voteDelay) {
|
||||
set(siteName, "VoteDelay", voteDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param url the url
|
||||
*/
|
||||
public void setVoteURL(String siteName, String url) {
|
||||
set(siteName, "VoteURL", url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Site check.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean siteCheck(String siteName) {
|
||||
boolean pass = true;
|
||||
if (!isServiceSiteGood(siteName)) {
|
||||
plugin.getLogger().warning("Issue with ServiceSite in site " + siteName + ", votes may not work properly");
|
||||
pass = false;
|
||||
}
|
||||
if (!isVoteURLGood(siteName)) {
|
||||
plugin.getLogger().warning("Issue with VoteURL in site " + siteName);
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote delay daily hour for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param intValue the value
|
||||
*/
|
||||
public void setVoteDelayDailyHour(String siteName, int intValue) {
|
||||
set(siteName, "VoteDelayDailyHour", intValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether vote delay is daily for a site.
|
||||
*
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setVoteDelayDaily(String siteName, boolean value) {
|
||||
set(siteName, "VoteDelayDaily", value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,503 +0,0 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataConfigurationSection;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* GUI configuration.
|
||||
*/
|
||||
public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.AlreadyVotedColor")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUIAlreadyVotedColor = "RED";
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.AlreadyVotedText")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUIAlreadyVotedText = "Click me";
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.CanVoteColor")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUICanVoteColor = "GREEN";
|
||||
|
||||
@ConfigDataBoolean(path = "BOOK.VoteURLBookGUI.Manual")
|
||||
@Getter
|
||||
private boolean bookVoteURLBookGUIManual = false;
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.CanVoteText")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUICanVoteText = "Click me";
|
||||
|
||||
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.Layout")
|
||||
@Getter
|
||||
private ArrayList<String> bookVoteURLBookGUILayout = ArrayUtils
|
||||
.convert(new String[] { "&c%Sitename%", "[UrlText]" });
|
||||
|
||||
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.TopLayout")
|
||||
@Getter
|
||||
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<>();
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.Title")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUITitle = "&cVoteURL";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteBest.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteBestBackButton = true;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteToday.IconTitle")
|
||||
@Getter
|
||||
private String chestVoteTodayIconTitle = "%player%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteToday.Line")
|
||||
@Getter
|
||||
private String chestVoteTodayLine = "&6%VoteSite% : %Time%";
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteToday.PlayerItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTodayPlayerItem;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteToday.UseSkull", defaultValue = true)
|
||||
@Getter
|
||||
private boolean chestVoteTodayUseSkull = true;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteTop.PlayerItem.Material")
|
||||
@Getter
|
||||
private String chestVoteTopPlayerItemMaterial = "PAPER";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTop.UseSkull")
|
||||
@Getter
|
||||
private boolean chestVoteTopUseSkull = true;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteURL.AllUrlsButton.RequireAllSitesVoted")
|
||||
@Getter
|
||||
private boolean chestVoteURLAllUrlsButtonrequireAllSitesVoted = true;
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Today", options = { "CHEST", "CHAT", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodToday = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.TopVoter", options = { "CHEST", "CHAT", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodTopVoter = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Last", options = { "CHEST", "CHAT", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodLast = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Next", options = { "CHEST", "CHAT", "BOOK", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodNext = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Total", options = { "CHEST", "CHAT", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodTotal = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.URL", options = { "CHEST", "CHAT", "BOOK", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodURL = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Best", options = { "CHEST", "CHAT", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodBest = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Streak", options = { "CHEST", "CHAT", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodStreak = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.GUI", options = { "CHEST", "DIALOG" })
|
||||
@Getter
|
||||
private String guiMethodGUI = "CHEST";
|
||||
|
||||
@ConfigDataBoolean(path = "LastMonthGUI")
|
||||
@Getter
|
||||
private boolean lastMonthGUI = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteLast.ClickableLinks")
|
||||
@Getter
|
||||
private boolean chestVoteLastClickableLinks = true;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.BackButton")
|
||||
@Getter
|
||||
private ConfigurationSection CHESTBackButton;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.DayBest.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteBestDayBestItem;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.MonthBest.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteBestMonthBestItem;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteBest.Name")
|
||||
@Getter
|
||||
private String chestVoteBestName = "VoteBest: %player%";
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.WeekBest.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteBestWeekBestItem;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteGUIName")
|
||||
@Getter
|
||||
private String chestVoteGUIName = "&cVoteGUI: &c&l%player%";
|
||||
|
||||
@ConfigDataKeys(path = "CHEST.VoteGUI")
|
||||
@Getter
|
||||
private Set<String> chestVoteGUISlots = new HashSet<>();
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.Customization")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTopCustomization;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteLast.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteLastBackButton = false;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteLast.Line")
|
||||
@Getter
|
||||
private String chestVoteLastLine = "&6%timeSince%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteLast.Name")
|
||||
@Getter
|
||||
private String chestVoteLastName = "VoteLast: %player%";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteNext.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteNextBackButton = false;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteNext.Name")
|
||||
@Getter
|
||||
private String chestVoteNextName = "VoteNext: %player%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteNext.Line")
|
||||
@Getter
|
||||
private String chestVoteNextLine = "%time%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteRewardName")
|
||||
@Getter
|
||||
private String chestVoteRewardName = "VoteReward";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteStreak.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteStreakBackButton = false;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentDayStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakCurrentDayStreakItem;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentMonthStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakCurrentMonthStreakItem;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentWeekStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakCurrentWeekStreakItem;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestDayStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakHighestDayStreakItem;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestMonthStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakHighestMonthStreakItem;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestWeekStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakHighestWeekStreakItem;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteStreak.Name")
|
||||
@Getter
|
||||
private String chestVoteStreakName = "VoteStreak";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteToday.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteTodayBackButton = false;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteToday.Name")
|
||||
@Getter
|
||||
private String chestVoteTodayName = "VoteToday";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTop.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteTopBackButton = false;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteTop.Item.Lore")
|
||||
@Getter
|
||||
private String chestVoteTopItemLore = "&3&lVotes: &3%votes%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteTop.Item.Name")
|
||||
@Getter
|
||||
private String chestVoteTopItemName = "&3&l%position%: &3%player%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteTop.Name")
|
||||
@Getter
|
||||
private String chestVoteTopName = "VoteTop %topvoter%";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTop.OpenMainGUIOnClick")
|
||||
@Getter
|
||||
private boolean chestVoteTopOpenMainGUIOnClick = true;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTop.CloseGUIOnClick")
|
||||
@Getter
|
||||
private boolean chestVoteTopCloseGUIOnClick = true;
|
||||
|
||||
@ConfigDataInt(path = "CHEST.VoteTop.Size")
|
||||
@Getter
|
||||
private int chestVoteTopSize = 27;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.SwitchItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTopSwitchItem;
|
||||
|
||||
@ConfigDataListString(path = "CHEST.VoteTop.SwitchItem.TopVoters")
|
||||
@Getter
|
||||
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<>();
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.AllTimeTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalAllTimeTotalItem;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTotal.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteTotalBackButton = false;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.DayTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalDayTotalItem;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.MonthTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalMonthTotalItem;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteTotal.Name")
|
||||
@Getter
|
||||
private String chestVoteTotalName = "VoteTotal: %player%";
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.WeekTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalWeekTotalItem;
|
||||
|
||||
@ConfigDataInt(path = "CHEST.VoteURL.AllUrlsButton.Slot")
|
||||
@Getter
|
||||
private int chestVoteURLAllUrlsButtonSlot = -1;
|
||||
|
||||
@ConfigDataInt(path = "CHEST.VoteURL.StartSlot")
|
||||
@Getter
|
||||
private int chestVoteURLAllUrlsButtonStartSlot = -1;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem", secondPath = "CHEST.VoteURL.AlreadyVotedItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteURLAlreadyVotedAllUrlsButtonItemSection;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AlreadyVotedItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteURLAlreadyVotedItemSection;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteURL.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteURLBackButton = false;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AllUrlsButton.CanVoteItem", secondPath = "CHEST.VoteURL.CanVoteItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteURLCanVoteAllUrlsButtonItemSection;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.CanVoteItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteURLCanVoteItemSection;
|
||||
|
||||
@ConfigDataKeys(path = "CHEST.VoteURL.ExtraItems")
|
||||
@Getter
|
||||
private Set<String> chestVoteURLExtraItems = new HashSet<>();
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.SiteName")
|
||||
@Getter
|
||||
private String chestVoteURLGUISiteName = "&c%Name%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.SiteNameCanVote")
|
||||
@Getter
|
||||
private String chestVoteURLGUISiteNameCanVote = "&a%Name%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.Name")
|
||||
@Getter
|
||||
private String chestVoteURLName = "&cVoteURL";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.NextVote")
|
||||
@Getter
|
||||
private String chestVoteURLNextVote = "&cCan Vote In: %Info%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.SeeURL")
|
||||
@Getter
|
||||
private String chestVoteURLSeeURL = "&cClick to see URL";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURLSite.Name")
|
||||
@Getter
|
||||
private String chestVoteURLSiteName = "VoteSite %site%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.URLText")
|
||||
@Getter
|
||||
private String chestVoteURLURLText = "%VoteUrl%";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteURL.ViewAllUrlsButtonEnabled")
|
||||
@Getter
|
||||
private boolean chestVoteURLViewAllUrlsButtonEnabled = false;
|
||||
|
||||
/**
|
||||
* Constructs a new GUI configuration.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
*/
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
|
||||
setIgnoreCase(plugin.getConfigFile().isCaseInsensitiveYMLFiles());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extra items for a chest GUI.
|
||||
*
|
||||
* @param gui the GUI name
|
||||
* @return the extra items
|
||||
*/
|
||||
public Set<String> getChestGUIExtraItems(String gui) {
|
||||
if (getData().isConfigurationSection("CHEST." + gui + ".ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an extra item configuration for a chest GUI.
|
||||
*
|
||||
* @param gui the GUI name
|
||||
* @param item the item name
|
||||
* @return the item configuration
|
||||
*/
|
||||
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot command
|
||||
*/
|
||||
|
||||
public String getChestVoteGUISlotCommand(String slot) {
|
||||
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot lore.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot lore
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChestVoteGUISlotLore(String slot) {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards path for a chest vote GUI slot.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @param lastPath the last path segment
|
||||
* @return the rewards path
|
||||
*/
|
||||
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
|
||||
return "CHEST.VoteGUI." + slot + "." + lastPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration section for a chest vote GUI slot.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the configuration section
|
||||
*/
|
||||
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot slot
|
||||
*/
|
||||
public int getChestVoteGUISlotSlot(String slot) {
|
||||
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the custom site name display for a vote next GUI.
|
||||
*
|
||||
* @param site the site name
|
||||
* @return the custom display name
|
||||
*/
|
||||
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
|
||||
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total item configuration for a top voter.
|
||||
*
|
||||
* @param top the top voter
|
||||
* @return the item configuration
|
||||
*/
|
||||
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getChestVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getChestVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getChestVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an extra item configuration for a vote URL GUI.
|
||||
*
|
||||
* @param item the item name
|
||||
* @return the item configuration
|
||||
*/
|
||||
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("GUI.yml", true);
|
||||
}
|
||||
}
|
||||
@@ -1,395 +0,0 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataConfigurationSection;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The ShopFile class manages the vote shop configuration.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ShopFile extends YMLFile {
|
||||
|
||||
@ConfigDataConfigurationSection(path = "ShopConfirmPurchase.NoItem")
|
||||
private ConfigurationSection shopConfirmPurchaseNoItem;
|
||||
|
||||
@ConfigDataBoolean(path = "ShopConfirmPurchase.UseDialog")
|
||||
private boolean shopConfirmPurchaseUseDialog = false;
|
||||
|
||||
@ConfigDataString(path = "ShopConfirmPurchase.Title")
|
||||
private String shopConfirmPurchaseTitle = "Confirm Purchase?";
|
||||
|
||||
@ConfigDataConfigurationSection(path = "ShopConfirmPurchase.YesItem")
|
||||
private ConfigurationSection shopConfirmPurchaseYesItem;
|
||||
|
||||
@ConfigDataString(path = "VoteShop.Disabled")
|
||||
private String voteShopDisabled = "&cVote shop disabled";
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.HideLimitedReached")
|
||||
private boolean voteShopHideLimitedReached = true;
|
||||
|
||||
@ConfigDataString(path = "VoteShop.LimitReached")
|
||||
private String voteShopLimitReached = "&aYou reached your limit";
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.RequireConfirmation")
|
||||
private boolean voteShopRequireConfirmation = false;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.BackButton")
|
||||
private boolean voteShopBackButton = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.ReopenGUIOnPurchase")
|
||||
private boolean voteShopReopenGuiOnPurchase = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.Enabled")
|
||||
private boolean voteShopEnabled = true;
|
||||
|
||||
@ConfigDataString(path = "VoteShop.Name")
|
||||
private String voteShopName = "VoteShop";
|
||||
|
||||
@ConfigDataKeys(path = "ExtraItems")
|
||||
private Set<String> voteShopExtraItems = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Constructs a new ShopFile.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public ShopFile(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Shop.yml"));
|
||||
setIgnoreCase(plugin.getConfigFile().isCaseInsensitiveYMLFiles());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts vote shop data from the GUI file to this shop file.
|
||||
*/
|
||||
public void convertFromGUIFile() {
|
||||
setValue("VoteShop.Enabled", plugin.getGui().getData().getBoolean("CHEST.VoteShopEnabled"));
|
||||
setValue("VoteShop.BackButton", plugin.getGui().getData().getBoolean("CHEST.VoteShopBackButton"));
|
||||
setValue("VoteShop.HideLimitReached", plugin.getGui().getData().getBoolean("CHEST.VoteShopHideLimitedReached"));
|
||||
setValue("VoteShop.RequireConfirmation",
|
||||
plugin.getGui().getData().getBoolean("CHEST.VoteShopRequireConfirmation"));
|
||||
setValue("VoteShop.ReopenGUIOnPurchase",
|
||||
plugin.getGui().getData().getBoolean("CHEST.VoteShopReopenGUIOnPurchase"));
|
||||
setValue("VoteShop.Name", plugin.getGui().getData().getString("CHEST.VoteShopName"));
|
||||
setValue("VoteShop.LimitReached", plugin.getGui().getData().getString("CHEST.VoteShopLimitReached"));
|
||||
setValue("VoteShop.Disabled", plugin.getGui().getData().getString("CHEST.VoteShopDisabled"));
|
||||
setValue("Shop", plugin.getGui().getData().getConfigurationSection("CHEST.Shop"));
|
||||
setValue("ExtraItems", plugin.getGui().getData().getConfigurationSection("CHEST.VoteShopExtraItems"));
|
||||
setValue("ShopConfirmPurchase", plugin.getGui().getData().getConfigurationSection("CHEST.ShopConfirmPurchase"));
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new legacy shop item.
|
||||
*
|
||||
* @param value the identifier
|
||||
*/
|
||||
public void createShop(String value) {
|
||||
ConfigurationSection shopData = getData().createSection("Shop." + value);
|
||||
shopData.set("Identifier_Name", value);
|
||||
shopData.set("Material", "STONE");
|
||||
shopData.set("Amount", 1);
|
||||
shopData.set("Name", "&cPlaceholder item");
|
||||
shopData.set("Cost", 1);
|
||||
shopData.set("Permission", "");
|
||||
shopData.set("CloseGUI", true);
|
||||
shopData.set("RequireConfirmation", false);
|
||||
shopData.set("Rewards.Items.Item1.Material", "STONE");
|
||||
shopData.set("Rewards.Items.Item1.Amount", 1);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the categories section.
|
||||
*
|
||||
* @return the categories section
|
||||
*/
|
||||
public ConfigurationSection getCategoriesSection() {
|
||||
return getData().getConfigurationSection("Categories");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a category section.
|
||||
*
|
||||
* @param categoryId the category id
|
||||
* @return the category section
|
||||
*/
|
||||
public ConfigurationSection getCategorySection(String categoryId) {
|
||||
return getData().getConfigurationSection("Categories." + categoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a category shop section.
|
||||
*
|
||||
* @param categoryId the category id
|
||||
* @return the category shop section
|
||||
*/
|
||||
public ConfigurationSection getCategoryShopSection(String categoryId) {
|
||||
return getData().getConfigurationSection("Categories." + categoryId + ".Shop");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a category back button is enabled.
|
||||
*
|
||||
* @param category the category id
|
||||
* @return true if enabled
|
||||
*/
|
||||
public boolean isCategoryBackButtonEnabled(String category) {
|
||||
return getData().getBoolean("Categories." + category + ".BackButton", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the category back button item section.
|
||||
*
|
||||
* @param category the category id
|
||||
* @return configuration section or null
|
||||
*/
|
||||
public ConfigurationSection getCategoryBackButtonItem(String category) {
|
||||
String path = "Categories." + category + ".BackButtonItem";
|
||||
|
||||
if (getData().isConfigurationSection(path)) {
|
||||
return getData().getConfigurationSection(path);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default VoteShop back button item.
|
||||
*
|
||||
* @return configuration section or null
|
||||
*/
|
||||
public ConfigurationSection getDefaultBackButtonItem() {
|
||||
if (getData().isConfigurationSection("VoteShop.BackButtonItem")) {
|
||||
return getData().getConfigurationSection("VoteShop.BackButtonItem");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display section for an entry, preferring DisplayItem when present.
|
||||
*
|
||||
* @param section the entry section
|
||||
* @return the display section
|
||||
*/
|
||||
public ConfigurationSection getDisplaySection(ConfigurationSection section) {
|
||||
if (section == null) {
|
||||
return null;
|
||||
}
|
||||
ConfigurationSection displaySection = section.getConfigurationSection("DisplayItem");
|
||||
if (displaySection != null) {
|
||||
return displaySection;
|
||||
}
|
||||
return section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration for a vote shop extra item.
|
||||
*
|
||||
* @param item the item identifier
|
||||
* @return the configuration section
|
||||
*/
|
||||
public ConfigurationSection getGUIVoteShopExtraItems(String item) {
|
||||
return getData().getConfigurationSection("ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cost of a shop item.
|
||||
*
|
||||
* @param identifier the shop identifier
|
||||
* @return the cost
|
||||
*/
|
||||
public int getShopIdentifierCost(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Cost");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the identifier name for a shop item.
|
||||
*
|
||||
* @param identifier the shop identifier
|
||||
* @return the identifier name
|
||||
*/
|
||||
public String getShopIdentifierIdentifierName(String identifier) {
|
||||
return getData().getString("Shop." + identifier + ".Identifier_Name", identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the purchase limit for a shop item.
|
||||
*
|
||||
* @param identifier the shop identifier
|
||||
* @return the purchase limit
|
||||
*/
|
||||
public int getShopIdentifierLimit(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Limit", -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards path for a shop item.
|
||||
*
|
||||
* @param identifier the shop identifier
|
||||
* @return the rewards path
|
||||
*/
|
||||
public String getShopIdentifierRewardsPath(String identifier) {
|
||||
return "Shop." + identifier + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all shop identifiers.
|
||||
*
|
||||
* @return the set of shop identifiers
|
||||
*/
|
||||
public Set<String> getShopIdentifiers() {
|
||||
ConfigurationSection shop = getData().getConfigurationSection("Shop");
|
||||
if (shop != null) {
|
||||
return shop.getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shop root section.
|
||||
*
|
||||
* @return the shop section
|
||||
*/
|
||||
public ConfigurationSection getShopSection() {
|
||||
return getData().getConfigurationSection("Shop");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration section for a shop item.
|
||||
*
|
||||
* @param identifier the shop identifier
|
||||
* @return the configuration section
|
||||
*/
|
||||
public ConfigurationSection getShopIdentifierSection(String identifier) {
|
||||
return getData().getConfigurationSection("Shop." + identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the GUI should close on purchase.
|
||||
*
|
||||
* @param shop the shop identifier
|
||||
* @return true if GUI should close
|
||||
*/
|
||||
public boolean getVoteShopCloseGUI(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".CloseGUI", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the shop item should be hidden when player has no permission.
|
||||
*
|
||||
* @param shop the shop identifier
|
||||
* @return true if should hide
|
||||
*/
|
||||
public boolean getVoteShopHideOnNoPermission(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".HideOnNoPermission", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the shop item is not buyable.
|
||||
*
|
||||
* @param shop the shop identifier
|
||||
* @return true if not buyable
|
||||
*/
|
||||
public boolean getVoteShopNotBuyable(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".NotBuyable", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the permission required for a shop item.
|
||||
*
|
||||
* @param ident the shop identifier
|
||||
* @return the permission
|
||||
*/
|
||||
public String getVoteShopPermission(String ident) {
|
||||
return getData().getString("Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the purchase message for a shop item.
|
||||
*
|
||||
* @param identifier the shop identifier
|
||||
* @return the purchase message
|
||||
*/
|
||||
public String getVoteShopPurchase(String identifier) {
|
||||
return getData().getString("Shop." + identifier + ".PurchaseMessage",
|
||||
plugin.getConfigFile().getFormatShopPurchaseMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the shop item resets daily.
|
||||
*
|
||||
* @param shop the shop identifier
|
||||
* @return true if resets daily
|
||||
*/
|
||||
public boolean getVoteShopResetDaily(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".Reset.Daily", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the shop item resets monthly.
|
||||
*
|
||||
* @param shop the shop identifier
|
||||
* @return true if resets monthly
|
||||
*/
|
||||
public boolean getVoteShopResetMonthly(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".Reset.Monthly", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the shop item resets weekly.
|
||||
*
|
||||
* @param shop the shop identifier
|
||||
* @return true if resets weekly
|
||||
*/
|
||||
public boolean getVoteShopResetWeekly(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".Reset.Weekly", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the shop item requires purchase confirmation.
|
||||
*
|
||||
* @param identifier the shop identifier
|
||||
* @return true if requires confirmation
|
||||
*/
|
||||
public boolean isVoteShopRequireConfirmation(String identifier) {
|
||||
return getData().getBoolean("Shop." + identifier + ".RequireConfirmation", isVoteShopRequireConfirmation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("Shop.yml", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a shop item.
|
||||
*
|
||||
* @param value the shop identifier
|
||||
*/
|
||||
public void removeShop(String value) {
|
||||
getData().set("Shop." + value, null);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
-317
@@ -1,317 +0,0 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataDouble;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* The SpecialRewardsConfig class manages special rewards configuration.
|
||||
*/
|
||||
public class SpecialRewardsConfig extends YMLFile {
|
||||
|
||||
@Getter
|
||||
private String anySiteRewardsPath = "AnySiteRewards";
|
||||
|
||||
@ConfigDataBoolean(path = "EnableDailyRewards")
|
||||
@Getter
|
||||
private boolean enableDailyRewards = false;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableMonthlyAwards")
|
||||
@Getter
|
||||
private boolean enableMonthlyAwards = true;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableWeeklyAwards")
|
||||
@Getter
|
||||
private boolean enableWeeklyAwards = false;
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.GiveOnlinePlayersOnly")
|
||||
@Getter
|
||||
private boolean votePartyGiveOnlinePlayersOnly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetCount")
|
||||
@Getter
|
||||
private boolean votePartyResetCount = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesWeekly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesWeekly = false;
|
||||
|
||||
@ConfigDataString(path = "VoteParty.VoteReminder.Broadcast", secondPath = "VoteParty.VoteReminderBroadcast")
|
||||
@Getter
|
||||
private String votePartyVoteReminderBroadcast = "%votesrequired% left to go, go vote!";
|
||||
|
||||
@ConfigDataListInt(path = "VoteParty.VoteReminder.AtVotes", secondPath = "VoteParty.VoteReminderAtVotes")
|
||||
@Getter
|
||||
private ArrayList<Integer> votePartyVoteReminderAtVotes = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.VoteReminder.Commands", secondPath = "VoteParty.VoteReminderCommands")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyVoteReminderCommands = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Day")
|
||||
@Getter
|
||||
private double voteStreakRequirementDay = 50;
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Month")
|
||||
@Getter
|
||||
private double voteStreakRequirementMonth = 50;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteStreak.Requirement.UsePercentage")
|
||||
@Getter
|
||||
private boolean voteStreakRequirementUsePercentage = false;
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Week")
|
||||
@Getter
|
||||
private double voteStreakRequirementWeek = 50;
|
||||
|
||||
@ConfigDataKeys(path = "DailyAwards")
|
||||
@Getter
|
||||
private Set<String> dailyPossibleRewardPlaces = new HashSet<>();
|
||||
|
||||
@ConfigDataString(path = "VoteParty.Broadcast")
|
||||
@Getter
|
||||
private String votePartyBroadcast = "";
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalCommands", secondPath = "VoteParty.Commands")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalCommands = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.CountFakeVotes")
|
||||
@Getter
|
||||
private boolean votePartyCountFakeVotes = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.CountOfflineVotes")
|
||||
@Getter
|
||||
private boolean votePartyCountOfflineVotes = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.Enabled")
|
||||
@Getter
|
||||
private boolean votePartyEnabled = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.GiveAllPlayers")
|
||||
@Getter
|
||||
private boolean votePartyGiveAllPlayers = false;
|
||||
|
||||
@Deprecated
|
||||
@ConfigDataInt(path = "VoteParty.IncreaseVotesRquired")
|
||||
@Getter
|
||||
private int votePartyIncreaseVotesRquired = 0;
|
||||
|
||||
@ConfigDataInt(path = "VoteParty.IncreaseVotesRequired")
|
||||
@Getter
|
||||
private int votePartyIncreaseVotesRequired = 0;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerDay")
|
||||
@Getter
|
||||
private boolean votePartyOnlyOncePerDay = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerWeek")
|
||||
@Getter
|
||||
private boolean votePartyOnlyOncePerWeek = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetEachDay")
|
||||
@Getter
|
||||
private boolean votePartyResetEachDay = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetMonthly")
|
||||
@Getter
|
||||
private boolean votePartyResetMonthly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetWeekly")
|
||||
@Getter
|
||||
private boolean votePartyResetWeekly = false;
|
||||
|
||||
@ConfigDataInt(path = "VoteParty.UserVotesRequired")
|
||||
@Getter
|
||||
private int votePartyUserVotesRequired = 0;
|
||||
@ConfigDataInt(path = "VoteParty.VotesRequired")
|
||||
@Getter
|
||||
private int votePartyVotesRequired = 0;
|
||||
|
||||
@ConfigDataKeys(path = "WeeklyAwards")
|
||||
@Getter
|
||||
private Set<String> weeklyPossibleRewardPlaces = new HashSet<>();
|
||||
|
||||
@ConfigDataBoolean(path = "NameMCLikeReward.Enabled")
|
||||
@Getter
|
||||
private boolean nameMCLikeRewardEnabled = false;
|
||||
|
||||
@ConfigDataString(path = "NameMCLikeReward.Url")
|
||||
@Getter
|
||||
private String nameMCLikeRewardUrl = "";
|
||||
|
||||
@ConfigDataInt(path = "NameMCLikeReward.CheckIntervalMinutes")
|
||||
@Getter
|
||||
private int nameMCLikeRewardCheckIntervalMinutes = 10;
|
||||
|
||||
@Getter
|
||||
private final String nameMCLikeRewardPath = "NameMCLikeReward.Rewards";
|
||||
|
||||
/**
|
||||
* Constructs a new SpecialRewardsConfig.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public SpecialRewardsConfig(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "SpecialRewards.yml"));
|
||||
setIgnoreCase(plugin.getConfigFile().isCaseInsensitiveYMLFiles());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards path for a daily award.
|
||||
*
|
||||
* @param path the award path
|
||||
* @return the daily award rewards path
|
||||
*/
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards path for a monthly award.
|
||||
*
|
||||
* @param path the award path
|
||||
* @return the monthly award rewards path
|
||||
*/
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
* @return the monthly possible reward places
|
||||
*/
|
||||
public Set<String> getMonthlyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("MonthlyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the increase votes required with the old typo field.
|
||||
*
|
||||
* @return the increase votes required
|
||||
* @deprecated Use getVotePartyIncreaseVotesRequired instead
|
||||
*/
|
||||
public int getVotePartyIncreaseVotesRequiredWithTypo() {
|
||||
int increase = getVotePartyIncreaseVotesRequired();
|
||||
if (increase > 0) {
|
||||
return increase;
|
||||
}
|
||||
return getVotePartyIncreaseVotesRquired();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a vote streak reward is enabled.
|
||||
*
|
||||
* @param type the streak type
|
||||
* @param s the streak value
|
||||
* @return true if enabled
|
||||
*/
|
||||
public boolean getVoteStreakRewardEnabled(String type, String s) {
|
||||
return getData().getBoolean("VoteStreak." + type + "." + s + ".Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards path for a vote streak.
|
||||
*
|
||||
* @param type the streak type
|
||||
* @param string the streak value
|
||||
* @return the vote streak rewards path
|
||||
*/
|
||||
public String getVoteStreakRewardsPath(String type, String string) {
|
||||
return "VoteStreak." + type + "." + string + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all vote streak values for a type.
|
||||
*
|
||||
* @param type the streak type
|
||||
* @return the set of vote streak values
|
||||
*/
|
||||
public Set<String> getVoteStreakVotes(String type) {
|
||||
try {
|
||||
Set<String> set = getData().getConfigurationSection("VoteStreak." + type).getKeys(false);
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
return new HashSet<>();
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards path for a weekly award.
|
||||
*
|
||||
* @param path the award path
|
||||
* @return the weekly award rewards path
|
||||
*/
|
||||
public String getWeeklyAwardRewardsPath(String path) {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("SpecialRewards.yml", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a vote milestone.
|
||||
*
|
||||
* @param votes the milestone votes value
|
||||
*/
|
||||
public void removeVoteMilestone(String votes) {
|
||||
getData().set("VoteMilestones." + votes, null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a vote milestone with default values.
|
||||
*
|
||||
* @param intValue the milestone votes value
|
||||
*/
|
||||
public void setVoteMilestone(int intValue) {
|
||||
getData().set("VoteMilestones." + intValue + ".Enabled", true);
|
||||
getData().set("VoteMilestones." + intValue + ".Rewards.Messages.Player",
|
||||
"&aYou got %milestone% milestone votes!");
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -1,435 +0,0 @@
|
||||
package com.bencodez.votingplugin.cooldown;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserDataFetchMode;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.NextSite;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Manages cooldown checks for vote rewards.
|
||||
*/
|
||||
public class CoolDownCheck implements Listener {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
|
||||
private final Map<UUID, ScheduledFuture<?>> perSiteTasks = new ConcurrentHashMap<>();
|
||||
private final Map<UUID, ScheduledFuture<?>> allSiteTasks = new ConcurrentHashMap<>();
|
||||
|
||||
@Getter
|
||||
private final ScheduledExecutorService timer;
|
||||
|
||||
private volatile boolean cooldownCheckEnabled = false;
|
||||
|
||||
/**
|
||||
* Constructs a new cooldown check manager.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
*/
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
// Better behavior when you cancel+reschedule a lot (removes cancelled tasks from queue)
|
||||
ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
|
||||
exec.setRemoveOnCancelPolicy(true);
|
||||
this.timer = exec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the cooldown for a player by UUID.
|
||||
*
|
||||
* @param uuid the player UUID
|
||||
*/
|
||||
public void check(UUID uuid) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.userDataFetechMode(UserDataFetchMode.NO_CACHE);
|
||||
}
|
||||
check(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the cooldown check timer.
|
||||
*/
|
||||
public void shutdown() {
|
||||
timer.shutdownNow();
|
||||
|
||||
for (ScheduledFuture<?> f : perSiteTasks.values()) {
|
||||
if (f != null) {
|
||||
f.cancel(false);
|
||||
}
|
||||
}
|
||||
for (ScheduledFuture<?> f : allSiteTasks.values()) {
|
||||
if (f != null) {
|
||||
f.cancel(false);
|
||||
}
|
||||
}
|
||||
|
||||
perSiteTasks.clear();
|
||||
allSiteTasks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the cooldown for a user.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public synchronized void check(VotingPluginUser user) {
|
||||
if (!user.getCoolDownCheck()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.canVoteAll()) {
|
||||
user.setCoolDownCheck(false);
|
||||
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
ScheduledFuture<?> f = allSiteTasks.remove(user.getJavaUUID());
|
||||
if (f != null) {
|
||||
f.cancel(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep per-site scheduling going while waiting for "all sites available"
|
||||
schedulePerSite(user, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check ONLY a specific votesite for all users (uses streaming keys/cols).
|
||||
*
|
||||
* @param site the vote site to check
|
||||
*/
|
||||
public void checkAllVoteSite(VoteSite site) {
|
||||
if (site == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Checking vote cooldown rewards for all players: " + site.getKey());
|
||||
|
||||
plugin.getUserManager().forEachUserKeys((uuid, cols) -> {
|
||||
if (!plugin.isEnabled() || uuid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid, false);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.userDataFetechMode(UserDataFetchMode.TEMP_ONLY);
|
||||
|
||||
try {
|
||||
if (cols != null) {
|
||||
user.updateTempCacheWithColumns(cols);
|
||||
cols.clear(); // help GC (only useful if reused)
|
||||
}
|
||||
|
||||
checkPerSite(site, user);
|
||||
} finally {
|
||||
user.clearTempCache();
|
||||
}
|
||||
}, (count) -> plugin.getLogger().info("Finished checking vote cooldown rewards for all players: " + site.getKey()
|
||||
+ " (processed: " + count + ")"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if cooldown check is enabled.
|
||||
*/
|
||||
public void checkEnabled() {
|
||||
cooldownCheckEnabled = !plugin.getConfigFile().isDisableCoolDownCheck()
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks per-site cooldown for a player by UUID.
|
||||
*
|
||||
* @param uuid the player UUID
|
||||
*/
|
||||
public void checkPerSite(UUID uuid) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.userDataFetechMode(UserDataFetchMode.NO_CACHE);
|
||||
}
|
||||
checkPerSite(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks per-site cooldown for a user.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public synchronized void checkPerSite(VotingPluginUser user) {
|
||||
if (!plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
boolean changed = false;
|
||||
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (site == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Boolean.TRUE.equals(coolDownChecks.get(site.getKey()))) {
|
||||
if (user.canVoteSite(site)) {
|
||||
coolDownChecks.put(site.getKey(), Boolean.TRUE);
|
||||
changed = true;
|
||||
|
||||
plugin.extraDebug("Triggering votesitecooldownend event for " + user.getUUID());
|
||||
PlayerVoteSiteCoolDownEndEvent event = new PlayerVoteSiteCoolDownEndEvent(user, site);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
user.setCoolDownCheckSite(coolDownChecks);
|
||||
}
|
||||
|
||||
schedulePerSite(user, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Site-specific version used by batch checks / checkAllVoteSite.
|
||||
*/
|
||||
private void checkPerSite(VoteSite site, VotingPluginUser user) {
|
||||
if (!plugin.getConfigFile().isPerSiteCoolDownEvents() || site == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
if (Boolean.TRUE.equals(coolDownChecks.get(site.getKey()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.canVoteSite(site)) {
|
||||
coolDownChecks.put(site.getKey(), Boolean.TRUE);
|
||||
user.setCoolDownCheckSite(coolDownChecks);
|
||||
|
||||
plugin.extraDebug(
|
||||
"Triggering votesitecooldownend event on site " + site.getKey() + " for " + user.getUUID());
|
||||
PlayerVoteSiteCoolDownEndEvent event = new PlayerVoteSiteCoolDownEndEvent(user, site);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the cooldown check system.
|
||||
*/
|
||||
public void load() {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
checkAllVoteSites();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the cooldown end event.
|
||||
*
|
||||
* @param event the cooldown end event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward", new RewardOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the per-site cooldown end event.
|
||||
*
|
||||
* @param event the per-site cooldown end event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
|
||||
new RewardOptions().addPlaceholder("sitename", event.getSite().getDisplayName())
|
||||
.addPlaceholder("url", event.getSite().getVoteURL(false)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a cooldown check for a user.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
* @param force whether to force the schedule
|
||||
*/
|
||||
public void schedule(VotingPluginUser user, boolean force) {
|
||||
if (user.getSitesVotedOn() <= 0 && !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID uuid = user.getJavaUUID();
|
||||
final long time = user.getNextTimeAllSitesAvailable();
|
||||
|
||||
allSiteTasks.compute(uuid, (k, existing) -> {
|
||||
if (existing != null) {
|
||||
existing.cancel(false);
|
||||
}
|
||||
|
||||
if (time <= 0) {
|
||||
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling cooldown check");
|
||||
return null; // remove entry
|
||||
}
|
||||
|
||||
user.setCoolDownCheck(true);
|
||||
|
||||
return timer.schedule(() -> {
|
||||
if (plugin.isEnabled()) {
|
||||
check(uuid);
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules per-site cooldown checks for a user.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
* @param force whether to force the schedule
|
||||
*/
|
||||
public void schedulePerSite(VotingPluginUser user, boolean force) {
|
||||
if (!plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.getSitesVotedOn() <= 0 && !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID uuid = user.getJavaUUID();
|
||||
|
||||
final NextSite next = user.getNextSiteAvailable();
|
||||
|
||||
perSiteTasks.compute(uuid, (k, existing) -> {
|
||||
if (existing != null) {
|
||||
existing.cancel(false);
|
||||
}
|
||||
|
||||
if (next == null || next.getSite() == null || next.getSecondsUntilAvailable() <= 0) {
|
||||
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling per-site cooldown check");
|
||||
return null; // remove entry
|
||||
}
|
||||
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule: site=" + next.getSite().getKey() + " time="
|
||||
+ next.getSecondsUntilAvailable() + " seconds");
|
||||
|
||||
return timer.schedule(() -> {
|
||||
if (!plugin.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only check the next site; this will set the cooldown-end flag + fire event if ready
|
||||
checkPerSite(next.getSite(), user);
|
||||
|
||||
// Schedule the following site (if any)
|
||||
schedulePerSite(user, false);
|
||||
|
||||
}, next.getSecondsUntilAvailable() + 2, TimeUnit.SECONDS);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a vote event for cooldown scheduling.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
* @param site the vote site
|
||||
*/
|
||||
public void vote(VotingPluginUser user, VoteSite site) {
|
||||
if (cooldownCheckEnabled) {
|
||||
schedule(user, true);
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performance-optimized: scan users ONCE, process all daily-delay sites.
|
||||
*/
|
||||
public void checkAllVoteSites() {
|
||||
final List<VoteSite> sites = plugin.getVoteSiteManager().getVoteSites();
|
||||
if (sites == null || sites.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ArrayList<VoteSite> dailySites = new ArrayList<>();
|
||||
for (int i = 0; i < sites.size(); i++) {
|
||||
VoteSite site = sites.get(i);
|
||||
if (site != null && site.isVoteDelayDaily()) {
|
||||
dailySites.add(site);
|
||||
}
|
||||
}
|
||||
|
||||
if (dailySites.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug("Checking vote cooldown rewards for all players across " + dailySites.size() + " sites...");
|
||||
|
||||
plugin.getUserManager().forEachUserKeys((uuid, cols) -> {
|
||||
if (!plugin.isEnabled() || uuid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid, false);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.userDataFetechMode(UserDataFetchMode.TEMP_ONLY);
|
||||
|
||||
try {
|
||||
if (cols != null) {
|
||||
user.updateTempCacheWithColumns(cols);
|
||||
cols.clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < dailySites.size(); i++) {
|
||||
checkPerSite(dailySites.get(i), user);
|
||||
}
|
||||
|
||||
check(user);
|
||||
} finally {
|
||||
user.clearTempCache();
|
||||
}
|
||||
}, (count) -> plugin.debug("Finished checking vote cooldown rewards (processed: " + count + " users)"));
|
||||
}
|
||||
}
|
||||
@@ -1,560 +0,0 @@
|
||||
package com.bencodez.votingplugin.data;
|
||||
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ServerData.
|
||||
*/
|
||||
public class ServerData {
|
||||
|
||||
private VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/**
|
||||
* Constructs a new ServerData.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public ServerData(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an auto-cached placeholder.
|
||||
*
|
||||
* @param placeholder the placeholder to add
|
||||
*/
|
||||
public void addAutoCachedPlaceholder(String placeholder) {
|
||||
List<String> p = getAutoCachedPlaceholder();
|
||||
|
||||
if (!ArrayUtils.containsIgnoreCase(p, placeholder)) {
|
||||
p.add(placeholder);
|
||||
setAutoCachedPlaceholder(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a service site to the list.
|
||||
*
|
||||
* @param site the service site to add
|
||||
*/
|
||||
public synchronized void addServiceSite(String site) {
|
||||
ArrayList<String> l = getServiceSites();
|
||||
if (!getServiceSites().contains(site)) {
|
||||
l.add(site);
|
||||
}
|
||||
setServiceSites(ArrayUtils.removeDuplicates(l));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the sign.
|
||||
*
|
||||
* @param location the location
|
||||
* @param data the data
|
||||
* @param position the position
|
||||
*/
|
||||
public void addSign(Location location, String data, int position) {
|
||||
|
||||
int count = nextSignNumber();
|
||||
|
||||
getData().set("Signs." + count + ".World", location.getWorld().getName());
|
||||
getData().set("Signs." + count + ".X", location.getBlockX());
|
||||
getData().set("Signs." + count + ".Y", location.getBlockY());
|
||||
getData().set("Signs." + count + ".Z", location.getBlockZ());
|
||||
getData().set("Signs." + count + ".Data", data);
|
||||
getData().set("Signs." + count + ".Position", position);
|
||||
saveData();
|
||||
plugin.getSigns().getSigns().add(new SignHandler(plugin, "" + count, getSignLocation("" + count),
|
||||
getSignSkullLocation("" + count), getSignData("" + count), getSignPosition("" + count)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a timed vote to the cache.
|
||||
*
|
||||
* @param num the vote number
|
||||
* @param vote the vote time queue entry
|
||||
*/
|
||||
public void addTimeVoted(int num, VoteTimeQueue vote) {
|
||||
getData().set("TimedVoteCache." + num + ".Name", vote.getName());
|
||||
getData().set("TimedVoteCache." + num + ".Service", vote.getService());
|
||||
getData().set("TimedVoteCache." + num + ".Time", vote.getTime());
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a vote shop purchase for the specified identifier.
|
||||
*
|
||||
* @param ident the vote shop identifier
|
||||
*/
|
||||
public void addVoteShopPurchase(String ident) {
|
||||
setVoteShopPurchases(ident, (getVoteShopPurchases(ident) + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the timed vote cache.
|
||||
*/
|
||||
public void clearTimedVoteCache() {
|
||||
getData().set("TimedVoteCache", null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the auto cached placeholders.
|
||||
*
|
||||
* @return the auto cached placeholder list
|
||||
*/
|
||||
public List<String> getAutoCachedPlaceholder() {
|
||||
return getData().getStringList("AutoCachePlaceholders");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current bungee vote party count.
|
||||
*
|
||||
* @return the bungee vote party current count
|
||||
*/
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the required votes for bungee vote party.
|
||||
*
|
||||
* @return the bungee vote party required votes
|
||||
*/
|
||||
public int getBungeeVotePartyRequired() {
|
||||
return getData().getInt("BungeeVotePartyRequired");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public ConfigurationSection getData() {
|
||||
ConfigurationSection data = plugin.getServerDataFile().getData().getConfigurationSection("VotingPlugin");
|
||||
if (data == null) {
|
||||
plugin.getServerDataFile().getData().createSection("VotingPlugin");
|
||||
data = plugin.getServerDataFile().getData().getConfigurationSection("VotingPlugin");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of disabled reminders.
|
||||
*
|
||||
* @return the disabled reminders
|
||||
*/
|
||||
public List<String> getDisabledReminders() {
|
||||
return getData().getStringList("DisabledReminders");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service sites list.
|
||||
*
|
||||
* @return the service sites
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getServiceSites() {
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign data.
|
||||
*
|
||||
* @param sign the sign
|
||||
* @return the sign data
|
||||
*/
|
||||
public String getSignData(String sign) {
|
||||
return getData().getString("Signs." + sign + ".Data");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign location.
|
||||
*
|
||||
* @param sign the sign
|
||||
* @return the sign location
|
||||
*/
|
||||
public Location getSignLocation(String sign) {
|
||||
return new Location(Bukkit.getWorld(getData().getString("Signs." + sign + ".World")),
|
||||
getData().getDouble("Signs." + sign + ".X"), getData().getDouble("Signs." + sign + ".Y"),
|
||||
getData().getDouble("Signs." + sign + ".Z"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign position.
|
||||
*
|
||||
* @param sign the sign
|
||||
* @return the sign position
|
||||
*/
|
||||
public int getSignPosition(String sign) {
|
||||
return getData().getInt("Signs." + sign + ".Position");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the signs.
|
||||
*
|
||||
* @return the signs
|
||||
*/
|
||||
public Set<String> getSigns() {
|
||||
try {
|
||||
return getData().getConfigurationSection("Signs").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign location.
|
||||
*
|
||||
* @param sign the sign
|
||||
* @return the sign location
|
||||
*/
|
||||
public Location getSignSkullLocation(String sign) {
|
||||
if (getData().getString("Signs." + sign + ".Skull.World", "").isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new Location(Bukkit.getWorld(getData().getString("Signs." + sign + ".Skull.World")),
|
||||
getData().getDouble("Signs." + sign + ".Skull.X"), getData().getDouble("Signs." + sign + ".Skull.Y"),
|
||||
getData().getDouble("Signs." + sign + ".Skull.Z"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the timed vote cache keys.
|
||||
*
|
||||
* @return the timed vote cache keys
|
||||
*/
|
||||
public Set<String> getTimedVoteCacheKeys() {
|
||||
if (getData().isConfigurationSection("TimedVoteCache")) {
|
||||
return getData().getConfigurationSection("TimedVoteCache").getKeys(false);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the timed vote cache section for the given number.
|
||||
*
|
||||
* @param num the cache entry number
|
||||
* @return the timed vote cache section
|
||||
*/
|
||||
public ConfigurationSection getTimedVoteCacheSection(String num) {
|
||||
return getData().getConfigurationSection("TimedVoteCache." + num);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extra required votes for vote party.
|
||||
*
|
||||
* @return the vote party extra required votes
|
||||
*/
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of purchases for a vote shop item.
|
||||
*
|
||||
* @param ident the vote shop identifier
|
||||
* @return the vote shop purchases
|
||||
*/
|
||||
public int getVoteShopPurchases(String ident) {
|
||||
return getData().getInt("VoteShopPurchases." + ident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the last vote party was on the same day.
|
||||
*
|
||||
* @return true if same day
|
||||
*/
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num == plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the last vote party was in the same week.
|
||||
*
|
||||
* @return true if same week
|
||||
*/
|
||||
public boolean isLastVotePartySameWeek() {
|
||||
int num = getData().getInt("LastVotePartyWeek", -1);
|
||||
if (num == plugin.getTimeChecker().getTime().get(WeekFields.of(Locale.getDefault()).weekOfYear())
|
||||
&& num != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the vote shop has been converted.
|
||||
*
|
||||
* @return true if converted
|
||||
*/
|
||||
public boolean isVoteShopConverted() {
|
||||
return getData().getBoolean("VoteShopConverted");
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
* @return the int
|
||||
*/
|
||||
public int nextSignNumber() {
|
||||
Set<String> signs = getSigns();
|
||||
|
||||
if (signs != null) {
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
if (!signs.contains(Integer.toString(i))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload data.
|
||||
*/
|
||||
public void reloadData() {
|
||||
plugin.getServerDataFile().reloadData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Discord message ID for the top voter.
|
||||
*
|
||||
* @param top the top voter type
|
||||
* @return the top voter message ID
|
||||
*/
|
||||
public long getTopVoterMessageId(TopVoter top) {
|
||||
return getData().getLong("DiscordSRV.TopVoterMessageId." + top.toString(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Discord message ID for the top voter.
|
||||
*
|
||||
* @param top the top voter type
|
||||
* @param messageId the message ID
|
||||
*/
|
||||
public void setTopVoterMessageId(TopVoter top, long messageId) {
|
||||
getData().set("DiscordSRV.TopVoterMessageId." + top.toString(), messageId);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*
|
||||
* @param sign the sign
|
||||
*/
|
||||
public void removeSign(String sign) {
|
||||
getData().set("Signs." + sign + ".World", null);
|
||||
getData().set("Signs." + sign + ".X", null);
|
||||
getData().set("Signs." + sign + ".Y", null);
|
||||
getData().set("Signs." + sign + ".Z", null);
|
||||
getData().set("Signs." + sign + ".Data", null);
|
||||
getData().set("Signs." + sign + ".Position", null);
|
||||
getData().set("Signs." + sign, null);
|
||||
getData().set("Signs." + sign + ".Skull.World", null);
|
||||
getData().set("Signs." + sign + ".Skull.X", null);
|
||||
getData().set("Signs." + sign + ".Skull.Y", null);
|
||||
getData().set("Signs." + sign + ".Skull.Z", null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save data.
|
||||
*/
|
||||
public synchronized void saveData() {
|
||||
plugin.getServerDataFile().saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the disabled reminders list.
|
||||
*
|
||||
* @param disabledReminders the list of UUIDs with disabled reminders
|
||||
*/
|
||||
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
|
||||
ArrayList<String> uuids = new ArrayList<>();
|
||||
for (UUID uuid : disabledReminders) {
|
||||
uuids.add(uuid.toString());
|
||||
}
|
||||
getData().set("DisabledReminders", uuids);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the auto cached placeholders.
|
||||
*
|
||||
* @param placeholders the list of placeholders
|
||||
*/
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current bungee vote party count.
|
||||
*
|
||||
* @param current the current vote count
|
||||
*/
|
||||
public void setBungeeVotePartyCurrent(int current) {
|
||||
getData().set("BungeeVotePartyCurrent", current);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the required votes for bungee vote party.
|
||||
*
|
||||
* @param required the required vote count
|
||||
*/
|
||||
public void setBungeeVotePartyRequired(int required) {
|
||||
getData().set("BungeeVotePartyRequired", required);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the service sites list.
|
||||
*
|
||||
* @param list the service sites list
|
||||
*/
|
||||
public void setServiceSites(ArrayList<String> list) {
|
||||
getData().set("ServiceSites", list);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote shop converted status.
|
||||
*
|
||||
* @param value the converted status
|
||||
*/
|
||||
public void setShopConverted(boolean value) {
|
||||
getData().set("VoteShopConverted", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets sign data.
|
||||
*
|
||||
* @param count the sign count
|
||||
* @param location the sign location
|
||||
* @param skullLocation the skull location
|
||||
* @param data the sign data
|
||||
* @param position the sign position
|
||||
*/
|
||||
public void setSign(String count, Location location, Location skullLocation, String data, int position) {
|
||||
|
||||
getData().set("Signs." + count + ".World", location.getWorld().getName());
|
||||
getData().set("Signs." + count + ".X", (int) location.getX());
|
||||
getData().set("Signs." + count + ".Y", (int) location.getY());
|
||||
getData().set("Signs." + count + ".Z", (int) location.getZ());
|
||||
getData().set("Signs." + count + ".Data", data);
|
||||
getData().set("Signs." + count + ".Position", position);
|
||||
if (skullLocation != null) {
|
||||
getData().set("Signs." + count + ".Skull.World", skullLocation.getWorld().getName());
|
||||
getData().set("Signs." + count + ".Skull.X", (int) skullLocation.getX());
|
||||
getData().set("Signs." + count + ".Skull.Y", (int) skullLocation.getY());
|
||||
getData().set("Signs." + count + ".Skull.Z", (int) skullLocation.getZ());
|
||||
}
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the skull location for a sign.
|
||||
*
|
||||
* @param count the sign count
|
||||
* @param skullLocation the skull location
|
||||
*/
|
||||
public void setSkullLocation(String count, Location skullLocation) {
|
||||
if (skullLocation != null) {
|
||||
getData().set("Signs." + count + ".Skull.World", skullLocation.getWorld().getName());
|
||||
getData().set("Signs." + count + ".Skull.X", (int) skullLocation.getX());
|
||||
getData().set("Signs." + count + ".Skull.Y", (int) skullLocation.getY());
|
||||
getData().set("Signs." + count + ".Skull.Z", (int) skullLocation.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version.
|
||||
*/
|
||||
public void setVersion() {
|
||||
getData().set("Version", Bukkit.getVersion());
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the extra required votes for vote party.
|
||||
*
|
||||
* @param value the extra required votes
|
||||
*/
|
||||
public void setVotePartyExtraRequired(int value) {
|
||||
getData().set("VotePartyExtraRequired", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of purchases for a vote shop item.
|
||||
*
|
||||
* @param ident the vote shop identifier
|
||||
* @param amount the purchase amount
|
||||
*/
|
||||
public void setVoteShopPurchases(String ident, int amount) {
|
||||
getData().set("VoteShopPurchases." + ident, amount);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the last vote party timestamp to today.
|
||||
*/
|
||||
public void updateLastVoteParty() {
|
||||
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the last vote party week timestamp to this week.
|
||||
*/
|
||||
public void updateLastVotePartyWeek() {
|
||||
getData().set("LastVotePartyWeek",
|
||||
plugin.getTimeChecker().getTime().get(WeekFields.of(Locale.getDefault()).weekOfYear()));
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates placeholders to lowercase format.
|
||||
*/
|
||||
public void updatePlaceholders() {
|
||||
boolean data = getData().getBoolean("AutoCacheUpdated", false);
|
||||
if (!data) {
|
||||
List<String> placeholders = getAutoCachedPlaceholder();
|
||||
for (int i = 0; i < placeholders.size(); i++) {
|
||||
placeholders.set(i, placeholders.get(i).toLowerCase());
|
||||
}
|
||||
setAutoCachedPlaceholder(placeholders);
|
||||
getData().set("AutoCacheUpdated", true);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
}
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
package com.bencodez.votingplugin.discord;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
import github.scarsz.discordsrv.api.events.DiscordReadyEvent;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.EmbedBuilder;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.JDA;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Handler for Discord integration.
|
||||
*/
|
||||
public class DiscordHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
@Getter
|
||||
private final HashMap<TopVoter, Long> topVoterMessageIds = new HashMap<TopVoter, Long>();
|
||||
private final AtomicBoolean discordReady = new AtomicBoolean(false);
|
||||
|
||||
/**
|
||||
* Constructs a new Discord handler.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
*/
|
||||
public DiscordHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
long savedId = plugin.getServerData().getTopVoterMessageId(top);
|
||||
topVoterMessageIds.put(top, savedId);
|
||||
}
|
||||
}
|
||||
|
||||
/** Call this early, e.g. from onEnable() in main plugin class */
|
||||
public void load() {
|
||||
DiscordSRV.api.subscribe(this);
|
||||
plugin.getLogger().info("DiscordHandler loaded; awaiting Discord readiness.");
|
||||
|
||||
// if DiscordSRV is already up and running, mark it ready now
|
||||
if (DiscordUtil.getJda().getStatus() == JDA.Status.CONNECTED) {
|
||||
discordReady.set(true);
|
||||
plugin.getLogger().info("DiscordSRV was already ready; manual update now available.");
|
||||
}
|
||||
|
||||
plugin.getRewardHandler().addInjectedReward(new RewardInjectConfigurationSection("DiscordSRV") {
|
||||
|
||||
@Override
|
||||
public String onRewardRequested(Reward arg0, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
|
||||
ConfigurationSection section, HashMap<String, String> placeholders) {
|
||||
if (section.getBoolean("Enabled")) {
|
||||
String msg = PlaceholderUtils
|
||||
.replacePlaceHolder(section.getString("Message", "Please set a message"), placeholders);
|
||||
msg = PlaceholderUtils.replacePlaceHolders(user.getOfflinePlayer(), msg);
|
||||
sendRewardMessage(msg, section.getString("ChannelID", "0"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser user) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostFinish() {
|
||||
|
||||
plugin.getTimer().scheduleAtFixedRate(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
updateDiscordLeaderboard();
|
||||
}
|
||||
}, 130, 60 * 60, TimeUnit.SECONDS); // 10-minute interval
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired once JDA is fully initialized.
|
||||
*
|
||||
* @param event the Discord ready event
|
||||
*/
|
||||
@Subscribe
|
||||
public void onDiscordReady(DiscordReadyEvent event) {
|
||||
discordReady.set(true);
|
||||
plugin.getLogger().info("DiscordSRV is ready; manual update now available.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Public method to update the Top Voter message on demand. Checks Discord
|
||||
* readiness internally.
|
||||
*/
|
||||
public void updateDiscordLeaderboard() {
|
||||
if (!discordReady.get()) {
|
||||
plugin.getLogger().warning("DiscordSRV not ready yet; cannot update Top Voters.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
if (plugin.getConfigFile().isDiscordSRVTopVoterEnabled(top)) {
|
||||
plugin.debug("Updating Discord Top Voter: " + top.toString());
|
||||
updateTopVoterMessageId(top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the top voter message ID for the specified top voter.
|
||||
*
|
||||
* @param top the top voter
|
||||
*/
|
||||
public void updateTopVoterMessageId(TopVoter top) {
|
||||
plugin.extraDebug("Updating Discord Top Voter message for: " + top);
|
||||
|
||||
long channelId = plugin.getConfigFile().getDiscordSRVTopVoterChannel(top);
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topVoters = plugin.getTopVoter(top);
|
||||
|
||||
String title = plugin.getConfigFile().getDiscordSRVTopVoterTitle(top);
|
||||
boolean newMessage = plugin.getConfigFile().isDiscordSRVTopVoterNewMessageOnUpdate(top);
|
||||
|
||||
EmbedBuilder eb = new EmbedBuilder().setTitle(title).setColor(Color.CYAN).setTimestamp(Instant.now());
|
||||
|
||||
if (topVoters == null || topVoters.isEmpty()) {
|
||||
eb.setDescription("No votes recorded yet.");
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("```");
|
||||
int rank = 1;
|
||||
|
||||
for (Entry<TopVoterPlayer, Integer> entry : topVoters.entrySet()) {
|
||||
if (rank > 10)
|
||||
break;
|
||||
|
||||
String prefix = rank <= 3 ? new String[] { "🥇", "🥈", "🥉" }[rank - 1] : rank + ".";
|
||||
|
||||
String player = entry.getKey().getPlayerName();
|
||||
int votes = entry.getValue();
|
||||
|
||||
// simple alignment: trim long names, pad to 16 chars
|
||||
if (player.length() > 16)
|
||||
player = player.substring(0, 16);
|
||||
|
||||
sb.append(String.format("%-3s %-16s %4d votes%n", prefix, player, votes));
|
||||
rank++;
|
||||
}
|
||||
sb.append("```");
|
||||
|
||||
eb.setDescription(sb.toString()).setFooter("Top 10 • Updated");
|
||||
}
|
||||
|
||||
TextChannel channel = DiscordUtil.getJda().getTextChannelById(channelId);
|
||||
if (channel == null) {
|
||||
plugin.getLogger().warning("Discord channel ID " + channelId + " not found: " + top);
|
||||
return;
|
||||
}
|
||||
|
||||
long existingId = topVoterMessageIds.getOrDefault(top, 0L);
|
||||
|
||||
if (existingId <= 0 || newMessage) {
|
||||
channel.sendMessageEmbeds(eb.build()).queue(msg -> {
|
||||
long newId = msg.getIdLong();
|
||||
topVoterMessageIds.put(top, newId);
|
||||
if (!newMessage)
|
||||
plugin.getServerData().setTopVoterMessageId(top, newId);
|
||||
plugin.debug("Posted new Top Voters " + top + " (ID: " + newId + ")");
|
||||
}, err -> plugin.getLogger().warning("Error sending Top Voters " + top + ": " + err.getMessage()));
|
||||
} else {
|
||||
channel.editMessageEmbedsById(existingId, eb.build()).queue(
|
||||
m -> plugin.debug("Edited Top Voters " + top + " (ID: " + existingId + ")"),
|
||||
err -> plugin.getLogger().warning("Error editing Top Voters " + top + ": " + err.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a reward message to a Discord channel.
|
||||
*
|
||||
* @param message the message to send
|
||||
* @param channelId the Discord channel ID
|
||||
*/
|
||||
public void sendRewardMessage(String message, String channelId) {
|
||||
TextChannel channel = DiscordUtil.getJda().getTextChannelById(channelId);
|
||||
if (channel != null) {
|
||||
channel.sendMessage(message).queue();
|
||||
} else {
|
||||
plugin.getLogger().warning("Discord channel ID " + channelId + " not found for reward message.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.proxy.VoteTotalsSnapshot;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerPostVoteEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean bungee = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteTotalsSnapshot bungeeTextTotals;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean forceBungee = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser user;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean realVote = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long voteTime = 0;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cached;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String service;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private UUID uuid;
|
||||
@Getter
|
||||
@Setter
|
||||
private String playerName;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private UUID voteUUID;
|
||||
|
||||
/**
|
||||
* Constructs a new PlayerPostVoteEvent.
|
||||
*
|
||||
* @param voteSite the vote site
|
||||
* @param user the voting plugin user
|
||||
* @param realVote whether this is a real vote
|
||||
* @param forceBungee whether to force Bungee processing
|
||||
* @param voteTime the vote timestamp
|
||||
* @param cached whether the vote was cached
|
||||
* @param service the service name
|
||||
* @param uuid the player UUID
|
||||
* @param playerName the player name
|
||||
* @param voteUUID the vote UUID
|
||||
*/
|
||||
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee,
|
||||
long voteTime, boolean cached, String service, UUID uuid, String playerName, UUID voteUUID) {
|
||||
super(true);
|
||||
this.user = user;
|
||||
this.voteSite = voteSite;
|
||||
this.realVote = realVote;
|
||||
this.forceBungee = forceBungee;
|
||||
this.voteTime = voteTime;
|
||||
this.cached = cached;
|
||||
this.service = service;
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
this.voteUUID = voteUUID;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerReceivePointsEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int points;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
/**
|
||||
* Constructs a new PlayerReceivePointsEvent.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
* @param points the points received
|
||||
*/
|
||||
public PlayerReceivePointsEvent(VotingPluginUser user, int points) {
|
||||
super(true);
|
||||
this.player = user;
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerSpecialRewardEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private SpecialRewardType type;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser user;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private UUID voteUUID;
|
||||
|
||||
/**
|
||||
* Constructs a new PlayerSpecialRewardEvent.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
* @param type the special reward type
|
||||
* @param voteUUID the vote UUID
|
||||
*/
|
||||
public PlayerSpecialRewardEvent(VotingPluginUser user, SpecialRewardType type, UUID voteUUID) {
|
||||
super(true);
|
||||
this.type = type;
|
||||
this.user = user;
|
||||
this.voteUUID = voteUUID;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteCoolDownEndEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser player;
|
||||
|
||||
/**
|
||||
* Constructs a new PlayerVoteCoolDownEndEvent.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public PlayerVoteCoolDownEndEvent(VotingPluginUser user) {
|
||||
super(true);
|
||||
player = user;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.proxy.VoteTotalsSnapshot;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean bungee = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteTotalsSnapshot bungeeTextTotals;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean forceBungee = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean realVote = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long time;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean wasOnline;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean broadcast = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int voteNumber = 1;
|
||||
|
||||
/**
|
||||
* Constructs a new PlayerVoteEvent.
|
||||
*
|
||||
* @param voteSite the vote site
|
||||
* @param voteUsername the username of the voter
|
||||
* @param serviceSite the service site name
|
||||
* @param realVote whether this is a real vote
|
||||
*/
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
this.player = voteUsername;
|
||||
this.voteSite = voteSite;
|
||||
this.realVote = realVote;
|
||||
this.serviceSite = serviceSite;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteSiteCoolDownEndEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite site;
|
||||
|
||||
/**
|
||||
* Constructs a new PlayerVoteSiteCoolDownEndEvent.
|
||||
*
|
||||
* @param user the voting plugin user
|
||||
* @param site the vote site
|
||||
*/
|
||||
public PlayerVoteSiteCoolDownEndEvent(VotingPluginUser user, VoteSite site) {
|
||||
super(true);
|
||||
player = user;
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Enumeration for different special reward types.
|
||||
*/
|
||||
public enum SpecialRewardType {
|
||||
/** @deprecated All site reward. */
|
||||
@Deprecated
|
||||
ALLSITE,
|
||||
/** @deprecated Cumulative reward. */
|
||||
@Deprecated
|
||||
CUMMULATIVE,
|
||||
/** @deprecated First vote reward. */
|
||||
@Deprecated
|
||||
FIRSTVOTE,
|
||||
/** @deprecated First vote today reward. */
|
||||
@Deprecated
|
||||
FIRSTVOTETODAY,
|
||||
/** @deprecated Milestone reward. */
|
||||
@Deprecated
|
||||
MILESTONE,
|
||||
/** Vote streak reward. */
|
||||
VOTESTREAK,
|
||||
/** @deprecated Almost all sites reward. */
|
||||
@Deprecated
|
||||
ALMOSTALLSITES,
|
||||
/** Top voter reward. */
|
||||
TOPVOTER,
|
||||
/** Vote streaks reward. */
|
||||
VOTESTREAKS;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@Getter
|
||||
private String type = "";
|
||||
|
||||
/**
|
||||
* Sets the amount for this special reward.
|
||||
*
|
||||
* @param num the amount
|
||||
* @return this special reward type
|
||||
*/
|
||||
public SpecialRewardType setAmount(int num) {
|
||||
amount = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type for this special reward.
|
||||
*
|
||||
* @param type the type
|
||||
* @return this special reward type
|
||||
*/
|
||||
public SpecialRewardType setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(name());
|
||||
|
||||
if (amount >= 0) {
|
||||
sb.append("(amount=").append(amount);
|
||||
}
|
||||
|
||||
if (type != null && !type.isEmpty()) {
|
||||
if (amount >= 0) {
|
||||
sb.append(", ");
|
||||
} else {
|
||||
sb.append("(");
|
||||
}
|
||||
sb.append("type=").append(type).append(")");
|
||||
} else if (amount >= 0) {
|
||||
sb.append(")");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
-159
@@ -1,159 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.specialrewards.votemilestones.VoteMilestone;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Fired after a VoteMilestone reward has been executed successfully.
|
||||
*/
|
||||
public class VoteMilestoneRewardEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final VotingPluginUser user;
|
||||
private final UUID uuid;
|
||||
private final String playerName;
|
||||
|
||||
private final VoteMilestone milestone;
|
||||
private final long value;
|
||||
|
||||
private final String groupId;
|
||||
private final String rewardPath;
|
||||
@Getter
|
||||
private final UUID voteUUID;
|
||||
private final Map<String, String> placeholders;
|
||||
|
||||
/**
|
||||
* Constructs a new VoteMilestoneRewardEvent.
|
||||
*
|
||||
* @param user VotingPluginUser who received the reward
|
||||
* @param milestone milestone that triggered
|
||||
* @param value resolved total value used for matching
|
||||
* @param groupId resolved group id used for selection
|
||||
* @param rewardPath path used to execute rewards
|
||||
* @param placeholders placeholders passed to the reward handler
|
||||
* @param voteUUID UUID of the vote that triggered this reward (may be null)
|
||||
*/
|
||||
public VoteMilestoneRewardEvent(VotingPluginUser user, VoteMilestone milestone, long value, String groupId,
|
||||
String rewardPath, Map<String, String> placeholders, UUID voteUUID) {
|
||||
super(true);
|
||||
this.user = user;
|
||||
this.uuid = user == null ? null : user.getJavaUUID();
|
||||
this.playerName = user == null ? null : user.getPlayerName();
|
||||
this.milestone = milestone;
|
||||
this.value = value;
|
||||
this.groupId = groupId;
|
||||
this.rewardPath = rewardPath;
|
||||
this.voteUUID = voteUUID;
|
||||
if (placeholders == null || placeholders.isEmpty()) {
|
||||
this.placeholders = Collections.emptyMap();
|
||||
} else {
|
||||
this.placeholders = Collections.unmodifiableMap(new HashMap<>(placeholders));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the voting plugin user associated with this event.
|
||||
*
|
||||
* @return the voting plugin user
|
||||
*/
|
||||
public VotingPluginUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player UUID.
|
||||
*
|
||||
* @return the player UUID
|
||||
*/
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player name.
|
||||
*
|
||||
* @return the player name
|
||||
*/
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone that triggered this event.
|
||||
*
|
||||
* @return milestone instance
|
||||
*/
|
||||
public VoteMilestone getMilestone() {
|
||||
return milestone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone ID.
|
||||
*
|
||||
* @return milestone id string
|
||||
*/
|
||||
public String getMilestoneId() {
|
||||
return milestone == null ? null : milestone.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value that triggered the milestone.
|
||||
*
|
||||
* @return the milestone value
|
||||
*/
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the group ID used for selection.
|
||||
*
|
||||
* @return group id string
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration path for the rewards.
|
||||
*
|
||||
* @return the reward path
|
||||
*/
|
||||
public String getRewardPath() {
|
||||
return rewardPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the placeholders map for this milestone reward.
|
||||
*
|
||||
* @return map of placeholder names to values
|
||||
*/
|
||||
public Map<String, String> getPlaceholders() {
|
||||
return placeholders;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler list for this event.
|
||||
*
|
||||
* @return handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class VotePartyEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* Constructs a new VotePartyEvent.
|
||||
*/
|
||||
public VotePartyEvent() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Fired when a player attempts to purchase an item from VotingPlugin's
|
||||
* VoteShop.
|
||||
*/
|
||||
public class VoteShopPurchaseEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
@Getter
|
||||
private UUID playerUuid;
|
||||
@Getter
|
||||
private String playerName;
|
||||
@Getter
|
||||
private VotingPluginUser user;
|
||||
|
||||
@Getter
|
||||
private String identifier;
|
||||
|
||||
@Getter
|
||||
private int cost;
|
||||
|
||||
public VoteShopPurchaseEvent(UUID playerUUID, String playerName, VotingPluginUser user, String identifier,
|
||||
int cost) {
|
||||
super(true);
|
||||
this.playerName = playerName;
|
||||
this.user = user;
|
||||
this.playerUuid = playerUUID;
|
||||
this.identifier = identifier;
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class BlockBreak.
|
||||
*/
|
||||
public class BlockBreak implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new block break.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public BlockBreak(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On block break.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.getBlock().getState() instanceof Sign) {
|
||||
Sign s = (Sign) event.getBlock().getState();
|
||||
final Location loc = s.getLocation();
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
if (sign.getLocation().equals(loc)) {
|
||||
sign.removeSign();
|
||||
sign.setValid(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
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.player.PlayerInteractEvent;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.PlayerManager;
|
||||
import com.bencodez.simpleapi.player.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerInteract.
|
||||
*/
|
||||
public class PlayerInteract implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player interact.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public PlayerInteract(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On player interact.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (plugin.getConfigFile().isDisableInteractEvent()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSigns().getSigns().size() > 0) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
// plugin.debug("Checking for sign click");
|
||||
if (event.getClickedBlock().getState() instanceof Sign) {
|
||||
// plugin.debug(player.getName() + " right clicked a sign");
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
|
||||
// plugin.debug(player.getName() +
|
||||
// " right clicked a top voter sign, sending message");
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(player)
|
||||
.sendMessage(sign.getRightClickMessage());
|
||||
|
||||
if (!sign.isSkullSet()) {
|
||||
if (PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Sign.Create")
|
||||
|| PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Admin")) {
|
||||
player.sendMessage("Skull not set, click to set skull");
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "skullset", sign.getSign());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.getClickedBlock().getState() instanceof Skull) {
|
||||
Object ob = PlayerUtils.getPlayerMeta(plugin, player, "skullset");
|
||||
if (ob != null) {
|
||||
String sign1 = (String) ob;
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
if (sign.getSign().equals(sign1)) {
|
||||
sign.setSkullLocation(event.getClickedBlock().getLocation());
|
||||
sign.storeSign();
|
||||
sign.checkSkulls();
|
||||
player.sendMessage("Skull set");
|
||||
}
|
||||
}
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "skullset", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.bencodez.advancedcore.api.player.UuidLookup;
|
||||
import com.bencodez.advancedcore.api.user.UserDataFetchMode;
|
||||
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginWire;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private final VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player join event.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public PlayerJoinEvent(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private static boolean isBlank(String s) {
|
||||
return s == null || s.trim().isEmpty() || "null".equalsIgnoreCase(s.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* On AdvancedCore login event (post-auth / delayed login).
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(AdvancedCoreLoginEvent event) {
|
||||
if (event == null || !plugin.isMySQLOkay() || event.isCancelled() || event.getUser() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// UUID is authoritative here (String)
|
||||
String uuid = event.getUuid();
|
||||
if (isBlank(uuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// "Has data" should come from AdvancedCore event (storage presence)
|
||||
boolean hasData = event.isUserInStorage();
|
||||
|
||||
// Resolve VotingPluginUser by the storage UUID string (offline-mode
|
||||
// name-derived UUID)
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player != null && player.isOp() && plugin.isYmlError()) {
|
||||
user.sendMessage("&cVotingPlugin: Detected yml error, please check console for details");
|
||||
}
|
||||
|
||||
if (hasData) {
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
} else {
|
||||
plugin.debug("No data detected for " + user.getUUID() + "/" + user.getPlayerName());
|
||||
}
|
||||
|
||||
user.loginRewards();
|
||||
|
||||
plugin.getPlaceholders().onUpdate(user, true);
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage(VotingPluginWire.login(user.getPlayerName(),
|
||||
user.getUUID(), plugin.getBungeeSettings().getServer()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles player quit events.
|
||||
*
|
||||
* @param event the player quit event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (plugin == null || !plugin.isEnabled() || event == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLoginTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(player.getUniqueId());
|
||||
|
||||
// Use AdvancedCore UUIDLookup to derive the correct UUID (online/offline aware)
|
||||
String uuid = UuidLookup.getInstance().getUUID(player.getName());
|
||||
if (isBlank(uuid)) {
|
||||
// Fallback to online UUID if lookup fails
|
||||
uuid = player.getUniqueId().toString();
|
||||
}
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.userDataFetechMode(UserDataFetchMode.NO_CACHE);
|
||||
user.logoutRewards();
|
||||
plugin.getPlaceholders().onLogout(user);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
-285
@@ -1,285 +0,0 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.bedrock.BedrockNameResolver;
|
||||
import com.bencodez.advancedcore.api.user.validation.UserValidationResult;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerPostVoteEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VotiferEvent.
|
||||
*/
|
||||
public class PlayerVoteListener implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new votifer event.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public PlayerVoteListener(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On votifer event.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onplayerVote(PlayerVoteEvent event) {
|
||||
if (!plugin.isEnabled()) {
|
||||
plugin.getLogger().warning("Plugin disabled, ignoring vote");
|
||||
return;
|
||||
}
|
||||
String playerName = event.getPlayer();
|
||||
plugin.debug("Processing PlayerVoteEvent: " + playerName + "/" + event.getServiceSite());
|
||||
|
||||
// check for name casing
|
||||
final String properName = plugin.getUserManager().getProperName(playerName);
|
||||
|
||||
// Validate BEFORE full bedrock/db-backed resolution
|
||||
boolean allowUnJoinedCheckServer = plugin.getConfigFile().isAllowUnJoinedCheckServer();
|
||||
UserValidationResult validationResult = plugin.getUserManager().getValidationService().validate(properName,
|
||||
allowUnJoinedCheckServer);
|
||||
|
||||
plugin.extraDebug("Vote validation result for " + properName + ": valid=" + validationResult.isValid()
|
||||
+ ", source=" + validationResult.getSource() + ", reason=" + validationResult.getReason()
|
||||
+ ", normalizedName=" + validationResult.getNormalizedName() + ", bedrock="
|
||||
+ validationResult.isBedrock());
|
||||
|
||||
if (!validationResult.isValid() && !plugin.getConfigFile().isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + properName + " has not joined before, disregarding vote. "
|
||||
+ "Reason: " + validationResult.getReason() + ". Set AllowUnjoined to true to accept.");
|
||||
if (event.isBungee() && plugin.getBungeeSettings().isRemoveInvalidUsers()) {
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(properName).remove();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Resolve Bedrock/Java + add prefix only when appropriate AFTER validation
|
||||
BedrockNameResolver.Result rn = plugin.getBedrockHandle().resolve(properName);
|
||||
String creditedName = rn.finalName;
|
||||
|
||||
plugin.debug("Vote name resolved: " + properName + " -> " + creditedName + " (" + rn.rationale + ")");
|
||||
|
||||
// If we get here, use the resolved/possibly-prefixed name going forward
|
||||
playerName = creditedName;
|
||||
|
||||
if (playerName.isEmpty()) {
|
||||
plugin.getLogger().warning("Empty player name from vote, ignoring");
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isBungee()) {
|
||||
plugin.debug("BungeePlayerVote forcebungee: " + event.isForceBungee() + ", bungeetotals: "
|
||||
+ event.getBungeeTextTotals());
|
||||
|
||||
if (plugin.getBungeeSettings().isTriggerVotifierEvent()) {
|
||||
try {
|
||||
new ProxyVotifierEvent().send(plugin, event);
|
||||
} catch (NoClassDefFoundError ex) {
|
||||
plugin.getLogger().severe(
|
||||
"Failed to trigger Votifier event for proxy vote. Either install votiifer or disable tirgger votiifer event");
|
||||
plugin.getLogger().severe("Error: " + ex.getMessage());
|
||||
plugin.debug(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VoteSite voteSite = event.getVoteSite();
|
||||
|
||||
if (voteSite == null) {
|
||||
voteSite = plugin.getVoteSiteManager()
|
||||
.getVoteSite(plugin.getVoteSiteManager().getVoteSiteName(true, event.getServiceSite()), true);
|
||||
}
|
||||
|
||||
// check valid service sites
|
||||
if (voteSite == null) {
|
||||
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + event.getServiceSite() + "'");
|
||||
|
||||
ArrayList<String> services = new ArrayList<>();
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSites()) {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
plugin.getLogger().warning("Currently set service sites: " + ArrayUtils.makeStringList(services));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!voteSite.isEnabled()) {
|
||||
plugin.debug("Votesite: " + voteSite.getKey() + " is not enabled");
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser user = null;
|
||||
if (event.getVotingPluginUser() != null) {
|
||||
user = event.getVotingPluginUser();
|
||||
} else {
|
||||
Player p = Bukkit.getPlayerExact(playerName);
|
||||
if (p != null) {
|
||||
// player online
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
} else {
|
||||
// attempt to get exact name from cache matching casing
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
if (!event.isRealVote()) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " did a not real vote, bypassing WaitUntilVoteDelay");
|
||||
} else {
|
||||
if (!user.hasPermission("VotingPlugin.BypassWaitUntilVoteDelay")) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
return;
|
||||
}
|
||||
plugin.getLogger()
|
||||
.info(user.getPlayerName() + " has bypass permission for WaitUntilVoteDelay, bypassing");
|
||||
}
|
||||
}
|
||||
|
||||
UUID voteUUID = UUID.randomUUID();
|
||||
if (event.isBungee() && event.getBungeeTextTotals() != null) {
|
||||
voteUUID = event.getBungeeTextTotals().getVoteUUID();
|
||||
if (voteUUID == null) {
|
||||
voteUUID = UUID.randomUUID();
|
||||
}
|
||||
}
|
||||
|
||||
final String uuid = user.getUUID();
|
||||
|
||||
// reupdate cache
|
||||
user.cache();
|
||||
|
||||
user.updateName(true);
|
||||
|
||||
// vote party
|
||||
plugin.getVoteParty().vote(user, event.isRealVote(), event.isForceBungee());
|
||||
|
||||
if (event.isBroadcast()) {
|
||||
if (plugin.getBroadcastHandler() != null) {
|
||||
boolean online = user.isOnline();
|
||||
if (event.isBungee()) {
|
||||
online = event.isWasOnline();
|
||||
}
|
||||
if (!user.isVanished()) {
|
||||
plugin.getBroadcastHandler().broadcastVote(user.getJavaUUID(), playerName,
|
||||
voteSite.getDisplayName(), online);
|
||||
} else {
|
||||
plugin.debug("Not broadcasting vote for vanished user: " + user.getPlayerName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long voteTime = 0;
|
||||
// update last vote time
|
||||
if (event.getTime() != 0) {
|
||||
user.setTime(voteSite, event.getTime());
|
||||
voteTime = event.getTime();
|
||||
} else {
|
||||
user.setTime(voteSite);
|
||||
voteTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
}
|
||||
|
||||
boolean cached = false;
|
||||
// check if player has voted on all sites in one day
|
||||
if (((user.isOnline() || voteSite.isGiveOffline()) && plugin.getOptions().isProcessRewards())
|
||||
|| event.isBungee()) {
|
||||
boolean online = true;
|
||||
if (event.isBungee()) {
|
||||
online = event.isWasOnline();
|
||||
}
|
||||
user.playerVote(voteSite, online, event.isForceBungee());
|
||||
if (event.getVoteNumber() == 1) {
|
||||
user.sendVoteEffects(online);
|
||||
}
|
||||
if (plugin.getConfigFile().isCloseInventoryOnVote()) {
|
||||
user.closeInv();
|
||||
}
|
||||
} else {
|
||||
if (!plugin.getConfigFile().isOfflineVotesLimitEnabled()
|
||||
|| user.getNumberOfOfflineVotes(voteSite) <= plugin.getConfigFile().getOfflineVotesLimitAmount()) {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
cached = true;
|
||||
plugin.debug(
|
||||
"Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
|
||||
} else {
|
||||
plugin.debug("Not setting offline vote, offline vote limit reached");
|
||||
}
|
||||
}
|
||||
|
||||
// add to total votes
|
||||
if ((plugin.getConfigFile().isCountFakeVotes() || event.isRealVote()) && event.isAddTotals()) {
|
||||
if (plugin.getConfigFile().isAddTotals()) {
|
||||
if (plugin.getConfigFile().isAddTotalsOffline() || user.isOnline()) {
|
||||
user.addTotal();
|
||||
user.addTotalDaily();
|
||||
user.addTotalWeekly();
|
||||
}
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
user.checkDayVoteStreak(event.isForceBungee());
|
||||
|
||||
if (plugin.getConfigFile().isLimitMonthlyVotes()) {
|
||||
int value = 0;
|
||||
if (event.isBungee()) {
|
||||
value = event.getBungeeTextTotals().getMonthTotal();
|
||||
} else {
|
||||
value = user.getTotal(TopVoter.Monthly);
|
||||
}
|
||||
LocalDateTime cTime = plugin.getTimeChecker().getTime();
|
||||
int days = cTime.getDayOfMonth();
|
||||
plugin.extraDebug("Current day of month: " + days + " Current total: " + value);
|
||||
if (value >= days * plugin.getVoteSiteManager().getVoteSitesEnabled().size()) {
|
||||
plugin.debug("Detected higher month total, changing. Current Total: " + value + " Days: " + days
|
||||
+ " New Total: " + days * plugin.getVoteSiteManager().getVoteSitesEnabled().size());
|
||||
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSiteManager().getVoteSitesEnabled().size());
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getVoteMilestonesManager().handleVote(user, event.getBungeeTextTotals(), event.isForceBungee(), voteUUID,
|
||||
new HashMap<String, String>());
|
||||
|
||||
plugin.getCoolDownCheck().vote(user, voteSite);
|
||||
|
||||
plugin.getVoteStreakHandler().processVote(user, voteTime, voteUUID);
|
||||
|
||||
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
|
||||
event.isForceBungee(), voteTime, cached, voteSite.getServiceSite(), user.getJavaUUID(), playerName,
|
||||
voteUUID);
|
||||
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
|
||||
|
||||
if (user.isOnline() || plugin.getConfigFile().getPlaceholderCacheLevel().isCacheAlways()) {
|
||||
plugin.getPlaceholders().onUpdate(user, true);
|
||||
}
|
||||
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
plugin.setUpdate(true);
|
||||
|
||||
plugin.extraDebug("Finished vote processing: " + playerName + "/" + uuid);
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 914 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user