Compare commits

...
154 Commits
Author SHA1 Message Date
BenCodez c2fe26aaea Update version number to 6.18 2024-12-16 20:21:37 -06:00
BenCodez 2aa84c90e8 Adjustments to how previous months top voters are loaded 2024-12-16 17:34:47 -06:00
BenCodez c8cace388e Change command from previousmonthsvoters to previousmonthstotals 2024-12-16 16:29:38 -06:00
BenCodez 1da028476f Don't load command if month date isn't enabled 2024-12-14 16:50:05 -06:00
BenCodez c28bddd0ba Add previous month top voters GUI, uses Month totals with date 2024-12-13 12:43:15 -06:00
BenCodez 1afd8253a5 Add extra time change checks on login 2024-12-13 09:58:29 -06:00
BenCodez a3a1b4604f Add extra check for time queues on proxy 2024-12-13 09:46:28 -06:00
BenCodez 3bd41af200 Add extra checks on proxy time changes 2024-12-13 09:43:04 -06:00
BenCodez 0042045d9b Add bypass fail safe options for bungee time checking 2024-12-13 09:10:04 -06:00
BenCodez 76d7579c7d Update to 1.21.4 2024-12-09 21:24:43 -06:00
Ben f591b863f1 Merge pull request #1405 from BenCodez/dependabot/maven/VotingPlugin/com.coderplus.maven.plugins-copy-rename-maven-plugin-1.0.1
Bump com.coderplus.maven.plugins:copy-rename-maven-plugin from 1.0 to 1.0.1 in /VotingPlugin
2024-12-09 07:43:31 -06:00
dependabot[bot] b43c4b89a8 Bump com.coderplus.maven.plugins:copy-rename-maven-plugin
Bumps [com.coderplus.maven.plugins:copy-rename-maven-plugin](https://github.com/coderplus/copy-rename-maven-plugin) from 1.0 to 1.0.1.
- [Commits](https://github.com/coderplus/copy-rename-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.coderplus.maven.plugins:copy-rename-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-09 06:43:18 +00:00
BenCodez f9d7f5a136 Adjust default caching columns 2024-12-08 14:38:28 -06:00
BenCodez 338853a29f Fix issues with new month total date system 2024-12-08 14:34:54 -06:00
BenCodez 7d0722d5c4 Fix vote streak command not working for multiples 2024-12-08 12:37:52 -06:00
BenCodez 86e6bca31d Small adjustment to vote streaking handling 2024-12-08 12:21:12 -06:00
BenCodez 8488233be1 More work on new month date totals 2024-12-07 21:13:56 -06:00
BenCodez ba5f8dfa6d Implement month totals with dates on proxy servers 2024-12-07 17:56:50 -06:00
BenCodez dc865f1d20 First implementation of storing and using totals with month names 2024-12-07 16:03:19 -06:00
BenCodez 5dedb644b2 More adjustments to build numbers on jar files 2024-12-06 20:59:52 -06:00
BenCodez c041c7c33a Adjust maven profile 2024-12-06 20:55:55 -06:00
BenCodez bbc0c4a88e Implement first steps at including version number in jar name 2024-12-06 20:52:47 -06:00
BenCodez 4d200f6675 Change version number to 6.17.5-SNAPSHOT 2024-12-01 16:22:51 -06:00
BenCodez ad7970c99d Update version number to 6.17.4 2024-12-01 16:06:45 -06:00
BenCodez 2ab6ff5105 Added /av resettotal (topvoter) 2024-11-30 20:37:38 -06:00
BenCodez 0470993b81 Adjustments to wiping column data 2024-11-30 20:33:03 -06:00
BenCodez 7de3dff221 Adjustments to time change handling in certain cases on proxy 2024-11-30 20:07:13 -06:00
Ben c17f6facbb Delete .github/workflows/jekyll-gh-pages.yml 2024-11-29 11:00:31 -06:00
Ben d0e2a7987b Create jekyll-gh-pages.yml 2024-11-29 10:59:27 -06:00
BenCodez c9d3b1655d Fix nonvotedplayerscache not working on velocity as it should 2024-11-29 08:27:11 -06:00
BenCodez 348ad9d3d5 Added new config option SkullProfileAPIURL 2024-11-28 12:37:26 -06:00
BenCodez f90b87fa5a Add new options for purging, new purge with no data check 2024-11-25 20:43:05 -06:00
BenCodez 5b19d3397a Add new placeholder for number of votes since last milestone 2024-11-24 14:47:31 -06:00
BenCodez dad0f88865 Change version to 6.17.4-SNAPSHOT 2024-11-24 14:34:32 -06:00
BenCodez 3e862efff2 Fix javadoc issue 2024-11-24 14:24:01 -06:00
BenCodez 52ca5467f7 Update version number to 6.17.3 2024-11-24 14:06:58 -06:00
BenCodez 61657dc670 Disable update checking on dev builds 2024-11-24 11:24:03 -06:00
BenCodez 4bac98c015 Quick fix 2024-11-23 11:22:55 -06:00
BenCodez 1215d224b4 Changes to vote party remindatvotes is gotten from specialrewards.yml 2024-11-23 11:21:57 -06:00
BenCodez 6dde613558 Modify hiding triggering vote message in console 2024-11-21 19:33:52 -06:00
BenCodez 99e34b5cd4 Hide trigger vote message if noservicesitemessage is disabled 2024-11-21 16:23:34 -06:00
BenCodez e049329f41 Add ability to hide issue with service site message on /av vote 2024-11-21 16:16:26 -06:00
BenCodez 8fe4661fe1 Change default skull cache timing 2024-11-19 19:27:11 -06:00
BenCodez af8cfc94a9 Changes to default sound 2024-11-18 08:01:16 -06:00
Ben d98a9a9152 Merge pull request #1394 from BenCodez/dependabot/maven/VotingPlugin/org.projectlombok-lombok-1.18.36
Bump org.projectlombok:lombok from 1.18.34 to 1.18.36 in /VotingPlugin
2024-11-18 07:29:48 -06:00
dependabot[bot] 749ef7fa45 Bump org.projectlombok:lombok from 1.18.34 to 1.18.36 in /VotingPlugin
Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.34 to 1.18.36.
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.34...v1.18.36)

---
updated-dependencies:
- dependency-name: org.projectlombok:lombok
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 06:16:44 +00:00
BenCodez 3f2a2fa33a Change version system to snapshots 2024-11-17 14:53:33 -06:00
BenCodez 2cb48d655a Disable plugin update checking if using snapshot version 2024-11-17 14:48:32 -06:00
BenCodez 573315dd18 Use snapshot version 2024-11-17 14:45:47 -06:00
BenCodez 63091ad815 Add dev maven profile back 2024-11-17 13:54:30 -06:00
BenCodez 9e88f57bfb Cleanup pom.xml 2024-11-17 12:55:15 -06:00
BenCodez 86d38d6ac9 Set correct java version in pom.xml 2024-11-17 12:28:30 -06:00
BenCodez e752d111a0 Fix pom.xml 2024-11-16 22:04:59 -06:00
BenCodez 0a09d13bb3 Remove unneeded maven profiles 2024-11-16 17:30:04 -06:00
BenCodez 08a6d91996 Fix issue with reload order with GlobalData mysql connection 2024-11-07 08:47:12 -06:00
BenCodez 1082c47297 Flush skull cache not used for a week 2024-11-05 18:08:34 -06:00
BenCodez 531812d800 Check if sever still exists on velocity 2024-11-05 07:31:24 -06:00
BenCodez 903a7232de Use new api 2024-11-04 12:01:30 -06:00
Ben ed1a0c0708 Merge pull request #1392 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.11.1
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.10.1 to 3.11.1 in /VotingPlugin
2024-11-04 07:45:16 -06:00
dependabot[bot] 15f12220a3 Bump org.apache.maven.plugins:maven-javadoc-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.10.1 to 3.11.1.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.10.1...maven-javadoc-plugin-3.11.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-04 06:55:01 +00:00
BenCodez c24871c34d Add new skull caching delay option 2024-11-03 13:58:25 -06:00
BenCodez 65e180ccf8 Remove all unused skull options 2024-11-03 13:48:02 -06:00
BenCodez 4cc523429d Changes to skull caching 2024-11-03 11:03:27 -06:00
BenCodez 01b5e5f8a1 Remove deprecated code 2024-11-02 16:45:50 -06:00
BenCodez 944458d858 Update to 1.21.3 2024-11-02 16:43:35 -06:00
BenCodez 9beaa4e440 Handle casing differences in position placeholder checking 2024-10-29 10:27:48 -06:00
BenCodez 3c78db5fe6 Update version number to 6.17.2 2024-10-20 13:27:26 -06:00
BenCodez 9400a4fa08 change book placeholder to use [] 2024-10-19 12:29:10 -06:00
BenCodez b4519bc6e7 add %num% placeholder to books 2024-10-18 07:06:53 -06:00
BenCodez f698481b97 More adjustments to global data handling 2024-10-08 15:39:21 -06:00
BenCodez 927641f005 Actually fix time changes on velocity not working correctly 2024-10-07 07:33:08 -06:00
BenCodez d85ad022fb Add extra checks on global data time changes 2024-10-07 07:27:49 -06:00
Ben e39fcd78ca Merge pull request #1390 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.10.1
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.10.0 to 3.10.1 in /VotingPlugin
2024-10-07 07:10:15 -06:00
dependabot[bot] 6800ccd4a7 Bump org.apache.maven.plugins:maven-javadoc-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.10.0 to 3.10.1.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.10.0...maven-javadoc-plugin-3.10.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-07 06:56:01 +00:00
BenCodez 3065e57b44 Add extra debug for vote shop permission checks 2024-10-06 22:18:31 -06:00
BenCodez fdcf092c7f Update banned players every day 2024-10-06 09:38:56 -06:00
BenCodez 7b9e734ccd Add option to force load skulls 2024-10-02 21:56:13 -06:00
BenCodez 5718e3261a Fix VoteParty increase votes required typo 2024-10-02 17:22:54 -06:00
BenCodez e391ba88e4 Add extra debug to limit monthly votes 2024-10-02 07:31:00 -06:00
BenCodez b7942e763c Fix NPE with placeholder caching invalid placeholders 2024-09-30 13:50:30 -06:00
BenCodez cb039e052c Fix invalid enoughpoints placeholder from creating errors 2024-09-30 08:06:58 -06:00
BenCodez 07a4350f10 Add more debug to login event 2024-09-30 07:20:50 -06:00
BenCodez 44130f6a52 Run everysite reward before votesite reward 2024-09-23 14:46:17 -06:00
Ben 6caf9afc1d Merge pull request #1386 from BenCodez/dependabot/maven/VotingPlugin/org.bstats-bstats-velocity-3.1.0
Bump org.bstats:bstats-velocity from 3.0.3 to 3.1.0 in /VotingPlugin
2024-09-23 07:28:25 -06:00
dependabot[bot] 7428581b4c Bump org.bstats:bstats-velocity from 3.0.3 to 3.1.0 in /VotingPlugin
Bumps [org.bstats:bstats-velocity](https://github.com/Bastian/bStats-Metrics) from 3.0.3 to 3.1.0.
- [Release notes](https://github.com/Bastian/bStats-Metrics/releases)
- [Commits](https://github.com/Bastian/bStats-Metrics/compare/v3.0.3...v3.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-23 06:13:42 +00:00
BenCodez a2dc362456 Add placeholder support to voteshop permission 2024-09-05 07:30:18 -04:00
Ben 8d8e904a5f Merge pull request #1382 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.10.0
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.8.0 to 3.10.0 in /VotingPlugin
2024-09-02 07:33:11 -04:00
dependabot[bot] 4485006fbb Bump org.apache.maven.plugins:maven-javadoc-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.8.0 to 3.10.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.8.0...maven-javadoc-plugin-3.10.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-02 06:49:44 +00:00
Ben 6fc3cb9096 Merge pull request #1378 from BenCodez/dependabot/maven/VotingPlugin/org.bstats-bstats-velocity-3.0.3
Bump org.bstats:bstats-velocity from 3.0.2 to 3.0.3 in /VotingPlugin
2024-08-26 07:25:55 -04:00
Ben cdf14896f0 Merge pull request #1379 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-deploy-plugin-3.1.3
Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.2 to 3.1.3 in /VotingPlugin
2024-08-26 07:25:49 -04:00
dependabot[bot] bdd73b2873 Bump org.apache.maven.plugins:maven-deploy-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/apache/maven-deploy-plugin/releases)
- [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.1.2...maven-deploy-plugin-3.1.3)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-deploy-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-26 06:59:28 +00:00
dependabot[bot] e8781a0abe Bump org.bstats:bstats-velocity from 3.0.2 to 3.0.3 in /VotingPlugin
Bumps [org.bstats:bstats-velocity](https://github.com/Bastian/bStats-Metrics) from 3.0.2 to 3.0.3.
- [Release notes](https://github.com/Bastian/bStats-Metrics/releases)
- [Commits](https://github.com/Bastian/bStats-Metrics/compare/v3.0.2...v3.0.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-26 06:59:15 +00:00
BenCodez 0d26b59777 process vote party before broadcast message 2024-08-12 16:09:48 -04:00
BenCodez fa0535cf32 Update to 1.21.1 2024-08-11 16:39:08 -04:00
BenCodez 2353ec321c Remove treatvanishasoffline to be enabled for voteparty reminder 2024-08-11 13:08:36 -04:00
BenCodez cb4646f67d Don't broadcast vote party reminders if vanished 2024-08-11 12:44:48 -04:00
BenCodez 7a500f9cca Fixed voteshop exra items rewards not working 2024-08-09 16:04:32 -04:00
BenCodez b583b71721 Fix Shop.yml not reloading on reload 2024-08-04 20:22:07 -04:00
BenCodez c2fa7c4f90 Update version number to 6.17.1 2024-08-04 13:43:54 -04:00
BenCodez 2b82b8db82 Changes to package relocations 2024-08-02 20:14:09 -04:00
BenCodez c130004201 Remove unused command in plugin.yml 2024-08-02 15:52:17 -04:00
BenCodez 4829c772cb Fix voteshop extra items not working 2024-07-30 16:00:20 -04:00
BenCodez e8bf487d74 Fix /voteshop (shop) not working 2024-07-22 20:26:30 -04:00
Ben f5e9a450f9 Merge pull request #1370 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.8.0
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.8.0 in /VotingPlugin
2024-07-22 16:07:57 -04:00
dependabot[bot] ebb44330fd Bump org.apache.maven.plugins:maven-javadoc-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.7.0 to 3.8.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.7.0...maven-javadoc-plugin-3.8.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-22 06:29:26 +00:00
BenCodez 616a102d73 Update version number to 6.17 2024-07-20 19:19:41 -04:00
BenCodez a5b741d92b Remove unneeded debug and changes 2024-07-17 19:59:43 -04:00
BenCodez e7f5000a56 More velocity cache fixes 2024-07-17 19:55:36 -04:00
BenCodez 0615f61f0b Fix typo 2024-07-17 19:48:45 -04:00
BenCodez 2ae913c743 Add temp debug 2024-07-17 19:38:54 -04:00
BenCodez 4ec5bfef4f Add extra log message 2024-07-17 19:21:59 -04:00
BenCodez 33e173448a Changes to proxy debug log message 2024-07-17 19:16:32 -04:00
BenCodez 20671c4504 More changes to vote cache on velocity 2024-07-17 14:49:49 -04:00
BenCodez 16705c5707 Changes to vote cache handling on velocity 2024-07-16 21:34:49 -04:00
BenCodez 549309ee8c Changes to auto conversion 2024-07-04 09:44:11 -04:00
BenCodez 2bb3fac778 Remove extra failsafe for Shop.yml conversion 2024-07-04 09:35:38 -04:00
BenCodez 1e84f3cbc6 Add new LimitVotePoints option to limit max amount of points possible 2024-07-04 07:45:54 -04:00
BenCodez 98a0c9944e Change order of file loading 2024-07-03 07:42:47 -04:00
BenCodez 8016240445 Remove vote shop settings from GUI.yml 2024-07-02 12:45:47 -04:00
BenCodez 4dc5e5c3b6 Add extra failsafe for Shop.yml conversion 2024-07-02 12:44:37 -04:00
Ben 5a4f361d3f Merge pull request #1368 from BenCodez/dependabot/maven/VotingPlugin/org.projectlombok-lombok-1.18.34
Bump org.projectlombok:lombok from 1.18.32 to 1.18.34 in /VotingPlugin
2024-07-01 07:39:55 -04:00
dependabot[bot] 2542cc87d3 Bump org.projectlombok:lombok from 1.18.32 to 1.18.34 in /VotingPlugin
Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.32 to 1.18.34.
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.32...v1.18.34)

---
updated-dependencies:
- dependency-name: org.projectlombok:lombok
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-01 06:33:43 +00:00
BenCodez b13afd53c1 Added Shop.yml, with auto conversion from GUI.yml 2024-06-30 19:56:38 -04:00
BenCodez c1f9ba24a7 Add link to wiki page for OnlineMode setting 2024-06-24 20:17:07 -04:00
BenCodez 1c20ac60e5 Fix error in spacing 2024-06-24 20:10:02 -04:00
Ben 98a4d7062b Merge pull request #1367 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-jar-plugin-3.4.2
Bump org.apache.maven.plugins:maven-jar-plugin from 3.4.1 to 3.4.2 in /VotingPlugin
2024-06-24 15:53:02 -04:00
dependabot[bot] b08edc007a Bump org.apache.maven.plugins:maven-jar-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.4.1 to 3.4.2.
- [Release notes](https://github.com/apache/maven-jar-plugin/releases)
- [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.4.1...maven-jar-plugin-3.4.2)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-jar-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-24 06:38:04 +00:00
BenCodez 054c8d0361 Update version number to 6.16.3 2024-06-23 14:45:19 -04:00
BenCodez c78141357e Change click bypass to require shift on vote URL 2024-06-18 16:36:45 -04:00
BenCodez 5efd5646f2 Changes to vote url GUI 2024-06-17 16:16:23 -04:00
BenCodez e1c1d7b530 Add paper mapping setting 2024-06-16 17:00:54 -04:00
BenCodez f436b03584 Support left clicking on GUI to show all votesites even without perms 2024-06-16 12:23:34 -04:00
BenCodez e34f5f077f Add ability to hide votesites if no permission 2024-06-15 19:56:11 -04:00
BenCodez e1a059b766 Properly shutdown multi-proxy handling on proxy 2024-06-14 15:58:28 -04:00
BenCodez 9cb7158d84 Update to 1.21 2024-06-13 16:31:47 -04:00
BenCodez 35ce6cc68e Fix timer not shuting down on velocity 2024-06-13 16:27:24 -04:00
BenCodez a7832692b7 Add option UUIDLookup on proxy (default=true) 2024-06-04 20:01:04 -04:00
Ben 8fd7a30720 Merge pull request #1360 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-shade-plugin-3.6.0
Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.3 to 3.6.0 in /VotingPlugin
2024-06-03 15:43:25 -04:00
Ben fdd8f28a29 Merge pull request #1361 from BenCodez/dependabot/maven/VotingPlugin/org.sonatype.plugins-nexus-staging-maven-plugin-1.7.0
Bump org.sonatype.plugins:nexus-staging-maven-plugin from 1.6.13 to 1.7.0 in /VotingPlugin
2024-06-03 15:43:18 -04:00
Ben f9d41d49b2 Merge pull request #1362 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.7.0
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.3 to 3.7.0 in /VotingPlugin
2024-06-03 15:43:07 -04:00
dependabot[bot] 456e43b37a Bump org.apache.maven.plugins:maven-javadoc-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.6.3 to 3.7.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.3...maven-javadoc-plugin-3.7.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 06:47:51 +00:00
dependabot[bot] 2cbf12cf1e Bump org.sonatype.plugins:nexus-staging-maven-plugin in /VotingPlugin
Bumps org.sonatype.plugins:nexus-staging-maven-plugin from 1.6.13 to 1.7.0.

---
updated-dependencies:
- dependency-name: org.sonatype.plugins:nexus-staging-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 06:45:32 +00:00
dependabot[bot] aeac53a5a7 Bump org.apache.maven.plugins:maven-shade-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.5.3 to 3.6.0.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.5.3...maven-shade-plugin-3.6.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-shade-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 06:45:27 +00:00
BenCodez 2ea402b67c Check offline rewards on resume 2024-06-02 15:52:43 -04:00
BenCodez ba1b8cafcd Change vote party timing 2024-06-02 15:30:21 -04:00
BenCodez 5984ee15b5 Always update last vote party for each day 2024-06-02 14:06:19 -04:00
BenCodez a13b5ee7a2 Add new VoteTotal to rewards as a requirement 2024-06-01 19:44:24 -04:00
BenCodez 56e6a659fe Added ability to pause/resume rewards globally via commands 2024-06-01 19:17:51 -04:00
BenCodez 56f5611a96 Change reward placeholder name 2024-05-30 20:02:35 -04:00
BenCodez a828450846 Add placeholder to voteparty rewards for first vote party today 2024-05-30 20:01:44 -04:00
BenCodez 3f8495d0f7 Added option to only shows sites to vote on still on all urls 2024-05-30 19:56:51 -04:00
BenCodez bbb2df5f16 Added option to enable/disable internal papi expansion 2024-05-28 15:52:12 -04:00
Ben 40eb9b0afc Merge pull request #1358 from BenCodez/dependabot/maven/VotingPlugin/me.clip-placeholderapi-2.11.6
Bump me.clip:placeholderapi from 2.11.5 to 2.11.6 in /VotingPlugin
2024-05-27 15:58:06 -04:00
dependabot[bot] 545eb0cd69 Bump me.clip:placeholderapi from 2.11.5 to 2.11.6 in /VotingPlugin
Bumps me.clip:placeholderapi from 2.11.5 to 2.11.6.

---
updated-dependencies:
- dependency-name: me.clip:placeholderapi
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-27 06:44:10 +00:00
46 changed files with 1896 additions and 772 deletions

No files matched your search

+56 -7
View File
@@ -129,6 +129,9 @@ Format:
# If you want to want to use the feature below where the plugin will
# automaticly list the sites then set the message in the text above
AutoInputSites: true
# If true only show links on all urls that need to be voted on still
OnlyShowSitesToVote: false
# For each VoteSite
# make sure to set VoteURL in your VoteSites
# Requires above to be true
@@ -463,6 +466,9 @@ UseJavascriptPlaceholders: false
# 'false': 'User does not have enough points'
CustomPlaceholderReturns: {}
# Load votingplugin internal expansion
LoadInteralExpansion: true
###########################################
# Login options
###########################################
@@ -552,6 +558,8 @@ CreateBackups: true
AutoDownload: false
# If false plugin will use offline player UUIDs
# Keep enabled when mixing uuids (Premium and cracked)
# More info: https://github.com/BenCodez/VotingPlugin/wiki/Online-Offline-Mode
OnlineMode: true
# Disable checking on world change
@@ -574,12 +582,35 @@ OfflineVotesLimit:
# Limit of votes per votesite
Amount: 5
# Maxium amount of vote points possible, -1 to disable
LimitVotePoints: -1
# Default worlds set for all rewards
DefaultRewardWorlds: []
# Default blackedlisted worlds set for all rewards
DefaultRewardBlackListedWorlds: []
###########################################
# Month Date Totals
# Experimental feature
###########################################
# Experimental
# Stores month votes with date formatting
# MonthTotal-MONTH-YEAR
# This setting only enables setting totals, not using them
# Enabling this is pretty safe and harmless with just this setting
# Essentially will just copy MonthTotal to MonthTotal-MONTH-YEAR
# Can use command /vote PreviousMonthsVoters after this is enabled
StoreMonthTotalsWithDate: false
# Experimental
# This setting uses month votes with date formatting
# If using this StoreMonthTotalsWithDate must be enabled
# This setting may be very buggy as it's in early stages
UseMonthDateTotalsAsPrimaryTotal: false
###########################################
# Skull settings
###########################################
@@ -587,12 +618,19 @@ DefaultRewardBlackListedWorlds: []
# Preload skulls to improve performance for vote top
# when using skulls as the item to display players
# If false, skulls will be cached as they are used
# assuming loadskulls is enabled
PreloadSkulls: false
PreloadSkulls: true
# Setting to false disables saving skulls in a cache to improve speeds
# Will reduce ram usage (very little) if disabled, but slow GUI speeds when using skulls
LoadSkulls: true
# Number of miliseconds between skull caching
# Default about 3 seconds is good for most servers
# Used to avoid rate limit, increase if needed
# If rate limit is hit caching will pause for 15 minutes
SkullLoadDelay: 3000
# Set a skull profile URL
# This is what gets used to cache skulls
# Default: https://sessionserver.mojang.com/session/minecraft/profile/
# Other examples: https://crafthead.net/profile/
SkullProfileAPIURL: ''
###########################################
# Extra checks on vote
@@ -705,7 +743,7 @@ ExtraBackgroundUpdate: false
# Click sound when using gui
# Set to none for no sound
ClickSound:
Sound: 'UI_BUTTON_CLICK'
Sound: 'ui.button.click'
Volume: 1.0
Pitch: 1.0
@@ -735,9 +773,20 @@ CloseGUIOnShiftClick: false
# Purge settings
###########################################
# Remove old player files
# Happens on startup or /av purge
# Recommend leaving this disabled
# When disabled it also disables the commands to manually purge
PurgeOldData: false
# Enable auto purging data on startup
# Do not enable unless you know what you are doing
# Purges players with vote totals
# Requires PurgeOldData to be enabled
PurgeDataOnStartup: false
# Same as above, but checks players have no vote total before purging
# Requires PurgeOldData to be enabled
PurgeNoDataOnStartup: false
# Minimum number of days offline in order to purge
PurgeMin: 90
+2 -73
View File
@@ -287,7 +287,6 @@ CHEST:
Name: 'VoteSite: %site%'
VoteGUIName: '&cVoteGUI: &c&l%player%'
VoteRewardName: 'VoteReward'
VoteShopName: 'VoteShop'
BackButton:
Material: 'BARRIER'
@@ -300,78 +299,8 @@ CHEST:
EndOfGUI: false
# If true, this item will become an exit button instead
Exit: false
VoteShopBackButton: true
VoteShopEnabled: true
# Hide items in vote shop which user can not buy
VoteShopHideLimitedReached: true
# Requires above to be false
VoteShopLimitReached: '&aYou reached your limit'
VoteShopRequireConfirmation: false
VoteShopDisabled: '&cVote shop disabled'
# If true, shop gui will reopen, updating all placeholders
VoteShopReopenGUIOnPurchase: false
# VoteShop extra items for display only
#VoteShopExtraItems:
#Item:
#...
Shop:
# Identifier
# Used in placeholders for formats
# Do not have spaces in the identifier
# Change the identifier for each shop item
Diamond:
Identifier_Name: 'Diamond'
# Item
Material: 'DIAMOND'
Amount: 1
Name: '&4Buy A Diamond'
# You can set skulls of the player using the following
# Remove the # to enable
#Skull: '%Player%'
Lore:
- '&c&lCost: &c3 Voting Points'
# Number of voting points this cost
Cost: 3
# Permission required, leave blank for no permission
Permission: ''
# Hide if player doesn't have permission (only if permission is set)
HideOnNoPermission: true
# Whether or not to keep GUI open after purchase
CloseGUI: true
# Require confirmation on purchase, overrides global option above
RequireConfirmation: false
# Overrides other purchase message
#PurchaseMessage: 'Thanks for the purchase'
# Limit how many times you can buy this
#Limit: 3
# Reset limit daily/weekly/monthly
#Reset:
#Daily: false
#Weekly: false
#Monthly: false
# If true, item is not buyable
#NotBuyable: false
# Rewards to run if player buys successfully
Rewards:
# Run command on purchase
#Commands:
#- 'command here'
Items:
Diamond:
Material: 'DIAMOND'
Amount: 1
ShopConfirmPurchase:
Title: 'Confirm Purchase?'
YesItem:
Material: EMERALD_BLOCK
Amount: 1
Name: '&aYes'
NoItem:
Material: BARRIER
Amount: 1
Name: '&cNo'
# VoteShop settings moved to Shop.yml for 6.17 (To be released)
BOOK:
+77
View File
@@ -0,0 +1,77 @@
VoteShop:
Enabled: true
Name: 'VoteShop'
BackButton: true
# Hide items in vote shop which user can not buy
HideLimitedReached: true
# Requires above to be false
LimitReached: '&aYou reached your limit'
RequireConfirmation: false
Disabled: '&cVote shop disabled'
# If true, shop gui will reopen, updating all placeholders
ReopenGUIOnPurchase: false
Shop:
# Identifier
# Used in placeholders for formats
# Do not have spaces in the identifier
# Change the identifier for each shop item
Diamond:
Identifier_Name: 'Diamond'
# Item
Material: 'DIAMOND'
Amount: 1
Name: '&4Buy A Diamond'
# You can set skulls of the player using the following
# Remove the # to enable
#Skull: '%Player%'
Lore:
- '&c&lCost: &c3 Voting Points'
# Number of voting points this cost
Cost: 3
# Permission required, leave blank for no permission
Permission: ''
# Hide if player doesn't have permission (only if permission is set)
HideOnNoPermission: true
# Whether or not to keep GUI open after purchase
CloseGUI: true
# Require confirmation on purchase, overrides global option above
RequireConfirmation: false
# Overrides other purchase message
#PurchaseMessage: 'Thanks for the purchase'
# Limit how many times you can buy this
#Limit: 3
# Reset limit daily/weekly/monthly
#Reset:
#Daily: false
#Weekly: false
#Monthly: false
# If true, item is not buyable
#NotBuyable: false
# Rewards to run if player buys successfully
Rewards:
# Run command on purchase
#Commands:
#- 'command here'
Items:
Diamond:
Material: 'DIAMOND'
Amount: 1
# VoteShop extra items for display only
#ExtraItems:
#ItemIdentifier:
#...
ShopConfirmPurchase:
Title: 'Confirm Purchase?'
YesItem:
Material: EMERALD_BLOCK
Amount: 1
Name: '&aYes'
NoItem:
Material: BARRIER
Amount: 1
Name: '&cNo'
+2 -2
View File
@@ -65,7 +65,7 @@ VoteParty:
# Number of votes required to give rewards
VotesRequired: 20
# Increase the amount of votes required on each vote party reached
#IncreaseVotesRquired: 10
#IncreaseVotesRequired: 10
# If true, players who did not vote to reach the votes required will
# recieve the reward
# If false, only players who voted get rewards
@@ -97,7 +97,7 @@ VoteParty:
Broadcast: '&cReached the vote party amount!'
# Send a broadcast at a certain number of votes left and send a vote reminder
VoteReminderBroadcast: '%votesrequired% left to go, go vote!'
# List of votes required amounts for when to send vote party reminders
# Send vote reminder at number of votes to go
VoteReminderAtVotes: []
# List of commands to execute, these only execute once.
# %player% does not work here
+4
View File
@@ -60,6 +60,10 @@ VoteSites:
# This basiclly disables offline voting if set to true, don't misinterpret this option
ForceOffline: false
# Requrie a permission to view site in GUI
# If empty or not set anyone can view (default)
#PermissionToView: 'Perm.here'
# VoteSite Material for some GUI's
# Removing this may result in an error, required on each site
DisplayItem:
+27
View File
@@ -128,6 +128,9 @@ VoteCacheTime: -1
# Set to -1 to disable
MaxAmountOfVotesPerDay: -1
# Maxium amount of vote points possible, -1 to disable
LimitVotePoints: -1
VoteParty:
# If enabled, will trigger vote party reward
# in BungeeSettings.yml under BungeeVotePartyReward
@@ -148,8 +151,32 @@ VoteParty:
# Online mode for UUIDS
# Offline mode setups are not fully tested and are not supported currently
# If using mixed uuids (premium and cracked players leave this enabled and disable UUIDLookup below)
# More details here: https://github.com/BenCodez/VotingPlugin/wiki/Online-Offline-Mode
OnlineMode: true
# If true plugin will atempt to lookup uuids if none exist
UUIDLookup: true
###########################################
# Month Date Totals
# Experimental feature
# Settings must match on backend servers
###########################################
# Experimental
# Stores month votes with date formatting
# MonthTotal-MONTH-YEAR
# This setting only enables setting totals, not using them
# Enabling this is pretty safe and harmless with just this setting
StoreMonthTotalsWithDate: false
# Experimental
# This setting uses month votes with date formatting
# If using this StoreMonthTotalsWithDate must be enabled
# This setting may be very buggy as it's in early stages
UseMonthDateTotalsAsPrimaryTotal: false
##########################################
# PLUGINMESSAGING Settings
##########################################
-3
View File
@@ -54,9 +54,6 @@ commands:
voteurl:
description: Open VoteURL
aliases: vurl
votereward:
description: Open VoteReward GUI
aliases: vreward
voteparty:
description: A command
aliases: vparty
+219 -170
View File
@@ -3,14 +3,16 @@
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>${version.art}</artifactId>
<version>6.16.2</version>
<artifactId>votingplugin</artifactId>
<version>6.18</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
<github.global.server>github</github.global.server>
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
<build.number>NOTSET</build.number>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<build>
<resources>
@@ -58,16 +60,6 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
@@ -90,7 +82,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<version>3.6.0</version>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<minimizeJar>true</minimizeJar>
@@ -103,6 +95,11 @@
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.tcoded.folialib</pattern>
<shadedPattern>
${project.groupId}.votingplugin.simpleapi.folialib</shadedPattern>
</relocation>
<relocation>
<pattern>com.bencodez.simpleapi</pattern>
<shadedPattern>
@@ -175,31 +172,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</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>
<repositories>
@@ -237,19 +209,19 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<version>1.21.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<version>1.18.36</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.20-R0.2</version>
<version>1.20-R0.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -267,91 +239,59 @@
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.1</version>
<version>3.1.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>3.7.12</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>normal</id>
<id>default</id>
<properties>
<build.profile.id>default</build.profile.id>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.profile.id>normal</build.profile.id>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>normal-folia</id>
<properties>
<build.profile.id>normal</build.profile.id>
<version.art>votingplugin-folia</version.art>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore-folia</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>prod2</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>prod2</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>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</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>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>deploy-snapshot</build.profile.id>
<build.profile.id>dev-snapshot</build.profile.id>
</properties>
<distributionManagement>
<snapshotRepository>
@@ -360,23 +300,67 @@
</snapshotRepository>
<repository>
<id>nexus</id>
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</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>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>
${project.basedir}/target/${project.name}.jar</sourceFile>
<destinationFile>
${project.basedir}/target/${project.name}-${build.number}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<phase>install</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.2</version>
<version>3.1.3</version>
<configuration>
<skip>true</skip>
</configuration>
@@ -384,11 +368,11 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<version>1.7.0</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
@@ -406,9 +390,6 @@
<profile>
<id>javadoc</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>javadoc</build.profile.id>
</properties>
<distributionManagement>
@@ -418,20 +399,25 @@
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</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.6.3</version>
<version>3.11.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -448,26 +434,83 @@
</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.4.2</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.3.1</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>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>deploy</build.profile.id>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>nexus</id>
@@ -480,10 +523,43 @@
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</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.6.3</version>
<version>3.11.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -501,7 +577,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
<configuration>
<skip>true</skip>
</configuration>
@@ -509,7 +585,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<version>1.7.0</version>
<executions>
<execution>
<id>default-deploy</id>
@@ -525,33 +601,6 @@
<skipStaging>true</skipStaging>
</configuration>
</plugin>
<!--<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<executions>
<execution>
<id>javadoc</id>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
<configuration>
<message>Maven javadoc for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/apidocs
</outputDirectory>
<branch>refs/heads/gh-pages</branch>
<includes>
<include>**/*</include>
</includes>
<repositoryName>VotingPlugin</repositoryName>
<repositoryOwner>BenCodez</repositoryOwner>
<server>github</server>
</configuration>
</execution>
</executions>
</plugin>-->
</plugins>
</build>
</profile>
@@ -1,31 +0,0 @@
package com.Ben12345rocks.VotingPlugin.Objects;
import org.bukkit.entity.Player;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@Deprecated
public class User {
private VotingPluginUser user;
public User(Player p) {
user = VotingPluginMain.plugin.getVotingPluginUserManager().getVotingPluginUser(p);
}
public void addPoints(int points) {
user.addPoints(points);
}
public int getPoints() {
return user.getPoints();
}
public boolean removePoints(int points) {
return user.removePoints(points);
}
public void setPoints(int points) {
user.setPoints(points);
}
}
@@ -167,6 +167,8 @@ public class BungeeHandler implements Listener {
plugin.debug("Detected time change from bungee: " + type.toString());
plugin.getTimeChecker().forceChanged(type, false, true, true);
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
getGlobalMessageHandler().sendMessage("TimeChangeFinished",
"" + plugin.getBungeeSettings().getServer());
}
}
return isProcessing;
@@ -226,6 +228,11 @@ public class BungeeHandler implements Listener {
public void debug(String text) {
plugin.debug(text);
}
@Override
public void info(String text) {
plugin.getLogger().info(text);
}
});
} else {
globalDataHandler = new GlobalDataHandler(
@@ -251,6 +258,11 @@ public class BungeeHandler implements Listener {
public void debug(String text) {
plugin.debug(text);
}
@Override
public void info(String text) {
plugin.getLogger().info(text);
}
});
}
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
@@ -7,6 +7,7 @@ import java.net.URL;
import java.security.CodeSource;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -46,16 +47,19 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
import com.bencodez.advancedcore.api.rewards.Reward;
import com.bencodez.advancedcore.api.rewards.RewardEditData;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.rewards.RewardPlaceholderHandle;
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection;
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectInt;
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator;
import com.bencodez.advancedcore.api.skull.SkullHandler;
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInjectConfigurationSection;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.api.yml.YMLConfig;
import com.bencodez.advancedcore.logger.Logger;
import com.bencodez.simpleapi.file.YMLConfig;
import com.bencodez.simpleapi.nms.NMSManager;
import com.bencodez.simpleapi.skull.SkullCache;
import com.bencodez.simpleapi.updater.Updater;
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
import com.bencodez.votingplugin.commands.CommandLoader;
@@ -68,6 +72,7 @@ import com.bencodez.votingplugin.config.BungeeSettings;
import com.bencodez.votingplugin.config.Config;
import com.bencodez.votingplugin.config.ConfigVoteSites;
import com.bencodez.votingplugin.config.GUI;
import com.bencodez.votingplugin.config.ShopFile;
import com.bencodez.votingplugin.config.SpecialRewardsConfig;
import com.bencodez.votingplugin.cooldown.CoolDownCheck;
import com.bencodez.votingplugin.data.ServerData;
@@ -141,9 +146,16 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private GUI gui;
@Getter
private ShopFile shopFile;
@Getter
private LinkedHashMap<TopVoterPlayer, Integer> lastMonthTopVoter;
@Getter
@Setter
private LinkedHashMap<YearMonth, LinkedHashMap<TopVoterPlayer, Integer>> previousMonthsTopVoters;
@Getter
private MVdWPlaceholders mvdwPlaceholders;
@@ -896,27 +908,27 @@ public class VotingPluginMain extends AdvancedCorePlugin {
});
}
for (String identifier : plugin.getGui().getChestShopIdentifiers()) {
addDirectlyDefinedRewards(new DirectlyDefinedReward("CHEST.Shop." + identifier + ".Rewards") {
for (String identifier : plugin.getShopFile().getShopIdentifiers()) {
addDirectlyDefinedRewards(new DirectlyDefinedReward("Shop." + identifier + ".Rewards") {
@Override
public void createSection(String key) {
getGui().createSection(key);
getShopFile().createSection(key);
}
@Override
public ConfigurationSection getFileData() {
return getGui().getData();
return getShopFile().getData();
}
@Override
public void save() {
getGui().saveData();
getShopFile().saveData();
}
@Override
public void setData(String path, Object value) {
getGui().setValue(path, value);
getShopFile().setValue(path, value);
}
});
}
@@ -1043,9 +1055,23 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Override
public void onPostLoad() {
// auto conversion for Shop.yml
if (plugin.getShopFile().isJustCreated()) {
if (!plugin.getGui().isJustCreated() && !getServerData().isVoteShopConverted()) {
plugin.getLogger().warning("Converting VoteShop configuration to Shop.yml from GUI.yml");
plugin.getShopFile().convertFromGUIFile();
}
getServerData().setShopConverted(true);
} else if (!getServerData().isVoteShopConverted()) {
getServerData().setShopConverted(true);
}
loadVersionFile();
getOptions().setServer(bungeeSettings.getServer());
// only purges if enabled in config
getVotingPluginUserManager().purgeOldPlayersNoData();
voteTester = new VoteTester(plugin);
loadVoteTimer();
@@ -1059,8 +1085,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new VotingPluginExpansion(this).register();
getLogger().info("Loading PlaceholderAPI expansion");
if (getConfigFile().isLoadInteralExpansion()) {
new VotingPluginExpansion(this).register();
getLogger().info("Loading PlaceholderAPI expansion");
}
}
registerCommands();
@@ -1088,12 +1116,15 @@ public class VotingPluginMain extends AdvancedCorePlugin {
topVoterHandler = new TopVoterHandler(this);
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
previousMonthsTopVoters = new LinkedHashMap<YearMonth, LinkedHashMap<TopVoterPlayer, Integer>>();
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
topVoterHandler.loadLastMonth();
debug("Loaded last month top voters");
topVoterHandler.loadPreviousMonthTopVoters();
}
});
topVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
@@ -1178,8 +1209,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
ConfigurationSection section, HashMap<String, String> placeholders) {
if (section.getBoolean("Enabled")) {
user.sendBossBar(
PlaceholderUtils.replacePlaceHolder(section.getString("Message", ""),
placeholders),
PlaceholderUtils.replacePlaceHolder(section.getString("Message", ""), placeholders),
section.getString("Color", "BLUE"), section.getString("Style", "SOLID"),
(double) getVotingPluginUserManager().getVotingPluginUser(user).getSitesVotedOn()
/ plugin.getVoteSites().size(),
@@ -1189,6 +1219,69 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
});
getRewardHandler().addInjectedRequirements(new RequirementInjectConfigurationSection("VoteTotal") {
@Override
public boolean onRequirementsRequested(Reward reward, AdvancedCoreUser acUser, ConfigurationSection section,
RewardOptions rewardOptions) {
boolean atleast = section.getBoolean("AtleastMode", false);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(acUser);
for (TopVoter top : TopVoter.values()) {
int required = section.getInt(top.toString(), -1);
if (required >= 0) {
int total = user.getTotal(top);
if (atleast) {
if (total < required) {
debug("Failed requirement " + top.toString() + " " + total + "/" + required);
return false;
}
} else {
if (total != required) {
debug("Failed requirement " + top.toString() + " " + total + "!=" + required);
return false;
}
}
}
}
int milestoneCountRequired = section.getInt("MilestoneCount", -1);
if (milestoneCountRequired >= 0) {
int milestoneCount = user.getMilestoneCount();
if (atleast) {
if (milestoneCount < milestoneCountRequired) {
debug("Failed requirement milestonecount " + milestoneCount + "/" + milestoneCountRequired);
return false;
}
} else {
if (milestoneCount != milestoneCountRequired) {
debug("Failed requirement milestonecount " + milestoneCount + "!="
+ milestoneCountRequired);
return false;
}
}
}
int pointsRequired = section.getInt("Points", -1);
if (pointsRequired >= 0) {
int points = user.getPoints();
if (atleast) {
if (points < pointsRequired) {
debug("Failed requirement points " + points + "/" + pointsRequired);
return false;
}
} else {
if (points != pointsRequired) {
debug("Failed requirement points " + points + "!=" + pointsRequired);
return false;
}
}
}
return true;
}
});
for (final TopVoter top : TopVoter.values()) {
getRewardHandler().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
@@ -1413,8 +1506,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
specialRewardsConfig.reloadData();
gui.reloadData();
shopFile.reloadData();
bungeeSettings.reloadData();
updateAdvancedCoreHook();
reloadAdvancedCore(userStorage);
if (bungeeSettings.isUseBungeecoord()) {
if (getBungeeHandler() == null) {
@@ -1430,10 +1527,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
broadcastHandler.schedule(getConfigFile().getFormatAlternateBroadcastDelay());
}
updateAdvancedCoreHook();
plugin.loadVoteSites();
reloadAdvancedCore(userStorage);
getOptions().setServer(bungeeSettings.getServer());
if (userStorage) {
placeholders.load();
@@ -1472,10 +1567,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
bungeeSettings = new BungeeSettings(this);
bungeeSettings.setup();
serverData = new ServerData(this);
gui = new GUI(this);
gui.setup();
serverData = new ServerData(this);
shopFile = new ShopFile(this);
shopFile.setup();
checkYMLError();
@@ -1495,6 +1593,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
synchronized (plugin) {
if (plugin != null && plugin.isEnabled()) {
getUserManager().getDataManager().clearCacheBasic();
SkullCache.flushWeek();
plugin.debug("Starting background task, current cached users: "
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
@@ -1638,7 +1737,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
Set<TopVoterPlayer> players = topVoter.get(top).keySet();
for (TopVoterPlayer p : players) {
if (num <= maxToLoad) {
SkullHandler.getInstance().loadSkull(p.getPlayerName());
getSkullCacheHandler().addToCache(p.getUuid(), p.getPlayerName());
}
num++;
}
@@ -8,7 +8,7 @@ import lombok.Setter;
public class BungeeMessageData {
// Message string
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired//datemonthtotal
@Getter
@Setter
@@ -24,6 +24,9 @@ public class BungeeMessageData {
private int monthTotal = 0;
@Getter
@Setter
private int dateMonthTotal = 0;
@Getter
@Setter
private int points = 0;
@Getter
@Setter
@@ -36,7 +39,7 @@ public class BungeeMessageData {
private int votePartyRequired = 0;
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
int milestoneCount, int votePartyCurrent, int votePartyRequired) {
int milestoneCount, int votePartyCurrent, int votePartyRequired, int dateMonthTotal) {
this.allTimeTotal = allTimeTotal;
this.monthTotal = monthTotal;
this.weeklyTotal = weeklyTotal;
@@ -45,6 +48,7 @@ public class BungeeMessageData {
this.milestoneCount = milestoneCount;
this.votePartyCurrent = votePartyCurrent;
this.votePartyRequired = votePartyRequired;
this.dateMonthTotal = dateMonthTotal;
}
public BungeeMessageData(String str) {
@@ -61,6 +65,9 @@ public class BungeeMessageData {
votePartyCurrent = Integer.parseInt(data[6]);
votePartyRequired = Integer.parseInt(data[7]);
}
if (data.length >= 9) {
dateMonthTotal = Integer.parseInt(data[8]);
}
}
@Override
@@ -57,6 +57,14 @@ public class Config {
return getData().getBoolean("Broadcast", false);
}
public boolean getStoreMonthTotalsWithDate() {
return getData().getBoolean("StoreMonthTotalsWithDate", false);
}
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
return getData().getBoolean("UseMonthDateTotalsAsPrimaryTotal", false);
}
public String getBedrockPlayerPrefix() {
return getData().getString("BedrockPlayerPrefix", ".");
}
@@ -64,6 +72,14 @@ public class Config {
public boolean getOnlineMode() {
return getData().getBoolean("OnlineMode", true);
}
public boolean getTimeChangeFailSafeBypass() {
return getData().getBoolean("TimeChangeFailSafeBypass", false);
}
public boolean getUUIDLookup() {
return getData().getBoolean("UUIDLookup", true);
}
public boolean getGlobalDataEnabled() {
return getData().getBoolean("GlobalData.Enabled", false);
@@ -89,6 +105,10 @@ public class Config {
return getData().getInt("BungeeServer.Port", 1297);
}
public int getLimitVotePoints() {
return getData().getInt("LimitVotePoints", -1);
}
public boolean getDebug() {
return getData().getBoolean("Debug", false);
}
@@ -39,6 +39,7 @@ import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigBungee;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
@@ -354,6 +355,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
getLogger().info(text);
}
}, servers) {
@Override
@@ -361,7 +368,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (type.equals(TimeType.MONTH)) {
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
}
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
if (!config.getGlobalDataEnabled()) {
return;
@@ -382,6 +389,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Override
public void onTimeChangedFailed(String server, TimeType type) {
getGlobalDataHandler().setBoolean(server, type.toString(), false);
getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
getGlobalDataHandler().setBoolean(server, "Processing", false);
}
};
} else {
@@ -409,6 +418,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
getLogger().info(text);
}
}, servers) {
@Override
@@ -416,7 +431,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (type.equals(TimeType.MONTH)) {
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
}
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
if (!config.getGlobalDataEnabled()) {
return;
@@ -437,6 +452,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Override
public void onTimeChangedFailed(String server, TimeType type) {
getGlobalDataHandler().setBoolean(server, type.toString(), false);
getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
getGlobalDataHandler().setBoolean(server, "Processing", false);
}
};
}
@@ -477,6 +494,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
getMysql().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
if (config.getStoreMonthTotalsWithDate()) {
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now()), "INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1)),
"INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2)),
"INT DEFAULT '0'");
}
}
private String buildNumber = "NOTSET";
@@ -553,6 +577,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (mysql != null) {
mysql.shutdown();
}
if (multiProxyHandler != null) {
multiProxyHandler.close();
}
getLogger().info("VotingPlugin disabled");
enabled = false;
}
@@ -617,6 +644,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
checkVoteCacheTime();
}
if (!config.getGlobalDataEnabled()) {
getLogger().warning("Global data not enabled, ignoring time change event");
return;
}
for (String s : getAvailableAllServers()) {
@@ -734,6 +762,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
voteCacheFile = new VoteCache(this);
voteCacheFile.load();
bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass());
bungeeTimeChecker.loadTimer();
nonVotedPlayersCache = new NonVotedPlayersCache(this);
@@ -873,6 +902,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (message[0].equalsIgnoreCase("statusokay")) {
String server = message[1];
getLogger().info("Status okay for " + server);
} else if (message[0].equalsIgnoreCase("TimeChangeFinished")) {
} else if (message[0].equalsIgnoreCase("login")) {
String player = message[1];
String uuid = message[2];
@@ -1142,6 +1173,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Override
public void run() {
if (isOnline(p)) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
}
}
checkCachedVotes(server);
checkOnlineVotes(proxiedPlayer, proxiedPlayer.getUniqueId().toString(), server);
multiProxyHandler.login(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
@@ -1180,6 +1217,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
String server = in.readUTF();
getLogger().info("Status okay for " + server);
return;
} else if (subchannel.equalsIgnoreCase("TimeChangeFinished")) {
} else if (subchannel.equalsIgnoreCase("login")) {
String player = in.readUTF();
String uuid = in.readUTF();
@@ -1257,8 +1296,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
ArrayList<String> list = new ArrayList<String>();
list.add(channel);
list.addAll(ArrayUtils.convert(messageData));
redisHandler.sendMessage(getConfig().getRedisPrefix() + "VotingPlugin_" + server,
ArrayUtils.convert(list));
redisHandler.sendMessage(getConfig().getRedisPrefix() + "VotingPlugin_" + server, ArrayUtils.convert(list));
}
public void sendPluginMessageServer(String server, String channel, String... messageData) {
@@ -1344,6 +1382,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
public String getMonthTotalsWithDatePath() {
LocalDateTime cTime = bungeeTimeChecker.getTime();
return getMonthTotalsWithDatePath(cTime);
}
public String getMonthTotalsWithDatePath(LocalDateTime cTime) {
return "MonthTotal-" + cTime.getMonth().toString() + "-" + cTime.getYear();
}
public synchronized void vote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
BungeeMessageData text, String uuid) {
try {
@@ -1351,10 +1398,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
getLogger().info("No name from vote on " + service);
return;
}
if (timeQueue) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
if (timeQueue && getGlobalDataHandler().isTimeChangedHappened()) {
timeChangeQueue.add(new VoteTimeQueue(player, service,
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
getLogger().info("Cachcing vote from " + player + "/" + service
@@ -1374,22 +1421,27 @@ public class VotingPluginBungee extends Plugin implements Listener {
return;
}
if (config.getAllowUnJoined()) {
debug("Fetching UUID online, since allowunjoined is enabled");
UUID u = null;
try {
if (config.getOnlineMode()) {
u = fetchUUID(player);
if (config.getUUIDLookup()) {
debug("Fetching UUID online, since allowunjoined is enabled");
UUID u = null;
try {
if (config.getOnlineMode()) {
u = fetchUUID(player);
}
} catch (Exception e) {
if (getConfig().getDebug()) {
e.printStackTrace();
}
}
} catch (Exception e) {
if (getConfig().getDebug()) {
e.printStackTrace();
if (u == null) {
debug("Failed to get uuid for " + player);
return;
}
}
if (u == null) {
debug("Failed to get uuid for " + player);
uuid = u.toString();
} else {
getLogger().info("Failed to get uuid for " + player);
return;
}
uuid = u.toString();
} else {
getLogger().info("Ignoring vote from " + player + " since player hasn't joined before");
return;
@@ -1416,6 +1468,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
int monthTotal = getValue(data, "MonthTotal", 1);
int dateMonthTotal = -1;
if (config.getStoreMonthTotalsWithDate()) {
if (config.getUseMonthDateTotalsAsPrimaryTotal()) {
dateMonthTotal = getValue(data, getMonthTotalsWithDatePath(), 1);
} else {
dateMonthTotal = monthTotal;
}
}
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
@@ -1429,11 +1489,20 @@ public class VotingPluginBungee extends Plugin implements Listener {
monthTotal = days * maxVotes;
}
}
if (getConfig().getLimitVotePoints() > 0) {
if (points > getConfig().getLimitVotePoints()) {
points = getConfig().getLimitVotePoints();
}
}
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
milestoneCount, votePartyVotes, currentVotePartyVotesRequired, dateMonthTotal);
ArrayList<Column> update = new ArrayList<Column>();
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
if (config.getStoreMonthTotalsWithDate()) {
update.add(new Column(getMonthTotalsWithDatePath(), new DataValueInt(dateMonthTotal)));
}
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
update.add(new Column("Points", new DataValueInt(points)));
@@ -1441,7 +1510,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
debug("Setting totals " + text.toString());
mysql.update(uuid, update);
} else {
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired, 0);
}
}
@@ -37,6 +37,22 @@ public class Config extends VelocityYMLFile {
return getBoolean(getNode("OnlineMode"), true);
}
public boolean getTimeChangeFailSafeBypass() {
return getBoolean(getNode("TimeChangeFailSafeBypass"), false);
}
public boolean getStoreMonthTotalsWithDate() {
return getBoolean(getNode("StoreMonthTotalsWithDate"), false);
}
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
return getBoolean(getNode("UseMonthDateTotalsAsPrimaryTotal"), false);
}
public boolean getUUIDLookup() {
return getBoolean(getNode("UUIDLookup"), true);
}
public boolean getGlobalDataEnabled() {
return getBoolean(getNode("GlobalData", "Enabled"), false);
}
@@ -61,6 +77,10 @@ public class Config extends VelocityYMLFile {
return getInt(getNode("Redis", "Port"), 6379);
}
public int getLimitVotePoints() {
return getInt(getNode("LimitVotePoints"), -1);
}
public String getRedisUsername() {
return getString(getNode("Redis", "Username"), "");
}
@@ -40,32 +40,29 @@ public class VoteCache extends VelocityJSONFile {
}
public void addVote(String server, int num, OfflineBungeeVote voteData) {
String[] path = new String[] { "VoteCache", server, "" + num };
getNode(path, "Name").setValue(voteData.getPlayerName());
getNode(path, "Service").setValue(voteData.getService());
getNode(path, "UUID").setValue(voteData.getUuid());
getNode(path, "Time").setValue(voteData.getTime());
getNode(path, "Real").setValue(voteData.isRealVote());
getNode(path, "Text").setValue(voteData.getText());
getNode("VoteCache", server, "" + num, "Name").setValue(voteData.getPlayerName());
getNode("VoteCache", server, "" + num, "Service").setValue(voteData.getService());
getNode("VoteCache", server, "" + num, "UUID").setValue(voteData.getUuid());
getNode("VoteCache", server, "" + num, "Time").setValue(voteData.getTime());
getNode("VoteCache", server, "" + num, "Real").setValue(voteData.isRealVote());
getNode("VoteCache", server, "" + num, "Text").setValue(voteData.getText());
}
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
String[] path = new String[] { "TimedVoteCache", "" + num };
getNode(path, "Name").setValue(voteTimedQueue.getName());
getNode(path, "Service").setValue(voteTimedQueue.getService());
getNode(path, "Time").setValue(voteTimedQueue.getTime());
getNode("TimedVoteCache", "" + num, "Name").setValue(voteTimedQueue.getName());
getNode("TimedVoteCache", "" + num, "Service").setValue(voteTimedQueue.getService());
getNode("TimedVoteCache", "" + num, "Time").setValue(voteTimedQueue.getTime());
}
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
String[] path = new String[] { "OnlineCache", player, "" + num };
getNode(path, "Name").setValue(voteData.getPlayerName());
getNode(path, "Service").setValue(voteData.getService());
getNode(path, "UUID").setValue(voteData.getUuid());
getNode(path, "Time").setValue(voteData.getTime());
getNode(path, "Real").setValue(voteData.isRealVote());
getNode(path, "Text").setValue(voteData.getText());
getNode("OnlineCache", player, "" + num, "Name").setValue(voteData.getPlayerName());
getNode("OnlineCache", player, "" + num, "Service").setValue(voteData.getService());
getNode("OnlineCache", player, "" + num, "UUID").setValue(voteData.getUuid());
getNode("OnlineCache", player, "" + num, "Time").setValue(voteData.getTime());
getNode("OnlineCache", player, "" + num, "Real").setValue(voteData.isRealVote());
getNode("OnlineCache", player, "" + num, "Text").setValue(voteData.getText());
}
public void clearData() {
@@ -99,7 +96,7 @@ public class VoteCache extends VelocityJSONFile {
}
public Collection<String> getServerVotes(String server) {
return getKeys(getNode("OnlineCache", server));
return getKeys(getNode("VoteCache", server));
}
public ConfigurationNode getServerVotes(String server, String num) {
@@ -49,6 +49,7 @@ import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigVelocity;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
@@ -363,6 +364,11 @@ public class VotingPluginVelocity {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
logger.info(text);
}
}, servers) {
@Override
@@ -370,7 +376,7 @@ public class VotingPluginVelocity {
if (type.equals(TimeType.MONTH)) {
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
}
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
for (RegisteredServer s : getAvailableAllServers()) {
getGlobalDataHandler().setBoolean(s.getServerInfo().getName(), "ForceUpdate", true);
@@ -387,6 +393,8 @@ public class VotingPluginVelocity {
@Override
public void onTimeChangedFailed(String server, TimeType type) {
getGlobalDataHandler().setBoolean(server, type.toString(), false);
getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
getGlobalDataHandler().setBoolean(server, "Processing", false);
}
};
} else {
@@ -414,6 +422,11 @@ public class VotingPluginVelocity {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
logger.info(text);
}
}, servers) {
@Override
@@ -421,7 +434,7 @@ public class VotingPluginVelocity {
if (type.equals(TimeType.MONTH)) {
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
}
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
for (RegisteredServer s : getAvailableAllServers()) {
getGlobalDataHandler().setBoolean(s.getServerInfo().getName(), "ForceUpdate", true);
@@ -439,6 +452,8 @@ public class VotingPluginVelocity {
@Override
public void onTimeChangedFailed(String server, TimeType type) {
getGlobalDataHandler().setBoolean(server, type.toString(), false);
getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
getGlobalDataHandler().setBoolean(server, "Processing", false);
}
};
@@ -479,6 +494,13 @@ public class VotingPluginVelocity {
getMysql().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
if (config.getStoreMonthTotalsWithDate()) {
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now()), "INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1)),
"INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2)),
"INT DEFAULT '0'");
}
}
@Subscribe
@@ -497,9 +519,20 @@ public class VotingPluginVelocity {
String server = in.readUTF();
logger.info("Status okay for " + server);
return;
} else if (subchannel.equalsIgnoreCase("TimeChangeFinished")) {
} else if (subchannel.equalsIgnoreCase("login")) {
String player = in.readUTF();
debug("Login: " + player);
String uuid = in.readUTF();
String serverName = "";
if (size > 2) {
serverName = in.readUTF();
}
debug("Login: " + player + "/" + uuid + " " + serverName);
if (nonVotedPlayersCache != null) {
nonVotedPlayersCache.addPlayerCheck(uuid, player);
}
if (server.getPlayer(player).isPresent()
&& (getGlobalDataHandler() == null || !getGlobalDataHandler().isTimeChangedHappened())) {
Player p = server.getPlayer(player).get();
@@ -510,6 +543,14 @@ public class VotingPluginVelocity {
@Override
public void run() {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
}
}
debug("Checking offline votes for " + p.getUsername() + "/"
+ p.getUniqueId().toString());
checkCachedVotes(server);
checkOnlineVotes(p1, p.getUniqueId().toString(), server);
getMultiProxyHandler().login(p1.getUniqueId().toString(), p1.getUsername());
@@ -593,7 +634,11 @@ public class VotingPluginVelocity {
if (mysql != null) {
mysql.shutDown();
}
if (multiProxyHandler != null) {
multiProxyHandler.close();
}
timer.shutdownNow();
bungeeTimeChecker.getTimer().shutdownNow();
enabled = false;
logger.info("VotingPlugin disabled");
}
@@ -654,6 +699,7 @@ public class VotingPluginVelocity {
checkVoteCacheTime();
}
if (!config.getGlobalDataEnabled()) {
getLogger().warn("Global data not enabled, ignoring time change event");
return;
}
for (RegisteredServer s : getAvailableAllServers()) {
@@ -690,6 +736,7 @@ public class VotingPluginVelocity {
}
}
globalDataHandler.onTimeChange(type);
}
@Override
@@ -814,6 +861,7 @@ public class VotingPluginVelocity {
voteCacheFile.save();
}
bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass());
bungeeTimeChecker.loadTimer();
try {
@@ -838,9 +886,11 @@ public class VotingPluginVelocity {
vote.add(new OfflineBungeeVote(data.getNode("Name").getString(),
data.getNode("UUID").getString(), data.getNode("Service").getString(),
data.getNode("Time").getLong(), data.getNode("Real").getBoolean(),
data.getNode("TEXT").getString()));
data.getNode("Text").getString()));
}
if (server.getServer(serverToCheck).isPresent()) {
cachedVotes.put(server.getServer(serverToCheck).get(), vote);
}
cachedVotes.put(server.getServer(serverToCheck).get(), vote);
}
} catch (Exception e) {
e.printStackTrace();
@@ -854,7 +904,7 @@ public class VotingPluginVelocity {
vote.add(new OfflineBungeeVote(data.getNode("Name").getString(),
data.getNode("UUID").getString(), data.getNode("Service").getString(),
data.getNode("Time").getLong(), data.getNode("Real").getBoolean(),
data.getNode("TEXT").getString()));
data.getNode("Text").getString()));
}
cachedOnlineVotes.put(player, vote);
}
@@ -948,6 +998,8 @@ public class VotingPluginVelocity {
if (message[0].equalsIgnoreCase("statusokay")) {
String server = message[1];
getLogger().info("Status okay for " + server);
} else if (message[0].equalsIgnoreCase("TimeChangeFinished")) {
} else if (message[0].equalsIgnoreCase("login")) {
String player = message[1];
String uuid = message[2];
@@ -969,6 +1021,12 @@ public class VotingPluginVelocity {
@Override
public void run() {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
}
}
checkCachedVotes(server);
checkOnlineVotes(p1, p.getUniqueId().toString(), server);
getMultiProxyHandler().login(p1.getUniqueId().toString(),
@@ -1403,6 +1461,15 @@ public class VotingPluginVelocity {
}
}
public String getMonthTotalsWithDatePath() {
LocalDateTime cTime = bungeeTimeChecker.getTime();
return getMonthTotalsWithDatePath(cTime);
}
public String getMonthTotalsWithDatePath(LocalDateTime cTime) {
return "MonthTotal-" + cTime.getMonth().toString() + "-" + cTime.getYear();
}
public synchronized void vote(String player, String service, boolean realVote, boolean timeQueue, long queuedTime,
BungeeMessageData text, String uuid) {
try {
@@ -1410,10 +1477,10 @@ public class VotingPluginVelocity {
logger.info("No name from vote on " + service);
return;
}
if (timeQueue) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
if (timeQueue && getGlobalDataHandler().isTimeChangedHappened()) {
timeChangeQueue.add(new VoteTimeQueue(player, service,
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
getLogger().info("Cachcing vote from " + player + "/" + service
@@ -1429,26 +1496,31 @@ public class VotingPluginVelocity {
if (uuid.isEmpty()) {
if (config.getAllowUnJoined()) {
if (player.startsWith(config.getBedrockPlayerPrefix())) {
logger.info("Ignoring vote since unable to get UUID of bedrock player");
if (config.getUUIDLookup()) {
if (player.startsWith(config.getBedrockPlayerPrefix())) {
logger.info("Ignoring vote since unable to get UUID of bedrock player");
return;
}
debug("Fetching UUID online, since allowunjoined is enabled");
UUID u = null;
try {
if (config.getOnlineMode()) {
u = fetchUUID(player);
}
} catch (Exception e) {
if (getConfig().getDebug()) {
e.printStackTrace();
}
}
if (u == null) {
debug("Failed to get uuid for " + player);
return;
}
uuid = u.toString();
} else {
logger.info("Failed to get uuid for " + player);
return;
}
debug("Fetching UUID online, since allowunjoined is enabled");
UUID u = null;
try {
if (config.getOnlineMode()) {
u = fetchUUID(player);
}
} catch (Exception e) {
if (getConfig().getDebug()) {
e.printStackTrace();
}
}
if (u == null) {
debug("Failed to get uuid for " + player);
return;
}
uuid = u.toString();
} else {
logger.info("Ignoring vote from " + player + " since player hasn't joined before");
return;
@@ -1474,6 +1546,14 @@ public class VotingPluginVelocity {
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
int monthTotal = getValue(data, "MonthTotal", 1);
int dateMonthTotal = -1;
if (config.getStoreMonthTotalsWithDate()) {
if (config.getUseMonthDateTotalsAsPrimaryTotal()) {
dateMonthTotal = getValue(data, getMonthTotalsWithDatePath(), 1);
} else {
dateMonthTotal = monthTotal;
}
}
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
@@ -1487,11 +1567,19 @@ public class VotingPluginVelocity {
monthTotal = days * maxVotes;
}
}
if (getConfig().getLimitVotePoints() > 0) {
if (points > getConfig().getLimitVotePoints()) {
points = getConfig().getLimitVotePoints();
}
}
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
milestoneCount, votePartyVotes, currentVotePartyVotesRequired, dateMonthTotal);
ArrayList<Column> update = new ArrayList<Column>();
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
if (config.getStoreMonthTotalsWithDate()) {
update.add(new Column(getMonthTotalsWithDatePath(), new DataValueInt(dateMonthTotal)));
}
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
update.add(new Column("Points", new DataValueInt(points)));
@@ -1499,7 +1587,7 @@ public class VotingPluginVelocity {
debug("Setting totals " + text.toString());
mysql.update(uuid, update);
} else {
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired, 0);
}
}
@@ -1,9 +1,7 @@
package com.bencodez.votingplugin.commands;
import java.io.IOException;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
@@ -39,7 +37,6 @@ import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener;
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
import com.bencodez.advancedcore.api.yml.editor.ConfigEditor;
import com.bencodez.advancedcore.api.yml.updater.ConfigUpdater;
import com.bencodez.advancedcore.command.gui.UserGUI;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.command.TabCompleteHandle;
@@ -69,6 +66,7 @@ import com.bencodez.votingplugin.commands.gui.player.VoteStreak;
import com.bencodez.votingplugin.commands.gui.player.VoteToday;
import com.bencodez.votingplugin.commands.gui.player.VoteTopVoter;
import com.bencodez.votingplugin.commands.gui.player.VoteTopVoterLastMonth;
import com.bencodez.votingplugin.commands.gui.player.VoteTopVoterPreviousMonths;
import com.bencodez.votingplugin.commands.gui.player.VoteTotal;
import com.bencodez.votingplugin.commands.gui.player.VoteURL;
import com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite;
@@ -327,6 +325,43 @@ public class CommandLoader {
}
});
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "PauseRewards" },
"VotingPlugin.Commands.AdminVote.PauseRewards|" + adminPerm, "Pause rewards globally") {
@Override
public void execute(CommandSender sender, String[] args) {
if (!plugin.getOptions().isPauseRewards()) {
plugin.getOptions().setPauseRewards(true);
sendMessage(sender,
"&cRewards paused, note server restart will reset pause, resume with /av resumerewards");
} else {
sendMessage(sender, "&cRewards already paused, use /av resumerewards to resume");
}
}
});
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "ResumeRewards" },
"VotingPlugin.Commands.AdminVote.ResumeRewards|" + adminPerm, "Resume rewards globally") {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getOptions().isPauseRewards()) {
plugin.getOptions().setPauseRewards(false);
for (Player p : Bukkit.getOnlinePlayers()) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
user.offVote();
user.checkOfflineRewards();
}
plugin.setUpdate(true);
sendMessage(sender, "&aRewards resumed");
} else {
sendMessage(sender, "&aRewards already resumed");
}
}
});
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "ResetMilestoneCount" },
"VotingPlugin.Commands.AdminVote.ResetMilestoneCount|" + adminPerm, "Resets milestone count to 0") {
@@ -689,6 +724,7 @@ public class CommandLoader {
+ "Detected that server hasn't received any votes from votifier, please check votifier connection");
}
if (!plugin.getConfigFile().isDisableUpdateChecking()
&& !plugin.getDescription().getVersion().endsWith("SNAPSHOT") && plugin.getUpdater() != null
&& plugin.getUpdater().getResult().equals(Updater.UpdateResult.UPDATE_AVAILABLE)) {
sendMessage(sender,
"&3Plugin has update available! https://www.spigotmc.org/resources/votingplugin.15358/");
@@ -716,6 +752,7 @@ public class CommandLoader {
+ "Detected that server hasn't received any votes from votifier, please check votifier connection");
}
if (!plugin.getConfigFile().isDisableUpdateChecking()
&& !plugin.getDescription().getVersion().endsWith("SNAPSHOT") && plugin.getUpdater() != null
&& plugin.getUpdater().getResult().equals(Updater.UpdateResult.UPDATE_AVAILABLE)) {
sendMessage(sender,
"&3Plugin has update available! https://www.spigotmc.org/resources/votingplugin.15358/");
@@ -756,7 +793,7 @@ public class CommandLoader {
sendMessage(sender, "AdvancedCore Jenkins build number: " + plugin.getAdvancedCoreBuildNumber());
}
if (!plugin.getBuildNumber().equals("NOTSET")) {
sendMessage(sender, "Using votingplugin jenkins build: " + plugin.getBuildNumber());
sendMessage(sender, "Using VotingPlugin jenkins build: " + plugin.getBuildNumber());
}
}
});
@@ -831,7 +868,6 @@ public class CommandLoader {
sender.sendMessage(MessageAPI.colorize("&cThis command can not be done from ingame"));
return;
}
for (TopVoter top : TopVoter.values()) {
plugin.getUserManager().removeAllKeyValues(top.getColumnName(), DataType.INTEGER);
}
@@ -841,6 +877,31 @@ public class CommandLoader {
}
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(plugin, new String[] { "ResetTotal", "(TopVoter)" },
"VotingPlugin.Commands.AdminVote.ResetTotal.All|" + adminPerm,
"Reset specific totals for all players (DAY/WEEK/MONTH)") {
@Override
public void execute(CommandSender sender, String[] args) {
if (sender instanceof Player) {
sender.sendMessage(MessageAPI.colorize("&cThis command can not be done from ingame"));
return;
}
TopVoter top = TopVoter.getTopVoter(args[1]);
if (top.equals(TopVoter.AllTime)) {
sendMessage(sender, "&cCan't reset all time total or invalid argument: " + args[1]);
return;
}
plugin.getUserManager().removeAllKeyValues(top.getColumnName(), DataType.INTEGER);
plugin.getUserManager().getDataManager().clearCache();
plugin.setUpdate(true);
sender.sendMessage(MessageAPI.colorize("&cCleared totals of " + top.getColumnName()));
}
});
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "ClearOfflineVoteRewards" },
"VotingPlugin.Commands.AdminVote.ClearOfflineVoteRewards|" + adminPerm, "Reset offline votes/rewards") {
@@ -1053,7 +1114,8 @@ public class CommandLoader {
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(),
false);
if (voteEvent.getVoteSite() != null) {
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
if (!voteEvent.getVoteSite().isVaidServiceSite()
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
sendMessage(sender,
"&cPossible issue with service site, has the server gotten the vote from "
+ voteEvent.getServiceSite() + "?");
@@ -1079,11 +1141,14 @@ public class CommandLoader {
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1], args[2],
false);
if (voteEvent.getVoteSite() != null) {
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
if (!voteEvent.getVoteSite().isVaidServiceSite()
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
sendMessage(sender, "&cPossible issue with service site, has the server gotten the vote from "
+ voteEvent.getServiceSite() + "?");
}
sendMessage(sender, "&cTriggering vote...");
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage() && !isPlayer(sender)) {
sendMessage(sender, "&cTriggering vote...");
}
plugin.getVoteTimer().submit(new Runnable() {
@@ -1110,9 +1175,12 @@ public class CommandLoader {
public void execute(CommandSender sender, String[] args) {
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1],
args[2], false);
sendMessage(sender, "&cTriggering vote...");
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage() && !isPlayer(sender)) {
sendMessage(sender, "&cTriggering vote...");
}
if (voteEvent.getVoteSite() != null) {
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
if (!voteEvent.getVoteSite().isVaidServiceSite()
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
sendMessage(sender,
"&cPossible issue with service site, has the server gotten the vote from "
+ voteEvent.getServiceSite() + "?");
@@ -1162,7 +1230,8 @@ public class CommandLoader {
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(),
false);
if (voteEvent.getVoteSite() != null) {
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
if (!voteEvent.getVoteSite().isVaidServiceSite()
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
sendMessage(sender,
"&cPossible issue with service site, has the server gotten the vote from "
+ voteEvent.getServiceSite() + "?");
@@ -1186,9 +1255,12 @@ public class CommandLoader {
public void execute(CommandSender sender, String[] args) {
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[3], true), args[1],
args[3], false);
sendMessage(sender, "&cTriggering vote...");
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage() && !isPlayer(sender)) {
sendMessage(sender, "&cTriggering vote...");
}
if (voteEvent.getVoteSite() != null) {
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
if (!voteEvent.getVoteSite().isVaidServiceSite()
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
sendMessage(sender,
"&cPossible issue with service site, has the server gotten the vote from "
+ voteEvent.getServiceSite() + "?");
@@ -1251,24 +1323,6 @@ public class CommandLoader {
}
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(plugin, new String[] { "Config", "Update" },
"VotingPlugin.Commands.AdminVote.Config.Edit|" + adminPerm,
"Force update Config.yml with new options") {
@Override
public void execute(CommandSender sender, String[] args) {
try {
ConfigUpdater.update(plugin, "Config.yml", plugin.getConfigFile().getdFile(), Arrays
.asList("VoteReminding", "MySQL", "CustomCommands", "CustomPlaceholderReturns"));
plugin.getConfigFile().reloadData();
} catch (IOException e) {
e.printStackTrace();
}
sendMessage(sender, "&aUpdated config");
}
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(plugin, new String[] { "VoteSite", "(sitename)", "SetServiceSite", "(string)" },
"VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Set VoteSite SerivceSite") {
@@ -1563,7 +1617,7 @@ public class CommandLoader {
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getRewardHandler().giveReward(user, plugin.getConfigFile().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(args[3]), new RewardOptions());
plugin.getShopFile().getShopIdentifierRewardsPath(args[3]), new RewardOptions());
sendMessage(sender, "&cVoteShop " + args[3] + " forced");
}
});
@@ -1630,15 +1684,19 @@ public class CommandLoader {
plugin.getAdminVoteCommand()
.add(new CommandHandler(plugin,
new String[] { "User", "(player)", "ForceVoteStreak", str, "(Number)" },
new String[] { "User", "(player)", "ForceVoteStreak", str, "(Text)" },
"VotingPlugin.Commands.AdminVote.ForceVoteStreak|" + adminPerm,
"Force a votestreak reward for " + str) {
@Override
public void execute(CommandSender sender, String[] args) {
String num = args[4];
if (num.contains("-")) {
num = num.replaceAll("-", "");
}
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveVoteStreakReward(user, user.isOnline(), str, args[4],
parseInt(args[4]), plugin.getBungeeSettings().isUseBungeecoord());
parseInt(num), plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cVoteStreak " + str + " " + args[4] + " forced");
}
});
@@ -1710,6 +1768,17 @@ public class CommandLoader {
}
});
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "PurgeNoData" },
"VotingPlugin.PurgeNoData",
"Purge players from database with no data and haven't been online for a number of days (Set in Config.yml)") {
@Override
public void execute(CommandSender sender, String[] args) {
plugin.getVotingPluginUserManager().purgeOldPlayersNowNoData();
sendMessage(sender, "&cPurged players with no data");
}
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(plugin, new String[] { "RemoveOfflineUUIDs" },
"VotingPlugin.Commands.AdminVote.RemoveOfflineUUIDs|" + adminPerm,
@@ -2069,7 +2138,7 @@ public class CommandLoader {
@Override
public void reload() {
ArrayList<String> sites = new ArrayList<String>();
for (String str : plugin.getGui().getChestShopIdentifiers()) {
for (String str : plugin.getShopFile().getShopIdentifiers()) {
sites.add(str);
}
setReplace(sites);
@@ -2150,7 +2219,7 @@ public class CommandLoader {
}
});
if (plugin.getGui().isChestVoteShopEnabled()) {
if (plugin.getShopFile().isVoteShopEnabled()) {
plugin.getVoteCommand().add(new CommandHandler(plugin, new String[] { "Shop" },
"VotingPlugin.Commands.Vote.Shop|" + playerPerm, "Open VoteShop GUI", false) {
@@ -2165,13 +2234,13 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (!plugin.getGui().isChestVoteShopEnabled()) {
if (!plugin.getShopFile().isVoteShopEnabled()) {
sender.sendMessage(MessageAPI.colorize("&cVote shop disabled"));
return;
}
String identifier = args[1];
Set<String> identifiers = plugin.getGui().getChestShopIdentifiers();
Set<String> identifiers = plugin.getShopFile().getShopIdentifiers();
if (ArrayUtils.containsIgnoreCase(identifiers, identifier)) {
for (String ident : identifiers) {
if (ident.equalsIgnoreCase(args[1])) {
@@ -2179,7 +2248,7 @@ public class CommandLoader {
}
}
String perm = plugin.getGui().getChestVoteShopPermission(identifier);
String perm = plugin.getShopFile().getVoteShopPermission(identifier);
boolean hasPerm = false;
if (perm.isEmpty()) {
hasPerm = true;
@@ -2187,7 +2256,7 @@ public class CommandLoader {
hasPerm = sender.hasPermission(perm);
}
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
int limit = plugin.getShopFile().getShopIdentifierLimit(identifier);
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(sender.getName());
@@ -2199,12 +2268,12 @@ public class CommandLoader {
}
}
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
if (!plugin.getShopFile().getVoteShopNotBuyable(identifier)) {
if (hasPerm) {
if (plugin.getConfigFile().isExtraVoteShopCheck()) {
user.cache();
}
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
int points = plugin.getShopFile().getShopIdentifierCost(identifier);
if (identifier != null) {
if (limitPass) {
@@ -2214,8 +2283,8 @@ public class CommandLoader {
placeholders.put("limit", "" + limit);
if (user.removePoints(points, true)) {
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
plugin.getRewardHandler().giveReward(user, plugin.getShopFile().getData(),
plugin.getShopFile().getShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
@@ -2229,7 +2298,7 @@ public class CommandLoader {
plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
}
} else {
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
user.sendMessage(plugin.getShopFile().getVoteShopLimitReached());
}
}
@@ -2408,6 +2477,21 @@ public class CommandLoader {
});
}
if (plugin.getConfigFile().isStoreMonthTotalsWithDate()
|| plugin.getOptions().getDebug().equals(DebugLevel.DEV)) {
plugin.getVoteCommand()
.add(new CommandHandler(plugin, new String[] { "PreviousMonthsTotals" },
"VotingPlugin.Commands.Vote.PreviousMonthsTotals",
"Open list of Top Voters from all known previous months") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTopVoterPreviousMonths(plugin, sender,
plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender), 0).open();
}
});
}
plugin.getVoteCommand().add(new CommandHandler(plugin, new String[] { "Top" },
"VotingPlugin.Commands.Vote.Top|" + playerPerm, "Open list of Top Voters") {
@@ -2645,10 +2729,10 @@ public class CommandLoader {
placeholders.put("touser", "" + user.getPlayerName());
placeholders.put("fromuser", "" + cPlayer.getPlayerName());
sendMessage(sender,
PlaceholderUtils
.replacePlaceHolder(plugin.getConfigFile()
PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile()
.getFormatCommandsVoteGivePointsTransferFrom(),
placeholders));
placeholders));
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteGivePointsTransferTo(),
placeholders));
@@ -59,7 +59,7 @@ public class AdminVoteVoteShop extends GUIHandler {
@Override
public void onInput(Player player, String value) {
plugin.getGui().createShop(value);
plugin.getShopFile().createShop(value);
plugin.reload();
}
});
@@ -53,7 +53,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
// to add
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Identifier_Name",
plugin.getGui().getChestShopIdentifierIdentifierName(identifier)) {
plugin.getShopFile().getShopIdentifierIdentifierName(identifier)) {
@Override
public void setValue(Player player, String name) {
@@ -61,7 +61,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.OAK_DOOR, 1),
new EditGUIValueString("Permission", plugin.getGui().getChestVoteShopPermission(identifier)) {
new EditGUIValueString("Permission", plugin.getShopFile().getVoteShopPermission(identifier)) {
@Override
public void setValue(Player player, String name) {
@@ -69,7 +69,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1),
new EditGUIValueNumber("Cost", plugin.getGui().getChestShopIdentifierCost(identifier)) {
new EditGUIValueNumber("Cost", plugin.getShopFile().getShopIdentifierCost(identifier)) {
@Override
public void setValue(Player player, Number num) {
@@ -77,7 +77,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.BARRIER, 1),
new EditGUIValueNumber("Limit", plugin.getGui().getChestShopIdentifierLimit(identifier)) {
new EditGUIValueNumber("Limit", plugin.getShopFile().getShopIdentifierLimit(identifier)) {
@Override
public void setValue(Player player, Number num) {
@@ -86,7 +86,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}));
// display item
ConfigurationSection displayItemData = plugin.getGui().getChestShopIdentifierSection(identifier);
ConfigurationSection displayItemData = plugin.getShopFile().getShopIdentifierSection(identifier);
inv.addButton(new EditGUIButton(new ItemBuilder(displayItemData.getString("Material")).setAmount(1),
new EditGUIValueString("Material", displayItemData.getString("Material")) {
@@ -156,8 +156,8 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}
private void setPathData(String path, Object value) {
plugin.getGui().getData().set("CHEST.Shop." + identifier + "." + path, value);
plugin.getGui().saveData();
plugin.getShopFile().getData().set("Shop." + identifier + "." + path, value);
plugin.getShopFile().saveData();
plugin.reload();
}
@@ -42,9 +42,9 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
BInventory inv = new BInventory("Edit VoteShop Remove Item");
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
inv.addButton(
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier))
new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier))
.addLoreLine("&c&lClick to remove")) {
@Override
@@ -54,7 +54,7 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
@Override
public void onConfirm(Player p) {
plugin.getGui().removeShop(identifier);
plugin.getShopFile().removeShop(identifier);
p.sendMessage("Removed " + identifier);
plugin.reload();
}
@@ -65,7 +65,6 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
}
}.open();
}
}.addData("ident", identifier));
}
@@ -41,9 +41,9 @@ public class AdminVoteVoteShopItems extends GUIHandler {
BInventory inv = new BInventory("Edit VoteShop Items");
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
for (String identifier : plugin.getGui().getChestShopIdentifiers()) {
for (String identifier : plugin.getShopFile().getShopIdentifiers()) {
inv.addButton(
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier))) {
new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier))) {
@Override
public void onClick(ClickEvent clickEvent) {
@@ -46,8 +46,8 @@ public class VoteShop extends GUIHandler {
@Override
public void onChest(Player player) {
if (!plugin.getGui().isChestVoteShopEnabled()) {
player.sendMessage(MessageAPI.colorize(plugin.getGui().getChestVoteShopDisabled()));
if (!plugin.getShopFile().isVoteShopEnabled()) {
player.sendMessage(MessageAPI.colorize(plugin.getShopFile().getVoteShopDisabled()));
return;
}
@@ -58,26 +58,33 @@ public class VoteShop extends GUIHandler {
/*
* if (!plugin.getConfigFile().isExtraVoteShopCheck()) { user.cacheAsync(); }
*/
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
BInventory inv = new BInventory(plugin.getShopFile().getVoteShopName());
inv.addPlaceholder("points", "" + user.getPoints());
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
inv.dontClose();
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
String perm = plugin.getGui().getChestVoteShopPermission(identifier);
String perm = plugin.getShopFile().getVoteShopPermission(identifier);
boolean hasPerm = false;
if (perm.isEmpty()) {
hasPerm = true;
} else {
String p = "";
if (perm.startsWith("!")) {
hasPerm = !player.hasPermission(perm.substring(1));
p = PlaceholderUtils.replacePlaceHolders(player, perm.substring(1));
hasPerm = !player.hasPermission(p);
} else {
hasPerm = player.hasPermission(perm);
p = PlaceholderUtils.replacePlaceHolders(player, perm);
hasPerm = player.hasPermission(p);
}
if (!hasPerm) {
plugin.extraDebug("VoteShop: " + player.getName() + "/" + player.getUniqueId()
+ " does not have permission `" + p + "` for " + identifier);
}
}
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
int limit = plugin.getShopFile().getShopIdentifierLimit(identifier);
boolean limitPass = true;
if (limit > 0) {
@@ -86,10 +93,10 @@ public class VoteShop extends GUIHandler {
}
}
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
if ((hasPerm || !plugin.getGui().getChestVoteShopHideOnNoPermission(identifier))
&& (limitPass || !plugin.getGui().isChestVoteShopHideLimitedReached())) {
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
if (!plugin.getShopFile().getVoteShopNotBuyable(identifier)) {
if ((hasPerm || !plugin.getShopFile().getVoteShopHideOnNoPermission(identifier))
&& (limitPass || !plugin.getShopFile().isVoteShopHideLimitedReached())) {
ItemBuilder builder = new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier));
inv.addButton(new BInventoryButton(builder) {
@@ -104,7 +111,7 @@ public class VoteShop extends GUIHandler {
String identifier = (String) getData("identifier");
int limit = (int) getData("Limit");
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
int points = plugin.getShopFile().getShopIdentifierCost(identifier);
if (identifier != null) {
// if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
// event.closeInventory();
@@ -119,10 +126,10 @@ public class VoteShop extends GUIHandler {
}
if (limitPass) {
if (!plugin.getGui().isChestVoteShopRequireConfirmation(identifier)) {
if (!plugin.getShopFile().isVoteShopRequireConfirmation(identifier)) {
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("identifier",
plugin.getGui().getChestShopIdentifierIdentifierName(identifier));
plugin.getShopFile().getShopIdentifierIdentifierName(identifier));
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
if (user.removePoints(points, true)) {
@@ -132,12 +139,12 @@ public class VoteShop extends GUIHandler {
plugin.getServerData().addVoteShopPurchase(identifier);
}
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
plugin.getRewardHandler().giveReward(user, plugin.getShopFile().getData(),
plugin.getShopFile().getShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
plugin.getGui().getCHESTVoteShopPurchase(identifier),
plugin.getShopFile().getVoteShopPurchase(identifier),
placeholders));
if (limit > 0) {
user.setVoteShopIdentifierLimit(identifier,
@@ -159,10 +166,10 @@ public class VoteShop extends GUIHandler {
}
} else {
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
user.sendMessage(plugin.getShopFile().getVoteShopLimitReached());
}
plugin.getCommandLoader().processSlotClick(player, user, identifier);
if (plugin.getGui().isChestVoteShopReopenGUIOnPurchase()) {
if (plugin.getShopFile().isVoteShopReopenGUIOnPurchase()) {
plugin.getCommandLoader().processSlotClick(player, user, "shop");
}
}
@@ -172,7 +179,7 @@ public class VoteShop extends GUIHandler {
}
} else {
if (hasPerm) {
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
ItemBuilder builder = new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier));
inv.addButton(new BInventoryButton(builder) {
@Override
@@ -185,20 +192,20 @@ public class VoteShop extends GUIHandler {
}
}
for (final String str : plugin.getGui().getChestGUIVoteShopExtraItems()) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIVoteShopExtraItems(str))) {
for (final String str : plugin.getShopFile().getVoteShopExtraItems()) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getGUIVoteShopExtraItems(str))) {
@Override
public void onClick(ClickEvent clickEvent) {
plugin.getCommandLoader().processSlotClick(player, user, str);
new RewardBuilder(plugin.getGui().getData(),
"CHEST.VoteShopExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
new RewardBuilder(plugin.getShopFile().getData(),
"ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
.setGiveOffline(false).send(clickEvent.getPlayer());
}
});
}
if (plugin.getGui().isChestVoteShopBackButton()) {
if (plugin.getShopFile().isVoteShopBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
@@ -47,15 +47,15 @@ public class VoteShopConfirm extends GUIHandler {
@Override
public void onChest(Player player) {
PlayerUtils.setPlayerMeta(plugin, player, "ident", identifier);
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
BInventory inv = new BInventory(plugin.getShopFile().getShopConfirmPurchaseTitle());
inv.dontClose();
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseYesItem())) {
@Override
public void onClick(ClickEvent event) {
user.cache();
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
int points = plugin.getShopFile().getShopIdentifierCost(identifier);
int limit = plugin.getShopFile().getShopIdentifierLimit(identifier);
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("identifier", identifier);
placeholders.put("points", "" + points);
@@ -67,12 +67,12 @@ public class VoteShopConfirm extends GUIHandler {
plugin.getServerData().addVoteShopPurchase(identifier);
}
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
plugin.getRewardHandler().giveReward(user, plugin.getShopFile().getData(),
plugin.getShopFile().getShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
user.sendMessage(PlaceholderUtils
.replacePlaceHolder(plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
.replacePlaceHolder(plugin.getShopFile().getVoteShopPurchase(identifier), placeholders));
if (limit > 0) {
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
}
@@ -80,7 +80,7 @@ public class VoteShopConfirm extends GUIHandler {
user.sendMessage(PlaceholderUtils
.replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
}
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
if (plugin.getShopFile().getVoteShopCloseGUI(identifier)) {
event.getButton().getInv().closeInv(player, null);
} else {
new VoteShop(plugin, event.getPlayer(), user).open();
@@ -88,11 +88,11 @@ public class VoteShopConfirm extends GUIHandler {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseNoItem())) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseNoItem())) {
@Override
public void onClick(ClickEvent event) {
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
if (plugin.getShopFile().getVoteShopCloseGUI(identifier)) {
event.getButton().getInv().closeInv(player, null);
} else {
new VoteShop(plugin, event.getPlayer(), user).open();
@@ -101,8 +101,8 @@ public class VoteToday extends GUIHandler {
} else {
item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
}
item.setName(PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
"player", user.getPlayerName()));
item.setName(PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(), "player",
user.getPlayerName()));
item.setLore(msg);
final UUID uuid = user.getUuid();
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
@@ -116,24 +116,30 @@ public class VoteToday extends GUIHandler {
});
}
}
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());
@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);
}
});}
if(plugin.getGui().isChestVoteTodayBackButton()){inv.addButton(plugin.getCommandLoader().getBackButton(user));}inv.openInventory(player);}
@Override
public void open() {
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodToday().toUpperCase()));
@@ -150,8 +156,8 @@ public class VoteToday extends GUIHandler {
placeholders.put("player", user.getPlayerName());
placeholders.put("votesite", voteSite.getKey());
placeholders.put("time", timeString);
msg.add(PlaceholderUtils
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
placeholders));
// msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
// timeString);
}
@@ -179,8 +185,8 @@ public class VoteToday extends GUIHandler {
placeholders.put("player", user.getPlayerName());
placeholders.put("votesite", mostRecentSite.getKey());
placeholders.put("time", timeString);
msg.add(PlaceholderUtils
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
placeholders));
}
}
msg = ArrayUtils.colorize(msg);
@@ -0,0 +1,150 @@
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 ArrayList<String> getChat(CommandSender arg0) {
return null;
}
@Override
public void onBook(Player player) {
// TODO
}
@Override
public void onChat(CommandSender sender) {
}
public void next(int index) {
}
@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;
} else {
if (yearMonthList.size() > index) {
yearMonth = yearMonthList.get(index);
} else {
player.sendMessage(ChatColor.RED + "Can't open previous months, no data for requested index");
return;
}
}
Set<Entry<TopVoterPlayer, Integer>> users = null;
if (plugin.getPreviousMonthsTopVoters().containsKey(yearMonth)) {
users = plugin.getPreviousMonthsTopVoters().get(yearMonth).entrySet();
} else {
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
return;
}
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<String>());
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);
}
}
@@ -7,6 +7,7 @@ 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;
@@ -50,7 +51,11 @@ public class VoteURL extends GUIHandler {
}
@Override
public ArrayList<String> getChat(CommandSender arg0) {
public ArrayList<String> getChat(CommandSender sender) {
return getChat(sender, false);
}
public ArrayList<String> getChat(CommandSender sender, boolean bypassCanVote) {
ArrayList<String> sites = new ArrayList<String>();
List<String> title = plugin.getConfigFile().getFormatCommandsVoteText();
@@ -61,16 +66,25 @@ public class VoteURL extends GUIHandler {
int counter = 0;
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
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));
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());
}
}
sites.add(message.colorize().getText());
}
}
}
@@ -141,20 +155,25 @@ public class VoteURL extends GUIHandler {
}
int i = 1;
for (VoteSite site : plugin.getVoteSitesEnabled()) {
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename",
site.getDisplayName());
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();
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++;
}
}
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);
@@ -178,7 +197,12 @@ public class VoteURL extends GUIHandler {
public void onClick(ClickEvent event) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(event.getPlayer());
json = true;
user.sendMessage(getChat(player));
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
@@ -191,42 +215,46 @@ public class VoteURL extends GUIHandler {
int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
ItemBuilder builder = getItemVoteSite(voteSite);
if (startSlot >= 0) {
builder.setSlot(startSlot);
startSlot++;
}
if (voteSite.getPermissionToView().isEmpty() || player.hasPermission(voteSite.getPermissionToView())) {
ItemBuilder builder = getItemVoteSite(voteSite);
if (startSlot >= 0) {
builder.setSlot(startSlot);
startSlot++;
}
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
HashMap<String, String> placeholders = new HashMap<String, String>();
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 void onClick(ClickEvent event) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
HashMap<String, String> placeholders = new HashMap<String, String>();
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);
}
@Override
public ItemBuilder onUpdate(Player player) {
return getItemVoteSite(voteSite);
}
});
});
}
}
}
for (final String str : plugin.getGui().getChestVoteURLExtraItems()) {
for (
final String str : plugin.getGui().getChestVoteURLExtraItems()) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteURLExtraItemsItem(str))) {
@Override
@@ -3,7 +3,7 @@ package com.bencodez.votingplugin.config;
import java.io.File;
import java.util.ArrayList;
import com.bencodez.advancedcore.api.yml.YMLFile;
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;
@@ -7,8 +7,8 @@ import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.bencodez.advancedcore.api.yml.YMLFile;
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;
@@ -39,10 +39,18 @@ public class Config extends YMLFile {
@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;
@ConfigDataBoolean(path = "QueueVotesDuringTimeChange")
@Getter
private boolean queueVotesDuringTimeChange = false;
@@ -381,6 +389,10 @@ public class Config extends YMLFile {
@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<String>();
@@ -651,13 +663,17 @@ public class Config extends YMLFile {
@Getter
private int pointsOnVote = 1;
@ConfigDataInt(path = "PurgeMin")
@ConfigDataBoolean(path = "PurgeNoDataOnStartup")
@Getter
private int purgeMin = 90;
private boolean purgeNoDataOnStartup = false;
@ConfigDataBoolean(path = "PurgeOldData")
@ConfigDataBoolean(path = "StoreMonthTotalsWithDate")
@Getter
private boolean purgeOldData = false;
private boolean storeMonthTotalsWithDate = false;
@ConfigDataBoolean(path = "UseMonthDateTotalsAsPrimaryTotal")
@Getter
private boolean useMonthDateTotalsAsPrimaryTotal = false;
@ConfigDataString(path = "RequestAPI.DefaultMethod")
@Getter
@@ -14,7 +14,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
import com.bencodez.advancedcore.api.yml.YMLFile;
import com.bencodez.simpleapi.file.YMLFile;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
@@ -103,8 +103,8 @@ public class ConfigVoteSites extends YMLFile {
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"));
p.sendMessage(MessageAPI.colorize("&cGenerating votesite for service site " + siteName
+ ", please check console for details"));
}
}
}
@@ -298,6 +298,10 @@ public class ConfigVoteSites extends YMLFile {
return siteNames;
}
public String getPermissionToView(String siteName) {
return getData(siteName).getString("PermissionToView", "");
}
/**
* Gets the vote URL.
*
@@ -7,7 +7,7 @@ import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.bencodez.advancedcore.api.yml.YMLFile;
import com.bencodez.simpleapi.file.YMLFile;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
@@ -56,34 +56,6 @@ public class GUI extends YMLFile {
@Getter
private String bookVoteURLBookGUITitle = "&cVoteURL";
@Getter
@ConfigDataConfigurationSection(path = "CHEST.ShopConfirmPurchase.NoItem")
private ConfigurationSection chestShopConfirmPurchaseNoItem;
@Getter
@ConfigDataString(path = "CHEST.ShopConfirmPurchase.Title")
private String chestShopConfirmPurchaseTitle = "Confirm Purchase?";
@Getter
@ConfigDataConfigurationSection(path = "CHEST.ShopConfirmPurchase.YesItem")
private ConfigurationSection chestShopConfirmPurchaseYesItem;
@Getter
@ConfigDataString(path = "CHEST.VoteShopDisabled")
private String chestVoteShopDisabled = "&cVote shop disabled";
@ConfigDataBoolean(path = "CHEST.VoteShopHideLimitedReached")
@Getter
private boolean chestVoteShopHideLimitedReached = true;
@ConfigDataString(path = "CHEST.VoteShopLimitReached")
@Getter
private String chestVoteShopLimitReached = "&aYou reached your limit";
@ConfigDataBoolean(path = "CHEST.VoteShopRequireConfirmation")
@Getter
private boolean chestVoteShopRequireConfirmation = false;
@ConfigDataBoolean(path = "CHEST.VoteBest.BackButton")
@Getter
private boolean chestVoteBestBackButton = true;
@@ -167,54 +139,10 @@ public class GUI extends YMLFile {
this.plugin = plugin;
}
public void createShop(String value) {
ConfigurationSection shopData = getData().createSection("CHEST.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();
}
@ConfigDataConfigurationSection(path = "CHEST.BackButton")
@Getter
private ConfigurationSection CHESTBackButton;
public int getChestShopIdentifierCost(String identifier) {
return getData().getInt("CHEST.Shop." + identifier + ".Cost");
}
public String getChestShopIdentifierIdentifierName(String identifier) {
return getData().getString("CHEST.Shop." + identifier + ".Identifier_Name", identifier);
}
public int getChestShopIdentifierLimit(String identifier) {
return getData().getInt("CHEST.Shop." + identifier + ".Limit", -1);
}
public String getChestShopIdentifierRewardsPath(String identifier) {
return "CHEST.Shop." + identifier + ".Rewards";
}
public Set<String> getChestShopIdentifiers() {
ConfigurationSection shop = getData().getConfigurationSection("CHEST.Shop");
if (shop != null) {
return shop.getKeys(false);
}
return new HashSet<String>();
}
public ConfigurationSection getChestShopIdentifierSection(String identifier) {
return getData().getConfigurationSection("CHEST.Shop." + identifier);
}
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.DayBest.Item")
@Getter
private ConfigurationSection chestVoteBestDayBestItem;
@@ -246,6 +174,10 @@ public class GUI extends YMLFile {
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
}
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
}
/**
* Gets the vote GUI slot lore.
*
@@ -315,55 +247,6 @@ public class GUI extends YMLFile {
@Getter
private String chestVoteRewardName = "VoteReward";
@ConfigDataBoolean(path = "CHEST.VoteShopBackButton")
@Getter
private boolean chestVoteShopBackButton = true;
@ConfigDataBoolean(path = "CHEST.VoteShopReopenGUIOnPurchase")
@Getter
private boolean chestVoteShopReopenGUIOnPurchase = true;
public boolean getChestVoteShopCloseGUI(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".CloseGUI", true);
}
public boolean getChestVoteShopHideOnNoPermission(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".HideOnNoPermission", true);
}
@ConfigDataBoolean(path = "CHEST.VoteShopEnabled")
@Getter
private boolean chestVoteShopEnabled = true;
@ConfigDataString(path = "CHEST.VoteShopName")
@Getter
private String chestVoteShopName = "VoteShop";
public boolean getChestVoteShopNotBuyable(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".NotBuyable", false);
}
public String getChestVoteShopPermission(String ident) {
return getData().getString("CHEST.Shop." + ident + ".Permission", "");
}
public String getCHESTVoteShopPurchase(String identifier) {
return getData().getString("CHEST.Shop." + identifier + ".PurchaseMessage",
plugin.getConfigFile().getFormatShopPurchaseMsg());
}
public boolean getChestVoteShopResetDaily(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Daily", false);
}
public boolean getChestVoteShopResetMonthly(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Monthly", false);
}
public boolean getChestVoteShopResetWeekly(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Weekly", false);
}
@ConfigDataBoolean(path = "CHEST.VoteStreak.BackButton")
@Getter
private boolean chestVoteStreakBackButton = false;
@@ -523,18 +406,6 @@ public class GUI extends YMLFile {
return new HashSet<String>();
}
public ConfigurationSection getChestGUIVoteShopExtraItems(String item) {
return getData().getConfigurationSection("CHEST.VoteShopExtraItems." + item);
}
@ConfigDataKeys(path = "CHEST.VoteShopExtraItems")
@Getter
private Set<String> chestGUIVoteShopExtraItems = new HashSet<String>();
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
}
@ConfigDataString(path = "CHEST.VoteURL.SiteName")
@Getter
private String chestVoteURLGUISiteName = "&c%Name%";
@@ -567,11 +438,6 @@ public class GUI extends YMLFile {
@Getter
private boolean chestVoteURLViewAllUrlsButtonEnabled = false;
public boolean isChestVoteShopRequireConfirmation(String identifier) {
return getData().getBoolean("CHEST.Shop." + identifier + ".RequireConfirmation",
isChestVoteShopRequireConfirmation());
}
@Override
public void loadValues() {
new AnnotationHandler().load(getData(), this);
@@ -581,9 +447,4 @@ public class GUI extends YMLFile {
public void onFileCreation() {
plugin.saveResource("GUI.yml", true);
}
public void removeShop(String value) {
getData().set("CHEST.Shop." + value, null);
saveData();
}
}
@@ -0,0 +1,198 @@
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;
public class ShopFile extends YMLFile {
@Getter
@ConfigDataConfigurationSection(path = "ShopConfirmPurchase.NoItem")
private ConfigurationSection shopConfirmPurchaseNoItem;
@Getter
@ConfigDataString(path = "ShopConfirmPurchase.Title")
private String shopConfirmPurchaseTitle = "Confirm Purchase?";
@Getter
@ConfigDataConfigurationSection(path = "ShopConfirmPurchase.YesItem")
private ConfigurationSection shopConfirmPurchaseYesItem;
@Getter
@ConfigDataString(path = "VoteShop.Disabled")
private String voteShopDisabled = "&cVote shop disabled";
@ConfigDataBoolean(path = "VoteShop.HideLimitedReached")
@Getter
private boolean voteShopHideLimitedReached = true;
@ConfigDataString(path = "VoteShop.LimitReached")
@Getter
private String voteShopLimitReached = "&aYou reached your limit";
@ConfigDataBoolean(path = "VoteShop.RequireConfirmation")
@Getter
private boolean voteShopRequireConfirmation = false;
private VotingPluginMain plugin;
public ShopFile(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "Shop.yml"));
this.plugin = plugin;
}
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();
}
public int getShopIdentifierCost(String identifier) {
return getData().getInt("Shop." + identifier + ".Cost");
}
public String getShopIdentifierIdentifierName(String identifier) {
return getData().getString("Shop." + identifier + ".Identifier_Name", identifier);
}
public int getShopIdentifierLimit(String identifier) {
return getData().getInt("Shop." + identifier + ".Limit", -1);
}
public String getShopIdentifierRewardsPath(String identifier) {
return "Shop." + identifier + ".Rewards";
}
public Set<String> getShopIdentifiers() {
ConfigurationSection shop = getData().getConfigurationSection("Shop");
if (shop != null) {
return shop.getKeys(false);
}
return new HashSet<String>();
}
public ConfigurationSection getShopIdentifierSection(String identifier) {
return getData().getConfigurationSection("Shop." + identifier);
}
@ConfigDataBoolean(path = "VoteShop.BackButton")
@Getter
private boolean voteShopBackButton = true;
@ConfigDataBoolean(path = "VoteShop.ReopenGUIOnPurchase")
@Getter
private boolean voteShopReopenGUIOnPurchase = true;
public boolean getVoteShopCloseGUI(String shop) {
return getData().getBoolean("Shop." + shop + ".CloseGUI", true);
}
public boolean getVoteShopHideOnNoPermission(String shop) {
return getData().getBoolean("Shop." + shop + ".HideOnNoPermission", true);
}
@ConfigDataBoolean(path = "VoteShop.Enabled")
@Getter
private boolean voteShopEnabled = true;
@ConfigDataString(path = "VoteShop.Name")
@Getter
private String voteShopName = "VoteShop";
public boolean getVoteShopNotBuyable(String shop) {
return getData().getBoolean("Shop." + shop + ".NotBuyable", false);
}
public String getVoteShopPermission(String ident) {
return getData().getString("Shop." + ident + ".Permission", "");
}
public String getVoteShopPurchase(String identifier) {
return getData().getString("Shop." + identifier + ".PurchaseMessage",
plugin.getConfigFile().getFormatShopPurchaseMsg());
}
public boolean getVoteShopResetDaily(String shop) {
return getData().getBoolean("Shop." + shop + ".Reset.Daily", false);
}
public boolean getVoteShopResetMonthly(String shop) {
return getData().getBoolean("Shop." + shop + ".Reset.Monthly", false);
}
public boolean getVoteShopResetWeekly(String shop) {
return getData().getBoolean("Shop." + shop + ".Reset.Weekly", false);
}
public ConfigurationSection getGUIVoteShopExtraItems(String item) {
return getData().getConfigurationSection("ExtraItems." + item);
}
@ConfigDataKeys(path = "ExtraItems")
@Getter
private Set<String> voteShopExtraItems = new HashSet<String>();
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);
}
public void convertFromGUIFile() {
// booleans
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"));
// strings
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"));
// sections
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();
}
public void removeShop(String value) {
getData().set("Shop." + value, null);
saveData();
}
}
@@ -6,12 +6,13 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.bencodez.advancedcore.api.yml.YMLFile;
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;
@@ -66,7 +67,7 @@ public class SpecialRewardsConfig extends YMLFile {
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
@Getter
private boolean votePartyResetExtraVotesMonthly = false;
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesWeekly")
@Getter
private boolean votePartyResetExtraVotesWeekly = false;
@@ -75,9 +76,9 @@ public class SpecialRewardsConfig extends YMLFile {
@Getter
private String votePartyVoteReminderBroadcast = "%votesrequired% left to go, go vote!";
@ConfigDataListString(path = "VoteParty.VoteReminderAtVotes")
@ConfigDataListInt(path = "VoteParty.VoteReminderAtVotes")
@Getter
private ArrayList<String> votePartyVoteReminderAtVotes = new ArrayList<String>();
private ArrayList<Integer> votePartyVoteReminderAtVotes = new ArrayList<Integer>();
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
@Getter
@@ -232,10 +233,23 @@ public class SpecialRewardsConfig extends YMLFile {
@Getter
private boolean votePartyGiveAllPlayers = false;
@Deprecated
@ConfigDataInt(path = "VoteParty.IncreaseVotesRquired")
@Getter
private int votePartyIncreaseVotesRquired = 0;
@ConfigDataInt(path = "VoteParty.IncreaseVotesRequired")
@Getter
private int votePartyIncreaseVotesRequired = 0;
public int getVotePartyIncreaseVotesRequiredWithTypo() {
int increase = getVotePartyIncreaseVotesRequired();
if (increase > 0) {
return increase;
}
return getVotePartyIncreaseVotesRquired();
}
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerDay")
@Getter
private boolean votePartyOnlyOncePerDay = false;
@@ -38,6 +38,15 @@ public class ServerData {
}
}
public void setShopConverted(boolean value) {
getData().set("VoteShopConverted", value);
saveData();
}
public boolean isVoteShopConverted() {
return getData().getBoolean("VoteShopConverted");
}
public void updatePlaceholders() {
boolean data = getData().getBoolean("AutoCacheUpdated", false);
if (!data) {
@@ -42,6 +42,8 @@ public class PlayerJoinEvent implements Listener {
if (data) {
// give offline vote (if they voted offline)
user.offVote();
} else {
plugin.debug("No data detected for " + player.getUniqueId().toString() + "/" + player.getName());
}
user.loginRewards();
@@ -90,8 +90,7 @@ public class PlayerVoteListener implements Listener {
for (VoteSite site : plugin.getVoteSites()) {
services.add(site.getServiceSite());
}
plugin.getLogger()
.warning("Currently set service sites: " + ArrayUtils.makeStringList(services));
plugin.getLogger().warning("Currently set service sites: " + ArrayUtils.makeStringList(services));
}
return;
}
@@ -227,7 +226,10 @@ public class PlayerVoteListener implements Listener {
}
LocalDateTime cTime = plugin.getTimeChecker().getTime();
int days = cTime.getDayOfMonth();
plugin.extraDebug("Current day of month: " + days + " Current total: " + value);
if (value >= days * plugin.getVoteSitesEnabled().size()) {
plugin.debug("Detected higher month total, changing. Current Total: " + value + " Days: " + days
+ " New Total: " + days * plugin.getVoteSitesEnabled().size());
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSitesEnabled().size());
}
}
@@ -82,6 +82,10 @@ public class VoteSite {
@Setter
private String voteURL;
@Getter
@Setter
private String permissionToView;
@Getter
@Setter
private boolean waitUntilVoteDelay;
@@ -174,8 +178,7 @@ public class VoteSite {
}
public String getVoteURL(boolean json) {
if (!plugin.getConfigFile().isFormatCommandsVoteForceLinks() || !json
|| MessageAPI.containsJson(voteURL)) {
if (!plugin.getConfigFile().isFormatCommandsVoteForceLinks() || !json || MessageAPI.containsJson(voteURL)) {
return voteURL;
} else {
if (!voteURL.startsWith("http")) {
@@ -199,15 +202,16 @@ public class VoteSite {
}
public void giveRewards(VotingPluginUser user, boolean online, boolean bungee) {
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getEverySiteRewardPath())
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getRewardsPath(key))
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getEverySiteRewardPath())
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
}
public boolean hasRewards() {
@@ -236,6 +240,7 @@ public class VoteSite {
voteDelayDailyHour = plugin.getConfigVoteSites().getVoteDelayDailyHour(key);
hidden = plugin.getConfigVoteSites().getVoteSiteHidden(key);
ignoreCanVote = plugin.getConfigVoteSites().getVoteSiteIgnoreCanVote(key);
permissionToView = plugin.getConfigVoteSites().getPermissionToView(key);
}
public boolean isVaidServiceSite() {
@@ -115,7 +115,7 @@ public class PlaceHolders {
identifier = PlaceholderUtils.replaceJavascript(p, identifier);
}
if (!identifier.endsWith("Position")) {
if (!identifier.toLowerCase().endsWith("position")) {
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
if (placeholder.matches(identifier)) {
String str = placeholder.placeholderRequest(identifier);
@@ -352,8 +352,20 @@ public class PlaceHolders {
}
}.withDescription("Get number of votes until next available milestone").updateDataKey("MilestoneCount"));
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
if (plugin.getGui().getChestShopIdentifierLimit(identifier) > 0) {
placeholders.add(new PlaceHolder<VotingPluginUser>("lastmilestone_votes_since") {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
int toGo = user.getMilestoneCount() - user.getLastGottenMilestone();
if (toGo >= 0) {
return "" + toGo;
}
return "0";
}
}.withDescription("Get number of votes since last milestone").updateDataKey("MilestoneCount"));
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
if (plugin.getShopFile().getShopIdentifierLimit(identifier) > 0) {
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
@Override
@@ -573,6 +585,9 @@ public class PlaceHolders {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
if (!MessageAPI.isInt(identifier.split("_")[1])) {
return "invalid";
}
int number = Integer.parseInt(identifier.split("_")[1]);
if (user.getPoints() >= number) {
return "true";
@@ -602,7 +617,7 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return null;
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -653,7 +668,7 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return null;
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -690,7 +705,7 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return null;
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -741,7 +756,7 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return null;
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -792,7 +807,7 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return null;
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -110,7 +110,11 @@ public class SpecialRewards {
total = bungeeMessageData.getDailyTotal();
break;
case Monthly:
total = bungeeMessageData.getMonthTotal();
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
total = bungeeMessageData.getDateMonthTotal();
} else {
total = bungeeMessageData.getMonthTotal();
}
break;
case Weekly:
total = bungeeMessageData.getWeeklyTotal();
@@ -164,6 +168,7 @@ public class SpecialRewards {
}
}
return gotCumulativeAny;
}
public boolean checkFirstVote(VotingPluginUser user, boolean forceBungee) {
@@ -258,13 +263,14 @@ public class SpecialRewards {
Set<String> streaks = plugin.getSpecialRewardsConfig().getVoteStreakVotes(type);
for (String streak : streaks) {
String s = streak.replaceAll("-", "");
boolean multiple = false;
if (streak.contains("-")) {
// multiple
multiple = true;
}
String s = streak.replaceAll("-", "");
plugin.debug("Streak: " + streak + " multiple: " + multiple);
if (MessageAPI.isInt(s)) {
int streakRequired = Integer.parseInt(s);
@@ -61,7 +61,7 @@ public class VoteTester {
String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
StringBuilder salt = new StringBuilder();
Random rnd = new Random();
while (salt.length() < 18) { // length of the random string.
while (salt.length() < 12) { // length of the random string.
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
salt.append(SALTCHARS.charAt(index));
}
@@ -2,6 +2,8 @@ package com.bencodez.votingplugin.topvoter;
import java.io.File;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -13,6 +15,8 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -26,8 +30,8 @@ import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
import com.bencodez.advancedcore.api.user.UserStorage;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
import com.bencodez.advancedcore.api.yml.YMLFileHandler;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.file.YMLFileHandler;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -83,11 +87,106 @@ public class TopVoterHandler implements Listener {
return place;
}
public void loadPreviousMonthTopVoters() {
if (plugin.getConfigFile().isStoreMonthTotalsWithDate()) {
LocalDateTime now = plugin.getTimeChecker().getTime();
for (String column : plugin.getUserManager().getAllColumns()) {
if (column.startsWith("MonthTotal-")) {
String[] data = column.split("-");
if (data.length > 2) {
String year = data[2];
String month = data[1];
if (MessageAPI.isInt(year)) {
YearMonth yearMonth = YearMonth.of(Integer.parseInt(year), Month.valueOf(month));
if (yearMonth.atDay(now.getDayOfMonth()).atTime(23, 59).isBefore(now)) {
plugin.debug("Loading previous month top voters of " + yearMonth.toString());
plugin.getPreviousMonthsTopVoters().put(yearMonth,
new LinkedHashMap<TopVoterPlayer, Integer>());
}
}
}
}
}
if (plugin.getPreviousMonthsTopVoters().size() > 0) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
for (YearMonth month : plugin.getPreviousMonthsTopVoters().keySet()) {
LocalDateTime atTime = month.atDay(15).atTime(0, 0);
int total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
plugin.getPreviousMonthsTopVoters().get(month).put(user.getTopVoterPlayer(), total);
}
}
cols.put(playerData.getKey(), null);
user.clearTempCache();
}
}
cols.clear();
cols = null;
}
for (YearMonth month : plugin.getPreviousMonthsTopVoters().keySet()) {
plugin.getPreviousMonthsTopVoters().put(month,
sortByValues(plugin.getPreviousMonthsTopVoters().get(month), false));
}
plugin.extraDebug("Previous Months: " + plugin.getPreviousMonthsTopVoters().keySet().toString());
for (Entry<YearMonth, LinkedHashMap<TopVoterPlayer, Integer>> entry : plugin.getPreviousMonthsTopVoters()
.entrySet()) {
for (Entry<TopVoterPlayer, Integer> entry2 : entry.getValue().entrySet()) {
plugin.extraDebug(entry.getKey().toString() + ": " + entry2.getKey().getUser().getPlayerName() + ":"
+ entry2.getValue().intValue());
}
}
}
}
public LinkedHashMap<TopVoterPlayer, Integer> getTopVotersOfMonth(YearMonth month,
HashMap<UUID, ArrayList<Column>> cols) {
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
LocalDateTime atTime = month.atDay(15).atTime(0, 0);
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
int total = 0;
total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
totals.put(user.getTopVoterPlayer(), total);
}
user.clearTempCache();
}
}
return sortByValues(totals, false);
}
public void loadLastMonth() {
if (plugin.getGui().isLastMonthGUI()) {
plugin.getLastMonthTopVoter().clear();
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
LocalDateTime lastMonthTime = plugin.getTimeChecker().getTime().minusMonths(1);
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
@@ -98,7 +197,12 @@ public class TopVoterHandler implements Listener {
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
int total = user.getLastMonthTotal();
int total = 0;
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
total = user.getTotal(TopVoter.Monthly, lastMonthTime);
} else {
total = user.getLastMonthTotal();
}
if (total > 0) {
totals.put(user.getTopVoterPlayer(), total);
}
@@ -198,8 +302,8 @@ public class TopVoterHandler implements Listener {
e.printStackTrace();
}
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
if (plugin.getGui().getChestVoteShopResetDaily(shopIdent)) {
for (String shopIdent : plugin.getShopFile().getShopIdentifiers()) {
if (plugin.getShopFile().getVoteShopResetDaily(shopIdent)) {
resetVoteShopLimit(shopIdent);
}
}
@@ -236,6 +340,7 @@ public class TopVoterHandler implements Listener {
plugin.getUserManager().copyColumnData(TopVoter.Monthly.getColumnName(),
TopVoter.Monthly.getLastColumnName());
}
LocalDateTime lastMonthTime = plugin.getTimeChecker().getTime().minusMonths(1);
if (plugin.getConfigFile().isUseHighestTotals() || plugin.getConfigFile().isUseVoteStreaks()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
@@ -245,13 +350,13 @@ public class TopVoterHandler implements Listener {
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
if (plugin.getConfigFile().isUseVoteStreaks()) {
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
if (user.getTotal(TopVoter.Monthly, lastMonthTime) == 0 && user.getMonthVoteStreak() != 0) {
user.setMonthVoteStreak(0);
} else {
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|| user.hasPercentageTotal(TopVoter.Monthly,
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
LocalDateTime.now().minusDays(1))) {
lastMonthTime)) {
user.addMonthVoteStreak();
plugin.getSpecialRewards().checkVoteStreak(user, "Month",
plugin.getBungeeSettings().isUseBungeecoord());
@@ -263,8 +368,8 @@ public class TopVoterHandler implements Listener {
// user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
if (plugin.getConfigFile().isUseHighestTotals()) {
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly, lastMonthTime)) {
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly, lastMonthTime));
}
}
user.clearTempCache();
@@ -281,10 +386,17 @@ public class TopVoterHandler implements Listener {
int i = 0;
int lastTotal = -1;
@SuppressWarnings("unchecked")
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Monthly).clone();
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
LinkedHashMap<TopVoterPlayer, Integer> topVoters = null;
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
topVoters = getMonthlyTopVotersAtTime(lastMonthTime);
} else {
@SuppressWarnings("unchecked")
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Monthly).clone();
topVoters = clone;
}
for (Entry<TopVoterPlayer, Integer> entry : topVoters.entrySet()) {
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
if (entry.getValue().intValue() != lastTotal) {
i++;
@@ -315,8 +427,8 @@ public class TopVoterHandler implements Listener {
resetGottenMilestones();
}
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
if (plugin.getGui().getChestVoteShopResetMonthly(shopIdent)) {
for (String shopIdent : plugin.getShopFile().getShopIdentifiers()) {
if (plugin.getShopFile().getVoteShopResetMonthly(shopIdent)) {
resetVoteShopLimit(shopIdent);
}
}
@@ -344,6 +456,12 @@ public class TopVoterHandler implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPreDateChanged(PreDateChangedEvent event) {
if (event.getTimeType().equals(TimeType.DAY)) {
plugin.getBannedPlayers().clear();
for (OfflinePlayer p : Bukkit.getBannedPlayers()) {
plugin.getBannedPlayers().add(p.getUniqueId().toString());
}
}
plugin.setUpdate(true);
plugin.update();
}
@@ -425,8 +543,8 @@ public class TopVoterHandler implements Listener {
e.printStackTrace();
}
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
if (plugin.getGui().getChestVoteShopResetWeekly(shopIdent)) {
for (String shopIdent : plugin.getShopFile().getShopIdentifiers()) {
if (plugin.getShopFile().getVoteShopResetWeekly(shopIdent)) {
resetVoteShopLimit(shopIdent);
}
}
@@ -805,6 +923,37 @@ public class TopVoterHandler implements Listener {
return ArrayUtils.convert(msg);
}
public LinkedHashMap<TopVoterPlayer, Integer> getMonthlyTopVotersAtTime(LocalDateTime atTime) {
// int limitSize = plugin.getConfigFile().getMaxiumNumberOfTopVotersToLoad();
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
LinkedHashMap<TopVoterPlayer, Integer> topVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (plugin != null && plugin.isEnabled()) {
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
int total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
topVoter.put(user.getTopVoterPlayer(), total);
}
}
}
}
return sortByValues(topVoter, false);
}
public synchronized void updateTopVoters(
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter) {
@@ -4,7 +4,6 @@ import java.util.UUID;
import org.bukkit.inventory.ItemStack;
import com.bencodez.advancedcore.api.misc.PlayerManager;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -30,7 +29,7 @@ public class TopVoterPlayer {
}
public ItemStack getPlayerHead() {
return PlayerManager.getInstance().getPlayerSkull(getPlayerName(), false);
return VotingPluginMain.plugin.getSkullCacheHandler().getSkull(uuid, playerName);
}
public VotingPluginUser getUser() {
@@ -22,7 +22,8 @@ public class CheckUpdate {
* Check update.
*/
public void checkUpdate() {
if (plugin.getConfigFile().isDisableUpdateChecking()) {
if (plugin.getConfigFile().isDisableUpdateChecking()
|| plugin.getDescription().getVersion().endsWith("SNAPSHOT")) {
return;
}
plugin.setUpdater(new Updater(plugin, 15358, false));
@@ -69,7 +70,8 @@ public class CheckUpdate {
* Start up.
*/
public void startUp() {
if (plugin.getConfigFile().isDisableUpdateChecking()) {
if (plugin.getConfigFile().isDisableUpdateChecking()
|| plugin.getDescription().getVersion().endsWith("SNAPSHOT")) {
return;
}
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@@ -1,16 +1,23 @@
package com.bencodez.votingplugin.user;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
import com.bencodez.advancedcore.api.user.UserStartup;
import com.bencodez.advancedcore.api.user.usercache.UserDataManager;
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyBoolean;
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyInt;
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyString;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
public class UserManager {
private VotingPluginMain plugin;
@@ -28,6 +35,14 @@ public class UserManager {
manager.addKey(new UserDataKeyString("OfflineVotes").setColumnType("MEDIUMTEXT"));
manager.addKey(new UserDataKeyInt("MilestoneCount"));
manager.addKey(new UserDataKeyInt("MonthTotal"));
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
manager.addKey(new UserDataKeyInt(getMonthTotalsWithDatePath(LocalDateTime.now().minusMonths(1))));
manager.addKey(new UserDataKeyInt(getMonthTotalsWithDatePath(LocalDateTime.now())));
manager.addKey(new UserDataKeyInt(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1))));
manager.addKey(new UserDataKeyInt(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2))));
}
manager.addKey(new UserDataKeyInt("AllTimeTotal"));
manager.addKey(new UserDataKeyInt("DailyTotal"));
manager.addKey(new UserDataKeyInt("WeeklyTotal"));
@@ -89,6 +104,15 @@ public class UserManager {
}
}
public String getMonthTotalsWithDatePath() {
LocalDateTime cTime = plugin.getTimeChecker().getTime();
return getMonthTotalsWithDatePath(cTime);
}
public String getMonthTotalsWithDatePath(LocalDateTime cTime) {
return "MonthTotal-" + cTime.getMonth().toString() + "-" + cTime.getYear();
}
public ArrayList<String> getAllUUIDs() {
return plugin.getUserManager().getAllUUIDs();
}
@@ -124,4 +148,81 @@ public class UserManager {
public VotingPluginUser getVotingPluginUser(UUID uuid, boolean loadName) {
return new VotingPluginUser(plugin, uuid, loadName);
}
public void purgeOldPlayersNoData() {
if (plugin.getOptions().isPurgeOldData() && plugin.getConfigFile().isPurgeNoDataOnStartup()) {
plugin.addUserStartup(new UserStartup() {
@Override
public void onFinish() {
plugin.debug("Finished no data purging");
}
@Override
public void onStart() {
}
@Override
public void onStartUp(AdvancedCoreUser acUser) {
VotingPluginUser user = getVotingPluginUser(acUser);
user.dontCache();
int daysOld = plugin.getOptions().getPurgeMinimumDays();
int days = user.getNumberOfDaysSinceLogin();
if (days == -1) {
// fix ones with no last online
user.setLastOnline(System.currentTimeMillis());
} else if (days > daysOld) {
if (user.getTotal(TopVoter.AllTime) == 0 && user.getMilestoneCount() == 0
&& user.getTotal(TopVoter.Monthly) == 0 && user.getTotal(TopVoter.Weekly) == 0
&& user.getTotal(TopVoter.Daily) == 0) {
plugin.debug("Removing " + user.getUUID() + " because of no data purge");
user.remove();
}
}
}
});
}
plugin.getUserManager().getDataManager().clearCache();
}
public void purgeOldPlayersNowNoData() {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (plugin.isEnabled()) {
if (uuid != null) {
VotingPluginUser user = getVotingPluginUser(UUID.fromString(uuid), false);
if (user != null) {
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
int daysOld = plugin.getOptions().getPurgeMinimumDays();
int days = user.getNumberOfDaysSinceLogin();
if (days == -1) {
// fix ones with no last online
user.setLastOnline(System.currentTimeMillis());
} else if (days > daysOld) {
if (user.getTotal(TopVoter.AllTime) == 0 && user.getMilestoneCount() == 0
&& user.getTotal(TopVoter.Monthly) == 0 && user.getTotal(TopVoter.Weekly) == 0
&& user.getTotal(TopVoter.Daily) == 0)
plugin.debug("Removing " + user.getUUID() + " because of no data purge");
user.remove();
}
user.clearTempCache();
cols.put(playerData.getKey(), null);
user = null;
}
}
}
}
cols.clear();
cols = null;
plugin.getUserManager().getDataManager().clearCache();
plugin.setUpdate(true);
}
}
@@ -110,6 +110,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
if (points != 0) {
addPoints(points);
}
if (plugin.getConfigFile().getLimitVotePoints() > 0) {
if (getPoints() > plugin.getConfigFile().getLimitVotePoints()) {
setPoints(plugin.getConfigFile().getLimitVotePoints());
}
}
}
/**
@@ -534,7 +539,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
@Deprecated
public int getMonthTotal() {
return getData().getInt("MonthTotal", isCacheData(), isWaitForCache());
return getTotal(TopVoter.Monthly);
}
public int getMonthVoteStreak() {
@@ -601,6 +606,30 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
case Daily:
return getUserData().getInt("DailyTotal", isCacheData(), isWaitForCache());
case Monthly:
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
return getData().getInt(plugin.getVotingPluginUserManager().getMonthTotalsWithDatePath(), isCacheData(),
isWaitForCache());
}
return getData().getInt("MonthTotal", isCacheData(), isWaitForCache());
case Weekly:
return getUserData().getInt("WeeklyTotal", isCacheData(), isWaitForCache());
default:
break;
}
return 0;
}
public int getTotal(TopVoter top, LocalDateTime atTime) {
switch (top) {
case AllTime:
return getUserData().getInt("AllTimeTotal", isCacheData(), isWaitForCache());
case Daily:
return getUserData().getInt("DailyTotal", isCacheData(), isWaitForCache());
case Monthly:
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
return getData().getInt(plugin.getVotingPluginUserManager().getMonthTotalsWithDatePath(atTime),
isCacheData(), isWaitForCache());
}
return getData().getInt("MonthTotal", isCacheData(), isWaitForCache());
case Weekly:
return getUserData().getInt("WeeklyTotal", isCacheData(), isWaitForCache());
@@ -684,7 +713,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
public boolean hasPercentageTotal(TopVoter top, double percentage, LocalDateTime time) {
int total = getTotal(top);
int total = getTotal(top, time);
switch (top) {
case Daily:
return (double) total / (double) plugin.getVoteSitesEnabled().size() * 100 > percentage;
@@ -1069,6 +1098,32 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
public int getLastGottenMilestone() {
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
ArrayList<Integer> nums = new ArrayList<Integer>();
int mileStoneCount = getMilestoneCount();
for (String vote : mVotes) {
if (MessageAPI.isInt(vote)) {
final int num = Integer.parseInt(vote);
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
nums.add(Integer.valueOf(num));
}
}
}
int highestNum = -1;
for (Integer num : nums) {
if (mileStoneCount > num.intValue()) {
if (highestNum == -1 || num.intValue() > highestNum) {
highestNum = num.intValue();
}
}
}
return highestNum;
}
public void setReminded(boolean reminded) {
getUserData().setString("Reminded", "" + reminded);
}
@@ -1104,6 +1159,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
}
getData().setInt("MonthTotal", value);
if (plugin.getConfigFile().isStoreMonthTotalsWithDate()) {
getData().setInt(plugin.getVotingPluginUserManager().getMonthTotalsWithDatePath(), value);
}
break;
case Weekly:
getUserData().setInt("WeeklyTotal", value);
@@ -1174,30 +1232,26 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
String info = "";
if (diffDays == 1) {
info += PlaceholderUtils
.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsDay()), "amount", "" + diffDays);
info += PlaceholderUtils.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsDay()), "amount", "" + diffDays);
info += " ";
} else if (diffDays > 1) {
info += PlaceholderUtils
.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsDays()), "amount", "" + diffDays);
info += PlaceholderUtils.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsDays()), "amount", "" + diffDays);
info += " ";
}
if (diffHours == 1) {
info += PlaceholderUtils
.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsHour()), "amount", "" + diffHours);
info += PlaceholderUtils.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsHour()), "amount", "" + diffHours);
info += " ";
} else if (diffHours > 1) {
info += PlaceholderUtils
.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsHours()), "amount", "" + diffHours);
info += PlaceholderUtils.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsHours()), "amount", "" + diffHours);
info += " ";
}
@@ -1225,8 +1279,8 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
}
info = PlaceholderUtils
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteLastLastVoted(), "times", info);
info = PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteLastLastVoted(),
"times", info);
return info;
}
@@ -90,9 +90,7 @@ public class VoteParty implements Listener {
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRequired());
}
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerDay()) {
plugin.getServerData().updateLastVoteParty();
}
plugin.getServerData().updateLastVoteParty();
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerWeek()) {
plugin.getServerData().updateLastVotePartyWeek();
@@ -115,12 +113,10 @@ public class VoteParty implements Listener {
placeholders.put("votesrequired", "" + votesRequired);
placeholders.put("neededvotes", "" + neededVotes);
placeholders.put("votes", "" + votes);
msg = ArrayUtils.colorize(
PlaceholderUtils.replacePlaceHolder(msg, placeholders));
msg = ArrayUtils.colorize(PlaceholderUtils.replacePlaceHolder(msg, placeholders));
if (sender instanceof Player) {
Player p = (Player) sender;
sender.sendMessage(ArrayUtils.convert(
PlaceholderUtils.replacePlaceHolders(msg, p)));
sender.sendMessage(ArrayUtils.convert(PlaceholderUtils.replacePlaceHolders(msg, p)));
} else {
sender.sendMessage(ArrayUtils.convert(msg));
}
@@ -186,6 +182,7 @@ public class VoteParty implements Listener {
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVotePartyRewardsPath()).setOnline(online)
.withPlaceHolder("VotesRequired", "" + plugin.getSpecialRewardsConfig().getVotePartyVotesRequired())
.withPlaceHolder("FirstVotePartyToday", "" + !plugin.getServerData().isLastVotePartySameDay())
.setServer(useBungee).send(user);
}
@@ -223,10 +220,8 @@ public class VoteParty implements Listener {
@Override
public void run() {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
PlaceholderUtils.replacePlaceHolder(
list.get(ThreadLocalRandom.current().nextInt(list.size())), "randomonlineplayer",
player));
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), PlaceholderUtils.replacePlaceHolder(
list.get(ThreadLocalRandom.current().nextInt(list.size())), "randomonlineplayer", player));
}
});
@@ -234,6 +229,7 @@ public class VoteParty implements Listener {
if (plugin.getSpecialRewardsConfig().isVotePartyGiveAllPlayers()) {
plugin.debug("Trying to give all players vote party");
ArrayList<String> alreadyGotten = new ArrayList<String>();
for (Player p : Bukkit.getOnlinePlayers()) {
VotingPluginUser user;
@@ -267,7 +263,9 @@ public class VoteParty implements Listener {
} else {
plugin.debug("Trying to give all voted players vote party");
plugin.debug(ArrayUtils.makeStringList(getVotedUsers()));
for (String uuid : getVotedUsers()) {
for (String uuid :
getVotedUsers()) {
VotingPluginUser user;
if (orgUser != null && orgUser.getJavaUUID().toString().equals(uuid)) {
user = orgUser;
@@ -281,6 +279,7 @@ public class VoteParty implements Listener {
}
}
reset(false);
}
@@ -351,11 +350,11 @@ public class VoteParty implements Listener {
}
public void checkVoteReminder(VotingPluginUser user) {
int neededVotes = getNeededVotes();
if (!user.isVanished()) {
int neededVotes = getNeededVotes();
for (String str : plugin.getSpecialRewardsConfig().getVotePartyVoteReminderAtVotes()) {
if (MessageAPI.isInt(str)) {
int num = Integer.parseInt(str);
for (Integer num1 : plugin.getSpecialRewardsConfig().getVotePartyVoteReminderAtVotes()) {
int num = num1.intValue();
if (neededVotes == num) {
String broadcastMessage = plugin.getSpecialRewardsConfig().getVotePartyVoteReminderBroadcast();
HashMap<String, String> placeholders = new HashMap<String, String>();
@@ -366,6 +365,7 @@ public class VoteParty implements Listener {
}
}
}
}
public synchronized void vote(VotingPluginUser user, boolean realVote, boolean forceBungee) {