Compare commits

..
238 Commits
Author SHA1 Message Date
BenCodez fe277d8bfd Update version number to 6.16 2024-05-05 13:30:18 -04:00
BenCodez 86cba23568 Add lastmonth position placeholder 2024-05-01 20:17:42 -04:00
BenCodez 5a6140020f Merge branch 'master' of https://github.com/BenCodez/VotingPlugin 2024-05-01 16:15:13 -04:00
BenCodez cb203edecf Update to 1.20.6 2024-04-30 21:13:21 -04:00
Ben 5510e3bb98 Merge pull request #1350 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-shade-plugin-3.5.3
Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.2 to 3.5.3 in /VotingPlugin
2024-04-29 16:07:56 -04:00
dependabot[bot] 470c52e6e3 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.2 to 3.5.3.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.5.2...maven-shade-plugin-3.5.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-29 06:53:18 +00:00
BenCodez 03e4c2165e Fix command casing 2024-04-28 14:50:10 -04:00
BenCodez 45d617106b Fix issues with command aliases not always working 2024-04-28 14:09:48 -04:00
BenCodez 58869742bc Update to 1.20.5 2024-04-23 19:34:57 -04:00
Ben a8841ca732 Merge pull request #1348 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-jar-plugin-3.4.1
Bump org.apache.maven.plugins:maven-jar-plugin from 3.4.0 to 3.4.1 in /VotingPlugin
2024-04-22 16:50:25 -04:00
dependabot[bot] 96ef82aef0 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.0 to 3.4.1.
- [Release notes](https://github.com/apache/maven-jar-plugin/releases)
- [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.4.0...maven-jar-plugin-3.4.1)

---
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-04-22 06:44:29 +00:00
BenCodez 5a33b5b892 Changes to almostallsites rewards trigger 2024-04-18 16:57:50 -04:00
Ben ed2fb77a7b Merge pull request #1347 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-jar-plugin-3.4.0
Bump org.apache.maven.plugins:maven-jar-plugin from 3.3.0 to 3.4.0 in /VotingPlugin
2024-04-15 16:42:58 -04:00
dependabot[bot] 8a1c820e42 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.3.0 to 3.4.0.
- [Release notes](https://github.com/apache/maven-jar-plugin/releases)
- [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.3.0...maven-jar-plugin-3.4.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-15 06:39:42 +00:00
BenCodez 43c5419453 Add additional debug for almostallsites reward 2024-04-14 14:14:51 -04:00
BenCodez 4f2caf67d0 Fix issue with conditional items and rewards in VoteGUI 2024-04-13 08:22:09 -04:00
BenCodez 8b17e43ce0 Adjustments to getting votesites 2024-04-10 20:24:39 -04:00
BenCodez 05db0b189b Add /av correctservicesites command 2024-04-09 20:48:25 -04:00
BenCodez 93f91923bb Slightly adjust vote next time caculations for votedailydaily sites 2024-04-09 17:09:09 -04:00
BenCodez 6dca3ad152 Slight change vote next time caculation 2024-04-07 13:14:59 -04:00
BenCodez 637db5afdb Changes to placeholders 2024-04-06 20:03:14 -04:00
BenCodez 029fa00e3a Fix typo 2024-04-06 19:46:11 -04:00
BenCodez e1bb95c482 Use only enabled votesites for monthly total 2024-04-06 15:58:17 -04:00
BenCodez 667b1b082d change log message to debug 2024-03-29 14:11:09 -04:00
BenCodez 2097fc4b86 Add new advanced service site handling feature, experimental 2024-03-28 20:53:29 -04:00
Ben 49d20c0bc8 Merge pull request #1341 from BenCodez/dependabot/maven/VotingPlugin/org.projectlombok-lombok-1.18.32
Bump org.projectlombok:lombok from 1.18.30 to 1.18.32 in /VotingPlugin
2024-03-25 16:47:05 -04:00
dependabot[bot] fe2ac4f02c Bump org.projectlombok:lombok from 1.18.30 to 1.18.32 in /VotingPlugin
Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.30 to 1.18.32.
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.30...v1.18.32)

---
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-03-25 06:29:20 +00:00
BenCodez 4859c37ef8 Fix status command on velocity not working 2024-03-23 22:13:28 -04:00
BenCodez c818007426 Fix issue with multi-proxy redis on velocity 2024-03-23 20:48:31 -04:00
Ben c86f07aeb6 Create FUNDING.yml 2024-03-22 16:57:09 -04:00
BenCodez 0a74e338c2 More fixes for cooldown events 2024-03-19 21:15:04 -04:00
BenCodez d1dc8b392f Added neededvotes placeholder to broadcast 2024-03-17 17:35:02 -04:00
BenCodez bd5234b479 Adjustments to vote delay daily can vote caculations 2024-03-16 14:58:04 -04:00
BenCodez cca9e3dc58 Added votesrequired placeholder to broadcasts 2024-03-16 08:38:52 -04:00
BenCodez c3df294ce6 Changes for vote delay daily sites issues 2024-03-15 17:04:15 -04:00
BenCodez d81a113240 More changes to cooldown events 2024-03-12 20:45:36 -04:00
BenCodez f2feafa45a Changes to cooldown checks 2024-03-12 20:37:58 -04:00
BenCodez f63a743c2c Change default displayitem material on auto generated votesites 2024-03-09 19:51:12 -05:00
BenCodez 2d9c6482fc Add placeholders for time until month and week changes 2024-03-09 19:46:18 -05:00
BenCodez 448a9eeea9 Add placeholderapi placeholder %votingplugin_sitesavailable% 2024-03-08 18:48:52 -05:00
BenCodez c8e32696af Adjustments to cooldown checks 2024-03-06 20:49:56 -05:00
BenCodez 36eb6eafb3 Add votedelay and votehour placeholders 2024-03-05 19:03:05 -05:00
BenCodez 040fafe33a Add better handling of more than 2 proxies in multi-proxy setup 2024-03-03 14:43:13 -05:00
BenCodez 040e467761 Fix issue with new placeholder not always working 2024-02-29 19:08:01 -05:00
BenCodez e0d28be260 Fix typo in debug 2024-02-28 19:33:57 -05:00
BenCodez 1ef2440bf9 Add more placeholders to VoteURL GUI 2024-02-28 19:07:25 -05:00
Ben 2a5d5d3bea Merge pull request #1336 from Melon-Oof/master
Update BungeeSettings.yml
2024-02-27 16:39:55 -05:00
Melon-Oof 419153d654 Update BungeeSettings.yml 2024-02-27 17:14:21 +01:00
Ben ed8c504c27 Merge pull request #1335 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-shade-plugin-3.5.2
Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.1 to 3.5.2 in /VotingPlugin
2024-02-26 16:47:58 -05:00
dependabot[bot] 2c29f11a8b 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.1 to 3.5.2.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.5.1...maven-shade-plugin-3.5.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-26 06:30:21 +00:00
BenCodez c442cd1deb Add ability to set prefix for redis channels 2024-02-23 20:46:03 -05:00
BenCodez 770e3e866c First implementation of multi-proxy redis 2024-02-23 20:30:32 -05:00
BenCodez 4014046444 Save vote cache file more often on proxy 2024-02-21 19:11:16 -05:00
BenCodez 6f378297dd Recode of multi-proxy backend for prep of redis multi-proxy 2024-02-18 20:24:05 -05:00
BenCodez 1c5c33be6a Update version number to 6.15.1 2024-02-17 20:33:16 -05:00
BenCodez 206665a40b Fix rare ConcurrentModificationException 2024-02-17 15:03:39 -05:00
BenCodez 159eb54e4e Fixed issue with used percentage for vote streaks not working 2024-02-11 13:43:15 -05:00
BenCodez f63ab7b693 Added more debug to votestreak 2024-02-10 08:07:16 -05:00
BenCodez 97e5f73774 Add new merge command to combine user totals 2024-02-05 20:30:57 -05:00
BenCodez 9f85149776 Add players to non voted cache before checking if they are online 2024-02-03 21:34:02 -05:00
BenCodez d6fa68dead Force mutli-proxy login message regardless of allowunjoined setting 2024-02-03 19:12:40 -05:00
BenCodez 5e42fdbfbe Fix remove offline uuids command 2024-02-02 20:25:24 -05:00
BenCodez 9b20d1754b Changes to rmeoveofflineuuids command 2024-02-02 19:50:49 -05:00
BenCodez d310fa3688 Add command to remove offline uuids from database 2024-02-02 19:33:43 -05:00
Ben 7ab3e8040c Merge pull request #1330 from NahuLD/patch-1
Fix issue with RedisHandler initialization utilizing wrong parameters
2024-02-02 10:10:09 -05:00
Nahuel Dolores 5173c24546 Fix issue with RedisHandler initialization utilizing wrong parameters 2024-02-02 10:21:03 -03:00
BenCodez 0c1cccfdcd Save reminds on toggle reminders command 2024-01-31 20:57:05 -05:00
BenCodez d36cd47597 Fix default config for vote reminding comments 2024-01-28 16:42:18 -05:00
BenCodez 6f34d11138 Add extra checks for milestones on proxy setups 2024-01-28 13:53:12 -05:00
Ben bf3f7bb6ad Merge pull request #1328 from BenCodez/dependabot/maven/VotingPlugin/net.md-5-bungeecord-api-1.20-R0.2
Bump net.md-5:bungeecord-api from 1.20-R0.1 to 1.20-R0.2 in /VotingPlugin
2024-01-22 16:51:53 -05:00
dependabot[bot] 28f74aa50a Bump net.md-5:bungeecord-api in /VotingPlugin
Bumps [net.md-5:bungeecord-api](https://github.com/SpigotMC/BungeeCord) from 1.20-R0.1 to 1.20-R0.2.
- [Commits](https://github.com/SpigotMC/BungeeCord/commits)

---
updated-dependencies:
- dependency-name: net.md-5:bungeecord-api
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-22 06:47:54 +00:00
BenCodez dc3c605315 Bypass fake votes for WaitUntilVoteDelay 2023-12-31 15:22:44 -05:00
BenCodez 5abc8004c7 Add option to reset extra votes required weekly 2023-12-31 13:43:24 -05:00
BenCodez bf1e971edd Add bypass permission for waituntilvotedelay 2023-12-31 12:55:30 -05:00
BenCodez 37c767dc74 Update version number to 6.15 2023-12-26 10:25:49 -05:00
BenCodez 8257b4f7f6 Add option to not hide voteshop item with no permission 2023-12-16 19:47:13 -05:00
BenCodez 0340f4512e Handle multi-proxy logins on velocity like bungee 2023-12-16 19:16:16 -05:00
BenCodez c45ce0d090 Fix a minor issue on velocity for redis 2023-12-13 19:58:14 -05:00
BenCodez add3dcaa26 Initial implementation of redis bungee method 2023-12-13 19:56:44 -05:00
BenCodez 4a88b10e61 Fix gotten milestones not resetting if per server milestones enabled 2023-12-12 17:55:32 -05:00
BenCodez 7001d0f7fc Update to 1.20.3 2023-12-05 19:04:31 -05:00
Ben fdf72b14eb Merge pull request #1318 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.6.3
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.2 to 3.6.3 in /VotingPlugin
2023-12-04 17:36:45 -05:00
dependabot[bot] 830de0388a 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.2 to 3.6.3.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.2...maven-javadoc-plugin-3.6.3)

---
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>
2023-12-04 06:52:55 +00:00
BenCodez 4a77c6bdd3 Add DisableReminders placeholder 2023-12-02 20:32:06 -05:00
BenCodez 579844f193 Save vote reminding toggles across restarts 2023-12-01 21:34:06 -05:00
BenCodez 4c6073c02a Add checks to matching server name in BungeeSettings.yml 2023-12-01 20:23:21 -05:00
Ben b1eb591e20 Merge pull request #1315 from NotAlexNoyle/master
Apply license to project root
2023-11-24 17:47:03 -05:00
NotAlexNoyle f5ee776586 Apply license to project root 2023-11-24 21:26:07 +01:00
BenCodez a2bf7c3dfc Update version number to 6.14.2 2023-11-19 19:07:25 -05:00
BenCodez 0543a91c5a Remove deprecated api 2023-11-17 18:34:36 -05:00
Ben d88868c4f7 Merge pull request #1312 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.6.2
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.0 to 3.6.2 in /VotingPlugin
2023-11-13 18:30:35 -05:00
dependabot[bot] 86dc52f131 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.0 to 3.6.2.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.6.0...maven-javadoc-plugin-3.6.2)

---
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>
2023-11-13 06:24:14 +00:00
BenCodez f7d88a26ef Handle allowunjoined disabled on multi-proxy setup 2023-11-05 20:16:52 -05:00
BenCodez ab1468d03a Changes to bedrock player support 2023-10-30 20:01:24 -04:00
Ben 3c65365b83 Merge pull request #1311 from BenCodez/dependabot/maven/VotingPlugin/me.clip-placeholderapi-2.11.5
Bump me.clip:placeholderapi from 2.11.4 to 2.11.5 in /VotingPlugin
2023-10-30 17:38:13 -04:00
dependabot[bot] bfefbb59d6 Bump me.clip:placeholderapi from 2.11.4 to 2.11.5 in /VotingPlugin
Bumps me.clip:placeholderapi from 2.11.4 to 2.11.5.

---
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>
2023-10-30 06:06:35 +00:00
BenCodez 9d74b5e428 Changes to handling ignoring bungee time change votes 2023-10-23 19:42:16 -04:00
BenCodez f131ce948c Force update placeholders on every vote to prevent issues 2023-10-22 12:45:09 -04:00
BenCodez 1a78a23e7c Shorten shutdown time 2023-10-17 16:52:35 -04:00
BenCodez 16cdfec4d5 Add player placeholder to vote reminder broadcast for voteparty 2023-10-13 16:49:45 -04:00
BenCodez 243300534c Add vote reminder broadcasts to vote party, WIP 2023-10-12 20:04:02 -04:00
BenCodez ea646b8e6f Ignore daily total for max amount of votes per day option 2023-10-08 12:34:07 -04:00
BenCodez bd5532aa71 Add vote limit feature to proxy setup 2023-10-05 20:55:20 -04:00
BenCodez be033793c2 Changes to limit monthly votes 2023-10-04 16:50:10 -04:00
BenCodez 28ce76bc60 Allow limit monthly votes to work on PLUGINMESSAGING 2023-10-01 16:36:10 -04:00
BenCodez 10732ee978 Limit monthly votes each day instead of at the end of the month 2023-10-01 13:54:05 -04:00
BenCodez 7deccf2e26 Minor changes to voteparty on proxy setup 2023-09-26 16:50:28 -04:00
Ben 8873fc8263 Merge pull request #1302 from BenCodez/dependabot/maven/VotingPlugin/me.clip-placeholderapi-2.11.4
Bump me.clip:placeholderapi from 2.11.3 to 2.11.4 in /VotingPlugin
2023-09-25 16:45:05 -04:00
Ben aaaaf2c670 Merge pull request #1303 from BenCodez/dependabot/maven/VotingPlugin/org.projectlombok-lombok-1.18.30
Bump org.projectlombok:lombok from 1.18.28 to 1.18.30 in /VotingPlugin
2023-09-25 16:44:50 -04:00
Ben 1e8421f83f Merge pull request #1304 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-shade-plugin-3.5.1
Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.0 to 3.5.1 in /VotingPlugin
2023-09-25 16:44:45 -04:00
dependabot[bot] a29a7bf5c3 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.0 to 3.5.1.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.5.0...maven-shade-plugin-3.5.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-25 06:33:21 +00:00
dependabot[bot] fae67a49ce Bump org.projectlombok:lombok from 1.18.28 to 1.18.30 in /VotingPlugin
Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.28 to 1.18.30.
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.28...v1.18.30)

---
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>
2023-09-25 06:33:11 +00:00
dependabot[bot] c48a0c1083 Bump me.clip:placeholderapi from 2.11.3 to 2.11.4 in /VotingPlugin
Bumps me.clip:placeholderapi from 2.11.3 to 2.11.4.

---
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>
2023-09-25 06:33:05 +00:00
BenCodez 37e29b8643 Update version number to 6.14.1 2023-09-23 20:42:13 -04:00
BenCodez f683cc66c1 Update to 1.20.2 2023-09-22 19:54:16 -04:00
BenCodez 2059832df8 Small change to bungee all sites reward 2023-09-18 19:24:52 -04:00
Ben bda5e61898 Merge pull request #1299 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.6.0
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.5.0 to 3.6.0 in /VotingPlugin
2023-09-18 16:53:46 -04:00
dependabot[bot] dcb5f67ba8 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.5.0 to 3.6.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.5.0...maven-javadoc-plugin-3.6.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>
2023-09-18 06:23:29 +00:00
BenCodez e6065f85cc Adjust allsites check for bungee a bit 2023-09-17 15:18:17 -04:00
BenCodez e0d3d36349 Add option to give extra allsites rewards when on PLUGINMESSAGING 2023-09-17 14:49:57 -04:00
BenCodez ab4d2069eb A lot of internal changes 2023-09-17 13:01:53 -04:00
BenCodez 84f8f9073d Adjustments to cooldown rewards checking 2023-09-10 20:02:31 -04:00
BenCodez 1e9828f594 Adjust cooldown checks a bit more 2023-09-09 21:16:37 -04:00
BenCodez a01050125b Make sure reset time is exactly the right second 2023-09-09 21:13:25 -04:00
BenCodez 60957be6fe Delay votesite cooldown checks a bit 2023-09-09 21:03:35 -04:00
BenCodez a2b094f7d8 Change some debug messages to log messages temporary 2023-09-09 08:49:53 -04:00
BenCodez 56e9705a6e Adjust cooldown checks slightly 2023-09-07 17:24:57 -04:00
BenCodez ad62da3221 Changes to placeholder caching 2023-09-05 21:15:10 -04:00
BenCodez c1421d6324 Add more placeholder cache updates on bungee votes 2023-09-05 20:51:43 -04:00
BenCodez 068c2b704e Add luckperms to softdepend 2023-09-05 17:21:16 -04:00
BenCodez 89d21044d2 Small code cleanup 2023-09-03 21:22:47 -04:00
BenCodez 98246613ca Remove debug messages 2023-09-03 21:22:19 -04:00
BenCodez ee884ee06a More fixes for vote cooldown events/rewards 2023-09-03 21:19:45 -04:00
BenCodez 355ca2cdf0 Add placeholders for last month top voters 2023-09-03 19:54:32 -04:00
BenCodez abc37be619 Small changes to account for using placeholder cache on next placeholder 2023-09-03 14:28:01 -04:00
BenCodez 20d9c08630 Edit votesites.yml comments slightly for new option 2023-09-03 14:15:54 -04:00
BenCodez 523c9e4ef9 Add gui editing ability for VoteDelayDailyHour 2023-09-03 14:14:52 -04:00
BenCodez 76b19f7fb3 Use new VoteDelayDailyHour option to fix issues with vote delay daily 2023-09-03 14:10:33 -04:00
BenCodez d776d0d798 Delay opening voteshop confirm slightly 2023-09-03 12:33:34 -04:00
BenCodez b63da09fe8 Add command to force check cooldown rewards 2023-09-01 19:29:40 -04:00
BenCodez d626210804 Changes to cooldown rewards checking 2023-09-01 19:26:38 -04:00
BenCodez 777c198471 Small changes to cool down checks 2023-08-30 20:15:43 -04:00
BenCodez dbd52a9114 Slight modifications to cooldown checks 2023-08-28 17:10:47 -04:00
BenCodez 3208b865e6 Removed config auto update option 2023-08-27 15:21:06 -04:00
BenCodez a78624eafb Update version number to 6.14 2023-08-27 14:46:41 -04:00
BenCodez 3249a43f4a Added command to manually update config 2023-08-27 14:29:04 -04:00
BenCodez 8e15ba0a3a Disable config auto updating 2023-08-27 14:26:11 -04:00
BenCodez 25969f35e0 Add config updater, disabled by default 2023-08-26 21:50:03 -04:00
BenCodez 6625bf9830 Improve gui editing for adding items, add voteshop item edits 2023-08-26 20:18:46 -04:00
BenCodez a925dcfd88 Edit config comments 2023-08-26 19:37:38 -04:00
BenCodez 40357def84 Add config option to support not adding totals while offline 2023-08-26 19:11:44 -04:00
BenCodez b4806abf70 Fix resetallvotedsites command not checking persite cooldowns 2023-08-26 15:30:44 -04:00
BenCodez f847c033fd Change handling of force cooldown rewards command handling 2023-08-26 15:27:54 -04:00
BenCodez 2919d23fd5 Slight change to placeholder 2023-08-26 14:59:08 -04:00
BenCodez 78412f4717 Add placeholders to PlayerVoteSiteCoolDownEndEvent rewards 2023-08-25 16:57:19 -04:00
BenCodez 438504a344 Check cooldown events on manual vote resets 2023-08-24 21:29:29 -04:00
BenCodez d27bc2580f Fix bottom bar of top voter not working in some rare cases 2023-08-24 19:21:51 -04:00
BenCodez 665865c5b3 Add bstats metrics for placeholder cache level 2023-08-20 13:46:35 -04:00
BenCodez d4124c78c2 Add new cache level, SPECIFICALL 2023-08-20 13:44:04 -04:00
BenCodez 63acc39588 Remove softdepend 2023-08-20 13:20:57 -04:00
BenCodez 46d7a3e95c Fix issue with placeholders not updating 2023-08-15 17:09:08 -04:00
BenCodez 39e5b54af6 Add another placeholder cache level 2023-08-12 21:16:49 -04:00
BenCodez 1a47862d22 Implement placeholder caching changes 2023-08-12 16:04:38 -04:00
BenCodez 63c73b8871 Remove need for external placeholder expansion, include directly 2023-08-08 19:54:00 -04:00
Ben 3bfab3518b Merge pull request #1291 from BenCodez/dependabot/maven/VotingPlugin/net.md-5-bungeecord-api-1.20-R0.1
Bump net.md-5:bungeecord-api from 1.17-R0.1-SNAPSHOT to 1.20-R0.1 in /VotingPlugin
2023-08-07 07:58:29 -04:00
dependabot[bot] 843d47cfb5 Bump net.md-5:bungeecord-api in /VotingPlugin
Bumps [net.md-5:bungeecord-api](https://github.com/SpigotMC/BungeeCord) from 1.17-R0.1-SNAPSHOT to 1.20-R0.1.
- [Commits](https://github.com/SpigotMC/BungeeCord/commits)

---
updated-dependencies:
- dependency-name: net.md-5:bungeecord-api
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 06:26:35 +00:00
BenCodez f7617eba61 Add vote time to playerpostvoteevent 2023-08-06 13:27:21 -04:00
BenCodez 1c95d37ce4 Set default bungee vote party placeholder to -1 to detect issues better 2023-08-05 17:38:09 -04:00
BenCodez db65b564a5 Add config options to adjust invalid arguments message 2023-08-04 20:43:44 -04:00
BenCodez 6f88e126e4 revert changes 2023-08-04 17:19:32 -04:00
BenCodez 25ea0b3a37 Changes to time handling 2023-08-03 20:24:49 -04:00
BenCodez d3bdcc762f Only reload global mysql on reloadall 2023-08-01 16:55:53 -04:00
BenCodez d72eb0e2a7 Force background update on cleartotal command 2023-07-29 20:24:06 -04:00
BenCodez 7b3a458b25 Update cache of online players on resetmilestonecount 2023-07-28 20:10:57 -04:00
BenCodez e2b79072d0 Add config option to disable javascript 2023-07-28 17:28:10 -04:00
BenCodez 7845741cec Handle incorrectly generated directlydefined reward files 2023-07-23 19:25:40 -04:00
BenCodez 6e2497dee7 More config handling improvements 2023-07-23 13:35:07 -04:00
BenCodez 7982c3df80 Switch to better config handling for config editor 2023-07-22 22:15:17 -04:00
BenCodez a7701f27f1 Improve config editor slightly 2023-07-22 21:32:26 -04:00
BenCodez bbe95bf83a Add system to purge cache of proxy votes 2023-07-14 20:40:51 -04:00
BenCodez 4e944df7f2 Add option to disable seconds in last vote times 2023-07-12 19:43:39 -04:00
BenCodez 6461aac03d Change deprecated api 2023-07-09 13:40:41 -04:00
BenCodez 1ece7935a2 Add getInstance method back to user manager for other plugins 2023-07-08 19:05:46 -04:00
BenCodez e130261a75 Add number placeholder for book gui 2023-07-07 12:46:29 -04:00
BenCodez c65c241b4d Add ability to manual layout in bookgui 2023-07-07 12:44:21 -04:00
BenCodez 9876e8e77b https://github.com/BenCodez/AdvancedCore/wiki/AdvancedPriority-Examples 2023-07-05 14:47:45 -04:00
BenCodez 674c41fec2 Improve config editor 2023-07-04 16:19:54 -04:00
BenCodez 6c295ec07f Small adjustment 2023-07-01 17:28:46 -04:00
BenCodez 332b7b667e Use new config editor 2023-06-25 17:38:03 -04:00
BenCodez 173bd381a5 Minor adjustment to plugin.yml 2023-06-25 16:29:51 -04:00
BenCodez 6154efdd50 Adjustments to vote handling 2023-06-23 18:57:58 -04:00
BenCodez ee0dcf8019 Add random global command to vote party 2023-06-21 20:18:51 -04:00
BenCodez 6a4740f729 Disable default worlds check on vote reminding 2023-06-20 20:27:56 -04:00
BenCodez ccf58be365 Add new offline vote limit feature 2023-06-20 20:06:47 -04:00
Ben b871278d82 Merge pull request #1286 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-jar-plugin-3.3.0
Bump maven-jar-plugin from 2.3.1 to 3.3.0 in /VotingPlugin
2023-06-19 21:07:19 -04:00
Ben 90bc2dd3ee Merge pull request #1285 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-shade-plugin-3.5.0
Bump maven-shade-plugin from 3.3.0 to 3.5.0 in /VotingPlugin
2023-06-19 21:07:04 -04:00
Ben a85b9dce23 Merge pull request #1284 from BenCodez/dependabot/maven/VotingPlugin/org.bstats-bstats-velocity-3.0.2
Bump bstats-velocity from 2.2.1 to 3.0.2 in /VotingPlugin
2023-06-19 21:06:57 -04:00
Ben a171fad307 Merge pull request #1283 from BenCodez/dependabot/maven/VotingPlugin/org.sonatype.plugins-nexus-staging-maven-plugin-1.6.13
Bump nexus-staging-maven-plugin from 1.5.1 to 1.6.13 in /VotingPlugin
2023-06-19 21:06:51 -04:00
dependabot[bot] eba230e5c0 Bump maven-jar-plugin from 2.3.1 to 3.3.0 in /VotingPlugin
Bumps [maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 2.3.1 to 3.3.0.
- [Release notes](https://github.com/apache/maven-jar-plugin/releases)
- [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-2.3.1...maven-jar-plugin-3.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-20 01:06:17 +00:00
dependabot[bot] ffd1f616d4 Bump maven-shade-plugin from 3.3.0 to 3.5.0 in /VotingPlugin
Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.3.0 to 3.5.0.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.3.0...maven-shade-plugin-3.5.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>
2023-06-20 01:06:12 +00:00
dependabot[bot] 4dfbf0c71f Bump bstats-velocity from 2.2.1 to 3.0.2 in /VotingPlugin
Bumps [bstats-velocity](https://github.com/Bastian/bStats-Metrics) from 2.2.1 to 3.0.2.
- [Release notes](https://github.com/Bastian/bStats-Metrics/releases)
- [Commits](https://github.com/Bastian/bStats-Metrics/compare/v2.2.1...v3.0.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-20 01:04:32 +00:00
dependabot[bot] c97616eb8d Bump nexus-staging-maven-plugin from 1.5.1 to 1.6.13 in /VotingPlugin
Bumps nexus-staging-maven-plugin from 1.5.1 to 1.6.13.

---
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>
2023-06-20 01:04:25 +00:00
Ben 6039bb12b8 Update dependabot.yml 2023-06-19 21:03:51 -04:00
Ben 11bf99faf9 Merge pull request #1282 from BenCodez/dependabot/maven/VotingPlugin/org.projectlombok-lombok-1.18.28
Bump lombok from 1.18.20 to 1.18.28 in /VotingPlugin
2023-06-19 20:58:18 -04:00
Ben cbfde9bedd Merge pull request #1280 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-resources-plugin-3.3.1
Bump maven-resources-plugin from 3.1.0 to 3.3.1 in /VotingPlugin
2023-06-19 20:58:08 -04:00
Ben 0ab0fa5fb5 Merge pull request #1279 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.5.0
Bump maven-javadoc-plugin from 2.10.4 to 3.5.0 in /VotingPlugin
2023-06-19 20:57:47 -04:00
Ben fd460787c3 Update dependabot.yml 2023-06-19 20:57:21 -04:00
dependabot[bot] 524d22d37a Bump lombok from 1.18.20 to 1.18.28 in /VotingPlugin
Bumps [lombok](https://github.com/projectlombok/lombok) from 1.18.20 to 1.18.28.
- [Release notes](https://github.com/projectlombok/lombok/releases)
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.20...v1.18.28)

---
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>
2023-06-20 00:55:51 +00:00
dependabot[bot] 220368d037 Bump maven-resources-plugin from 3.1.0 to 3.3.1 in /VotingPlugin
Bumps [maven-resources-plugin](https://github.com/apache/maven-resources-plugin) from 3.1.0 to 3.3.1.
- [Release notes](https://github.com/apache/maven-resources-plugin/releases)
- [Commits](https://github.com/apache/maven-resources-plugin/compare/maven-resources-plugin-3.1.0...maven-resources-plugin-3.3.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-20 00:55:41 +00:00
dependabot[bot] 5d86c5297d Bump maven-javadoc-plugin from 2.10.4 to 3.5.0 in /VotingPlugin
Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 2.10.4 to 3.5.0.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-2.10.4...maven-javadoc-plugin-3.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-20 00:55:26 +00:00
Ben 7d69f1e496 Merge pull request #1278 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-deploy-plugin-3.1.1
Bump maven-deploy-plugin from 3.0.0-M1 to 3.1.1 in /VotingPlugin
2023-06-19 20:55:02 -04:00
dependabot[bot] e2784c6b17 Bump maven-deploy-plugin from 3.0.0-M1 to 3.1.1 in /VotingPlugin
Bumps [maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.0.0-M1 to 3.1.1.
- [Release notes](https://github.com/apache/maven-deploy-plugin/releases)
- [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.0.0-M1...maven-deploy-plugin-3.1.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-20 00:54:04 +00:00
Ben f9ce8f325d Update dependabot.yml 2023-06-19 20:53:35 -04:00
Ben b059fc644a Update dependabot.yml 2023-06-19 20:52:23 -04:00
Ben 5c7e5d2d59 Create dependabot.yml 2023-06-19 20:50:36 -04:00
BenCodez 3b4dde335d Implement better command handler api to handle player commands 2023-06-19 20:01:59 -04:00
BenCodez f00ca81c28 Use new command handler constructor 2023-06-19 19:46:58 -04:00
Ben 36ef5e15cf Update publish-javadoc.yml 2023-06-18 15:46:27 -04:00
BenCodez 9a122fb46d Change deploy profile slightly 2023-06-18 15:36:02 -04:00
BenCodez 17fc78a15f Fix profile 2023-06-18 15:29:30 -04:00
BenCodez 0718f0976d Add javadoc profile 2023-06-18 15:27:14 -04:00
Ben 580e7d3061 Update publish-javadoc.yml 2023-06-18 15:26:59 -04:00
Ben 29af36a9e9 Create publish-javadoc.yml 2023-06-18 15:22:10 -04:00
Ben 56d39722cb Delete publish-javadoc.yml 2023-06-18 13:43:09 -04:00
Ben 6a202d4768 Update publish-javadoc.yml 2023-06-18 13:39:12 -04:00
Ben d399684bfa Create publish-javadoc.yml 2023-06-18 13:35:08 -04:00
Ben 1a0da65c66 Delete publish-javadoc.yml 2023-06-18 13:25:35 -04:00
Ben 463b303f2e Update publish-javadoc.yml 2023-06-18 13:22:46 -04:00
Ben abf0e2bebb Update publish-javadoc.yml 2023-06-18 13:17:51 -04:00
Ben 29670f8c22 Update publish-javadoc.yml 2023-06-18 13:16:18 -04:00
Ben 7b08d6806b Update publish-javadoc.yml 2023-06-18 13:13:47 -04:00
Ben 3211e22963 Update publish-javadoc.yml 2023-06-18 12:52:23 -04:00
Ben 2634639f6b Update publish-javadoc.yml 2023-06-18 12:49:08 -04:00
Ben 0798110743 Update publish-javadoc.yml 2023-06-18 12:46:46 -04:00
Ben 2f90e112b1 Update publish-javadoc.yml 2023-06-18 12:43:16 -04:00
Ben 661ea3ce94 Update publish-javadoc.yml 2023-06-17 22:17:11 -04:00
Ben 8d6e95927c Merge pull request #1277 from BenCodez/Auto-upload-javadoc
Create publish-javadoc.yml
2023-06-17 22:14:05 -04:00
Ben c138edccc8 Create publish-javadoc.yml 2023-06-17 22:13:51 -04:00
83 changed files with 4185 additions and 2297 deletions

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
# These are supported funding model platforms
github: BenCodez # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
#patreon: # Replace with a single Patreon username
#open_collective: # Replace with a single Open Collective username
#ko_fi: # Replace with a single Ko-fi username
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
#liberapay: # Replace with a single Liberapay username
#issuehunt: # Replace with a single IssueHunt username
#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
#polar: # Replace with a single Polar username
#buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
custom: ["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YQBX25RTXJ5DG"]
+11
View File
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "maven" # See documentation for possible values
directory: "/VotingPlugin/" # Location of package manifests
schedule:
interval: "weekly"
+24
View File
@@ -0,0 +1,24 @@
name: Deploy Javadoc
on:
release:
types: [published]
branches:
- master
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Deploy JavaDoc 🚀
uses: MathieuSoysal/Javadoc-publisher.yml@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
javadoc-branch: gh-pages
java-version: 17
target-folder: ''
project: maven # or gradle
# subdirectories: moduleA moduleB #for subdirectories support, needs to be run with custom command
custom-command: mvn -f VotingPlugin/pom.xml deploy -P javadoc javadoc:aggregate
javadoc-source-folder: 'VotingPlugin/target/apidocs'
File renamed without changes.
+1
View File
@@ -5,3 +5,4 @@
/*.iml
/.settings/
/.classpath
/.factorypath
+18
View File
@@ -14,8 +14,19 @@ UseBungeecord: false
# SOCKETS
# PLUGINMESSAGING (Recommended)
# MYSQL
# REDIS (2nd Most Recommended)
BungeeMethod: PLUGINMESSAGING
# Use Redis for between server communication, set BungeeMethod to REDIS to use this
Redis:
Host: localhost
Port: 6379
# To get the user name, run redis-cli, if you set a password, run "auth <your password>" and if the out put is "OK" run "ACL USERS"
Username: 'default'
Password: ''
# Set a prefix from an entire proxy network if using multi-proxy setup below
Prefix: ''
# Enables more debug messages for communication between servers
# Use /votingpluginbungee status for testing communication
BungeeDebug: false
@@ -52,6 +63,13 @@ PerServerPoints: false
# Should allow some compability with other plugins
TriggerVotifierEvent: false
# If enabled plugin will give extra allsites reward if deterimned that it should
# E.g. user votes offline for 7 days, they will only get 1 allsites reward by default
# When enabled, they should get 7
# Only applies to PLUGINMESSAGING
# Recommend enabling ExtraAllSitesCheck in config.yml as well
GiveExtraAllSitesRewards: false
# What server this is in bungee (must match)
# Also can be applied to rewards
Server: PleaseSet
+47 -10
View File
@@ -50,7 +50,7 @@ VoteReminding:
# Requires VoteDelays to be setup properly
# Use /vote next to see when you can be reminded
# Players require the perm "VotingPlugin.Login.RemindVotes" or "VotingPlugin.Player"
# To remind if any votesite is available (rather than all) use the permission "VotingPlugin.Login.RemindVotes.Any"
# To remind if all votesites are available (rather than any) use the permission "VotingPlugin.Login.RemindVotes.All"
Enabled: true
# Will remind player on login if he can vote
@@ -172,6 +172,8 @@ Format:
TimeFormat: '%amount% %TimeType%'
LastVoted: '%times% ago'
NeverVoted: 'Never voted'
# Whether or not to include seconds into last voted time
IncludeSeconds: true
# Format for /vote total
Total:
@@ -331,6 +333,11 @@ Format:
Weekly: 'Weekly'
Monthly: 'Monthly'
AllTime: 'AllTime'
# Invalid command messages
InvalidCommand:
Vote: '&4No valid arguments, see /vote help!'
AdminVote: '&4No valid arguments, see /adminvote help!'
# Playernames to not be broadcasted when voting
# case sensitive
@@ -419,8 +426,10 @@ LogVotesToFile: false
UsePrimaryAccountForPlaceholders: false
# Valid Options:
# AUTO - Auto cache after they have been used (Recommended)
# SPECIFIC - Only cache certain placeholders
# AUTOALL - Auto cache placeholders after they have been used and cache all players placeholder all the time
# AUTO - Auto cache after they have been used and cache online players placeholders (Recommended)
# SPECIFIC - Only cache certain placeholders for online players
# SPECIFICALL - Only cache certain placeholders for all players
# NONE - Don't cache any placeholders
PlaceholderCacheLevel: AUTO
@@ -447,10 +456,12 @@ UseJavascriptPlaceholders: false
# For the example below use %votingplugin_custom_enoughpoints_5%
# DO NOT USE ON MAIN THREAD IF POSSIBLE
# Keep everything lowercase
# Example:
#CustomPlaceholderReturns:
# 'enoughpoints_5':
# 'true': 'User has enough points'
# 'false': 'User does not have enough points'
CustomPlaceholderReturns: {}
###########################################
# Login options
@@ -464,7 +475,7 @@ TreatVanishAsOffline: false
DelayLoginEvent: 0
# Wait until user is logged in with AuthMe
# Requires AuthMe
# Requires AuthMe or LoginSecurity
WaitUntilLoggedIn: true
###########################################
@@ -506,21 +517,30 @@ QueueVotesDuringTimeChange: false
# Most cases this will work all the time
AutoCreateVoteSites: true
# Experiemtental feature
# Uses https://github.com/BenCodez/VotingPlugin/wiki/Minecraft-Server-Lists
# Not all voting sites use the domain name as the service sites
# This feature is an attempt to ease setup for new users by matching domain name to actual service site
AdvancedServiceSiteHandling: false
# Set this to false to disable the plugin adding totals
# Not really recommended
AddTotals: true
# Disabling this prevents offline votes from adding totals to users
AddTotalsOffline: true
# If false, votestreaks will be disabled
UseVoteStreaks: true
# If false, storing best totals will be disabled
UseHighestTotals: true
# Enable Geyser prefix support
# Geyser support is hit or miss currently
# May work best if players vote with prefix
GeyserPrefixSupport: false
GeyserPrefix: '*'
# Geyser/Bedrock player support
# Set prefix used for voting
# Players should vote with prefix
# https://github.com/BenCodez/VotingPlugin/wiki/Bedrock-Player-Support
BedrockPlayerPrefix: '.'
# Whether or not to create daily backups. (Only the most recent ones get kept)
CreateBackups: true
@@ -538,11 +558,28 @@ OnlineMode: true
# May improve performance
#DisableCheckOnWorldChange: false
# Disable javascript processing in messages/rewards
DisableJavascript: false
# If true, number of vote shop purchases will be tracked
# Data will be tracked in serverdata.yml, may change in the future
# No commands to view data currently
TrackShopPurchases: false
# Limits about of offline votesites
# Does not currently work with bungee votes from votingplugin
OfflineVotesLimit:
# Enable or disable
Enabled: false
# Limit of votes per votesite
Amount: 5
# Default worlds set for all rewards
DefaultRewardWorlds: []
# Default blackedlisted worlds set for all rewards
DefaultRewardBlackListedWorlds: []
###########################################
# Skull settings
###########################################
@@ -678,7 +715,7 @@ DropOnFullInv: true
# This will prevent spam clicking GUI's to prevent exploits
# Number is time in between clicking in milliseconds
SpamClickTime: 150
SpamClickTime: 100
# Message to send when inventory forced closed when spam clicking
# Uncomment to use
#SpamClickMessage: '&cDetected spam clicking GUI, closing to prevent exploits'
+8 -2
View File
@@ -71,7 +71,7 @@ CHEST:
Name: '&4Vote Shop'
Lore:
- '&aYou currently have %points% points'
# 'ExtraName' below is an identifier, can be whatever
# 'ExtraItem' below is an identifier, can be whatever
# ExtraItem:
# Item:
# Material: 'DIRT'
@@ -335,6 +335,8 @@ CHEST:
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
@@ -378,7 +380,11 @@ BOOK:
CanVoteText: 'Click me'
CanVoteColor: 'GREEN'
AlreadyVotedText: 'Click me'
AlreadyVotedColor: 'RED'
AlreadyVotedColor: 'RED'
# If true the layout below is the full book text
Manual: false
# Only works if Manual is enabled
TopLayout: []
Layout:
- '&3&l%Sitename%'
- '[UrlText]'
+11 -1
View File
@@ -83,7 +83,9 @@ VoteParty:
OnlyOncePerDay: false
# If true, will give voteparty once per week only
OnlyOncePerWeek: false
# Reset extra votes
# Reset extra votes weekly
ResetExtraVotesWeekly: false
# Reset extra votes monthly
ResetExtraVotesMonthly: false
# Count votes from /av vote?
CountFakeVotes: true
@@ -93,9 +95,16 @@ VoteParty:
CountOfflineVotes: true
# Broadcast when vote party reached
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
VoteReminderAtVotes: []
# List of commands to execute, these only execute once.
# %player% does not work here
GlobalCommands: []
# List of commands to execute once
# Only run will run
GlobalRandomCommand: []
# Rewards to give per player
Rewards:
# Uncomment below for online players to be rewarded only
@@ -128,6 +137,7 @@ VoteStreak:
# Number of days in a row
# Each day requires one vote
# Add a - to give a reward for every multiple (e.g. 2- = 2,4,6,8, and so on)
# This may not work perfectly on bungee setups at this time
'2':
# Enabled or not
Enabled: false
+7 -3
View File
@@ -38,6 +38,7 @@ VoteSites:
VoteDelay: 24
# Use to have a minute votedelay
# Must set a value on VoteDelay if you plan on only using this setting
#VoteDelayMin: 30
# Require waiting until votedelay time has pasted in order to accept vote
@@ -48,8 +49,11 @@ VoteSites:
# Recommend: false
VoteDelayDaily: false
#Offset time for /vote next caculations
#TimeOffSet: 0
# Replaces offset, set the exact hour based on server time
# Include server time offset when setting this
# 2 = 2 am server time
# Use 1-24
#VoteDelayDailyHour: 14
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
# Setting this to true will execute the reward offline while the player is offline
@@ -115,7 +119,7 @@ VoteSites:
Messages:
Player: 'You got unlucky'
# Give 1 diamond
# Give 1 diamond regardless of above
Items:
item1:
Material: DIAMOND
+65 -12
View File
@@ -19,10 +19,6 @@ Prefix: ''
#Attempt to use mariadb driver
#UseMariaDB: false
# Online mode for UUIDS
# Offline mode setups are not fully tested and are not supported currently
OnlineMode: true
####################################################################################
# Global mysql data handle for between server commmunications
@@ -86,8 +82,18 @@ WhiteListedServers: []
# SOCKETS
# PLUGINMESSAGING (Recommended)
# MYSQL
# REDIS
BungeeMethod: PLUGINMESSAGING
# Use Redis for between server communication, set BungeeMethod to REDIS to use this
Redis:
Host: localhost
Port: 6379
Username: ''
Password: ''
# Set a prefix from an entire proxy network if using mutli-proxy setup below
Prefix: ''
# If false, votes will be checked if user is a valid player that has joined to server
# Works for PLUGINMESSAGING and SOCKETS methods only
# This requires spigot servers AllowUnJoined to be set to true in Config.yml
@@ -106,11 +112,21 @@ BungeeManageTotals: true
# Set DisableBroadcast to true on spigot servers (BungeeSettings.yml) as well
Broadcast: true
# Geyser settings
# This may or may not work
# Does not work on velocity currently
GeyserSupport: false
GeyserPrefix: '.'
# Geyser/bedrock player settings
# https://github.com/BenCodez/VotingPlugin/wiki/Bedrock-Player-Support
BedrockPlayerPrefix: '.'
# Time votes will be cached on proxy
# -1 means no time limit
# Time in days
VoteCacheTime: -1
# Maxium number of votes possible per day
# Usually matches the amount of votesites
# Will limit vote totals to match accordingly
# Only applies for month total
# Set to -1 to disable
MaxAmountOfVotesPerDay: -1
VoteParty:
# If enabled, will trigger vote party reward
@@ -130,6 +146,9 @@ VoteParty:
BungeeCommands: []
Broadcast: '&aVote party has been reached!'
# Online mode for UUIDS
# Offline mode setups are not fully tested and are not supported currently
OnlineMode: true
##########################################
# PLUGINMESSAGING Settings
@@ -137,19 +156,19 @@ VoteParty:
# Applies to PLUGINMESSAGING only
# Votes will be forwarded when specific player is online
# If set to false, rewards should still reward when player logs in (by default)
WaitForUserOnline: false
##########################################
# Multi-proxy setup
# This is still a WIP, use with caution
# Primary server needs votifier and config option enabled
# Primary server needs votifier and config option enabled
# Set socket host on each proxy and primary server set sub proxies
# All servers should be on pluginmessaging or sockets setup
##########################################
# Support for redis
# experimental
# Support for multiple proxies
MultiProxySupport: false
# Enable on primary proxy server with votifier
@@ -160,12 +179,46 @@ PrimaryServer: false
# Must also disable sendtoallservers
MultiProxyOneGlobalReward: false
# Multi-proxy available methods:
# SOCKET
# REDIS
MultiProxyMethod: SOCKET
##########################################
# REDIS Settings
##########################################
# Set multiproxymethod to REDIS to use redis
MultiProxyRedis:
# If true the plugin will use the exsiting connection set above
# Must be on REDIS method to use this setting
UseExistingConnection: false
Host: localhost
Port: 6379
Username: ''
Password: ''
# Set each server it's own proxy name here (can be anything)
ProxyServerName: proxy1
# Set names of other proxy servers
# Must match what's set as the proxy server name above from other servers
# On non primary proxy server just set the primary proxy server name here
ProxyServers:
- proxy2
- proxy3
##########################################
# SOCKET settings for mutli-proxy
##########################################
# Set this for each proxy
MultiProxySocketHost:
Host: 0.0.0.0
Port: 1234
# Set other sub proxies here
# On non primary proxy only set primary proxy
MultiProxyServers:
secondproxy:
Host: 0.0.0.0
+64 -61
View File
@@ -16,7 +16,7 @@ softdepend:
- AuthMe
- SuperVanish
- PremiumVanish
- DiscordSRV
- LuckPerms
loadbefore:
- MCPerks
api-version: 1.13
@@ -141,106 +141,106 @@ commands:
adminvotegivereward:
description: Command Alias
aliases: avgivereward
adminvoteConvertFromData:
adminvoteconvertfromdata:
description: Command Alias
aliases: avConvertFromData
adminvoteConvertToData:
aliases: avconvertfromdata
adminvoteonverttodata:
description: Command Alias
aliases: avConvertFromData
adminvoteClearTotal:
aliases: avconverttodata
adminvotecleartotal:
description: Command Alias
adminvoteBackgroundUpdate:
adminvotebackgroundupdate:
description: Command Alias
aliases: avBackgroundUpdate
adminvoteClearCache:
aliases: avbackgroundupdate
adminvoteclearcache:
description: Command Alias
aliases: avClearCache
adminvoteServiceSites:
aliases: avclearcache
adminvoteservicesites:
description: Command Alias
aliases: avServiceSites
adminvoteVoteParty:
aliases: avservicesites
adminvotevoteparty:
description: Command Alias
aliases: avVoteParty
adminvoteChoices:
aliases: avvoteparty
adminvotechoices:
description: Command Alias
aliases: avChoices
adminvoteReloadAll:
aliases: avchoices
adminvotereloadall:
description: Command Alias
aliases: avReloadAll
adminvotePermsPlayer:
aliases: avreloadall
adminvotepermsplayer:
description: Command Alias
aliases: avPermsPlayer
adminvoteResyncMilestonesAlreadyGiven:
aliases: avpermsplayer
adminvoteresyncmilestonesalreadygiven:
description: Command Alias
aliases: avResyncMilestonesAlreadyGiven
voteSetPrimaryAccount:
aliases: avresyncmilestonesalreadygiven
votesetprimaryaccount:
description: Command Alias
adminvoteClearOfflineVotes:
adminvoteclearofflinevotes:
description: Command Alias
aliases: avClearOfflineVotes
adminvoteGiveAll:
aliases: avclearofflinevotes
adminvotegiveall:
description: Command Alias
aliases: avGiveAll
adminvoteGiveAllOnline:
aliases: avgiveall
adminvotegiveallonline:
description: Command Alias
aliases: avGiveAllOnline
adminvoteForceTimeChanged:
aliases: avgiveallonline
adminvoteforcetimechanged:
description: Command Alias
aliases: avForceTimeChanged
aliases: avforcetimechanged
adminvoteplayername:
description: Command Alias
aliases: avplayername
adminvoteResyncMilestones:
adminvoteresyncmilestones:
description: Command Alias
aliases: avResyncMilestones
adminvoteClearOfflineRewards:
aliases: avresyncmilestones
adminvoteclearofflinerewards:
description: Command Alias
aliases: avClearOfflineRewards
adminvoteUserRemove:
aliases: avclearofflinerewards
adminvoteuserremove:
description: Command Alias
aliases: avUserRemove
adminvotePurge:
aliases: avuserremove
adminvotepurge:
description: Command Alias
aliases: avPurge
adminvoteJavascript:
aliases: avpurge
adminvotejavascript:
description: Command Alias
aliases: avJavascript
adminvoteStatus:
aliases: avjavascript
adminvotestatus:
description: Command Alias
aliases: avStatus
adminvoteTest:
aliases: avstatus
adminvotetest:
description: Command Alias
aliases: avTest
adminvotePlaceholders:
aliases: avtest
adminvoteplaceholders:
description: Command Alias
aliases: avPlaceholders
adminvoteDownloadJenkins:
aliases: avplaceholders
adminvotedownloadjenkins:
description: Command Alias
aliases: avDownloadJenkins
adminvoteSetRequestMethod:
aliases: avdownloadjenkins
adminvotesetrequestmethod:
description: Command Alias
aliases: avSetRequestMethod
adminvoteUser:
aliases: avsetrequestmethod
adminvoteuser:
description: Command Alias
aliases: avUser
adminvoteCurrentPluginTime:
aliases: avuser
adminvotecurrentplugintime:
description: Command Alias
aliases: avCurrentPluginTime
adminvoteResetPoints:
aliases: avcurrentplugintime
adminvoteresetpoints:
description: Command Alias
aliases: avResetPoints
adminvoteRunCMD:
aliases: avresetpoints
adminvoteruncmd:
description: Command Alias
aliases: avRunCMD
aliases: avruncmd
adminvoteuseruuidremove:
description: Command Alias
aliases: avuseruuidremove
adminvoteedit:
description: Command Alias
aliases: avedit
adminvoteResetMilestoneCount:
adminvoteresetmilestonecount:
description: Command Alias
aliases: avResetMilestoneCount
aliases: avresetmilestonecount
permissions:
VotingPlugin.Player:
description: Allows basic access player commands
@@ -257,6 +257,9 @@ permissions:
VotingPlugin.NoRemind:
description: Ignore vote reminding
default: false
VotingPlugin.BypassWaitUntilVoteDelay:
description: Bypass WaitUntilVoteDelay
default: false
VotingPlugin.Sign.Create:
description: Permission to create sign
VotingPlugin.Admin.GenerateServiceSite:
+71 -14
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>${version.art}</artifactId>
<version>6.13.1</version>
<version>6.16</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -59,7 +59,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<version>3.4.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@@ -88,7 +88,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.5.3</version>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<minimizeJar>true</minimizeJar>
@@ -162,7 +162,7 @@
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-resources</id>
@@ -212,24 +212,28 @@
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.20.6-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<version>1.20-R0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -253,9 +257,15 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>2.2.1</version>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
@@ -350,7 +360,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.1</version>
<configuration>
<skip>true</skip>
</configuration>
@@ -377,6 +387,52 @@
</plugins>
</build>
</profile>
<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>
<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-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<phase>deploy</phase>
<configuration>
<sourcepath>${project.basedir}/target/delombok</sourcepath>
<outputDirectory>${project.basedir}/target/apidocs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deploy</id>
<properties>
@@ -385,6 +441,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>deploy</build.profile.id>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
@@ -408,7 +465,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -425,7 +482,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<version>3.1.1</version>
<configuration>
<skip>true</skip>
</configuration>
@@ -433,7 +490,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<version>1.6.13</version>
<executions>
<execution>
<id>default-deploy</id>
@@ -449,7 +506,7 @@
<skipStaging>true</skipStaging>
</configuration>
</plugin>
<plugin>
<!--<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
@@ -475,7 +532,7 @@
</configuration>
</execution>
</executions>
</plugin>
</plugin>-->
</plugins>
</build>
</profile>
@@ -14,6 +14,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
@@ -22,13 +23,16 @@ import com.bencodez.advancedcore.api.user.UserStorage;
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigSpigot;
import com.bencodez.advancedcore.bungeeapi.GlobalMessage.GlobalMessageHandler;
import com.bencodez.advancedcore.bungeeapi.GlobalMessage.GlobalMessageListener;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandler;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.bungee.BungeeVersion;
@@ -49,10 +53,10 @@ public class BungeeHandler implements Listener {
private VotingPluginMain plugin;
@Getter
private int bungeeVotePartyCurrent = 0;
private int bungeeVotePartyCurrent = -2;
@Getter
private int bungeeVotePartyRequired = 0;
private int bungeeVotePartyRequired = -2;
@Getter
private SocketHandler socketHandler;
@@ -62,9 +66,16 @@ public class BungeeHandler implements Listener {
@Getter
private ScheduledExecutorService timer;
@Getter
private RedisHandler redisHandler;
@Getter
private GlobalMessageHandler globalMessageHandler;
private Thread redisThread;
public BungeeHandler(VotingPluginMain plugin) {
this.plugin = plugin;
}
public void close() {
@@ -144,8 +155,9 @@ public class BungeeHandler implements Listener {
long lastUpdated = Long.valueOf(data.get("LastUpdated").getString()).longValue();
plugin.debug("LastUpdated: " + lastUpdated);
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastUpdated > 1000 * 60 * 60
* 1) {
plugin.getLogger().warning("Ignore bungee time change since it was more than 1 hour ago");
* 2) {
plugin.getLogger().warning("Ignoring bungee time change since it was more than 2 hours ago");
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
return false;
}
@@ -262,9 +274,369 @@ public class BungeeHandler implements Listener {
loadGlobalMysql();
globalMessageHandler = new GlobalMessageHandler() {
@Override
public void sendMessage(String subChannel, String... messageData) {
if (method.equals(BungeeMethod.MYSQL)) {
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
} else if (method.equals(BungeeMethod.SOCKETS)) {
ArrayList<String> list = new ArrayList<String>();
list.add(subChannel);
list.addAll(ArrayUtils.getInstance().convert(messageData));
sendData(ArrayUtils.getInstance().convert(list));
} else if (method.equals(BungeeMethod.REDIS)) {
ArrayList<String> list = new ArrayList<String>();
list.add(subChannel);
list.addAll(ArrayUtils.getInstance().convert(messageData));
redisHandler.sendMessage(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
ArrayUtils.getInstance().convert(list));
}
}
};
globalMessageHandler.addListener(new GlobalMessageListener("Vote") {
@Override
public void onReceive(ArrayList<String> args) {
if (args.size() > 8) {
int bungeeVersion = Integer.parseInt(args.get(8));
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
plugin.getLogger().warning("Incompatible version with bungee, please update all servers"
+ bungeeVersion + ":" + BungeeVersion.getPluginMessageVersion());
return;
}
String player = args.get(0);
String uuid = args.get(1);
String service = args.get(2);
long time = Long.parseLong(args.get(3));
plugin.debug("pluginmessaging vote received from " + player + "/" + uuid + " on " + service);
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), player);
boolean wasOnline = Boolean.valueOf(args.get(4));
BungeeMessageData text = new BungeeMessageData(args.get(6));
bungeeVotePartyCurrent = text.getVotePartyCurrent();
bungeeVotePartyRequired = text.getVotePartyRequired();
plugin.getPlaceholders().onBungeeVotePartyUpdate();
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
boolean setTotals = Boolean.valueOf(args.get(7));
user.cache();
boolean broadcast = true;
boolean bungeeBroadcast = false;
if (args.size() > 9) {
bungeeBroadcast = Boolean.valueOf(args.get(9));
}
int num = 1;
if (args.size() > 10) {
num = Integer.valueOf(args.get(10));
}
int numberOfVotes = 1;
if (args.size() > 11) {
numberOfVotes = Integer.valueOf(args.get(11));
}
if (!bungeeBroadcast) {
if (!plugin.getBungeeSettings().isBungeeBroadcast()
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
if (num == 1) {
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
numberOfVotes);
}
} else {
VoteSite site = plugin.getVoteSite(service, true);
if (site != null) {
site.broadcastVote(user, false);
broadcast = false;
} else {
plugin.getLogger().warning("No votesite for " + service);
}
}
}
}
} else {
broadcast = false;
}
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
if (plugin.getBungeeSettings().isPerServerPoints()) {
user.addPoints(plugin.getConfigFile().getPointsOnVote());
}
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
if (Boolean.valueOf(args.get(5))) {
plugin.getServerData().addServiceSite(service);
}
} else {
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
}
}
});
globalMessageHandler.addListener(new GlobalMessageListener("VoteOnline") {
@Override
public void onReceive(ArrayList<String> args) {
if (args.size() > 8) {
int bungeeVersion = Integer.parseInt(args.get(8));
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
return;
}
String player = args.get(0);
String uuid = args.get(1);
String service = args.get(2);
long time = Long.parseLong(args.get(3));
BungeeMessageData text = new BungeeMessageData(args.get(6));
bungeeVotePartyCurrent = text.getVotePartyCurrent();
bungeeVotePartyRequired = text.getVotePartyRequired();
plugin.getPlaceholders().onBungeeVotePartyUpdate();
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
plugin.debug("pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), player);
user.cache();
if (plugin.getBungeeSettings().isPerServerPoints()) {
user.addPoints(plugin.getConfigFile().getPointsOnVote());
}
boolean setTotals = Boolean.valueOf(args.get(7));
boolean wasOnline = Boolean.valueOf(args.get(4));
boolean broadcast = true;
boolean bungeeBroadcast = false;
if (args.size() > 9) {
bungeeBroadcast = Boolean.valueOf(args.get(9));
}
int num = 1;
if (args.size() > 10) {
num = Integer.valueOf(args.get(10));
}
int numberOfVotes = 1;
if (args.size() > 11) {
numberOfVotes = Integer.valueOf(args.get(11));
}
if (!bungeeBroadcast) {
if (!plugin.getBungeeSettings().isBungeeBroadcast()
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
if (num == 1) {
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
numberOfVotes);
}
} else {
VoteSite site = plugin.getVoteSite(service, true);
if (site != null) {
site.broadcastVote(user, false);
broadcast = false;
} else {
plugin.getLogger().warning("No votesite for " + service);
}
}
}
}
} else {
broadcast = false;
}
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
if (plugin.getBungeeSettings().isPerServerPoints()) {
user.addPoints(plugin.getConfigFile().getPointsOnVote());
}
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
if (Boolean.valueOf(args.get(5))) {
plugin.getServerData().addServiceSite(service);
}
} else {
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
}
}
});
globalMessageHandler.addListener(new GlobalMessageListener("VoteUpdate") {
@Override
public void onReceive(ArrayList<String> args) {
String player = args.get(0);
plugin.debug("pluginmessaging voteupdate received for " + player);
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(player));
user.cache();
user.offVote();
if (args.size() > 3 && plugin.getBungeeSettings().isPerServerMilestones()) {
BungeeMessageData text = new BungeeMessageData(args.get(3));
plugin.getSpecialRewards().checkMilestone(user, text, true);
}
if (args.size() > 2) {
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
}
plugin.setUpdate(true);
}
});
globalMessageHandler.addListener(new GlobalMessageListener("BungeeTimeChange") {
@Override
public void onReceive(ArrayList<String> args) {
checkGlobalData();
}
});
globalMessageHandler.addListener(new GlobalMessageListener("VoteBroadcast") {
@Override
public void onReceive(ArrayList<String> args) {
if (args.size() > 2) {
String uuid = args.get(0);
String service = args.get(2);
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
VoteSite site = plugin.getVoteSite(service, true);
if (site != null) {
site.broadcastVote(user, false);
} else {
plugin.getLogger().warning("No votesite for " + service);
}
}
}
});
globalMessageHandler.addListener(new GlobalMessageListener("VoteBroadcastOffline") {
@Override
public void onReceive(ArrayList<String> args) {
if (args.size() > 2) {
String uuid = args.get(0);
String votes = args.get(2);
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
}
});
globalMessageHandler.addListener(new GlobalMessageListener("Status") {
@Override
public void onReceive(ArrayList<String> args) {
String server = args.get(0);
sendMessage(globalMessageHandler, "statusokay", server);
}
});
globalMessageHandler.addListener(new GlobalMessageListener("ServerName") {
@Override
public void onReceive(ArrayList<String> args) {
String server = args.get(0);
if (!plugin.getOptions().getServer().equals(server)) {
plugin.getLogger().warning("Server name doesn't match in BungeeSettings.yml, should be " + server);
}
}
});
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBungee") {
@Override
public void onReceive(ArrayList<String> args) {
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
});
}
for (Player p : Bukkit.getOnlinePlayers()) {
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
}
}
});
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBroadcast") {
@Override
public void onReceive(ArrayList<String> args) {
String broadcast = args.get(0);
MiscUtils.getInstance().broadcast(broadcast);
}
});
if (method.equals(BungeeMethod.MYSQL)) {
plugin.registerBungeeChannels("vp:vp");
} else if (method.equals(BungeeMethod.REDIS)) {
redisHandler = new RedisHandler(plugin.getBungeeSettings().getRedisHost(),
plugin.getBungeeSettings().getRedisPort(), plugin.getBungeeSettings().getRedisUsername(),
plugin.getBungeeSettings().getRedisPassword()) {
@Override
protected void onMessage(String channel, String[] message) {
plugin.getLogger().info(channel
+ ArrayUtils.getInstance().makeStringList(ArrayUtils.getInstance().convert(message)));
if (message.length > 0) {
ArrayList<String> list = new ArrayList<String>();
for (int i = 1; i < message.length; i++) {
list.add(message[i]);
}
globalMessageHandler.onMessage(message[0], list);
}
}
@Override
public void debug(String message) {
if (plugin.getBungeeSettings().isBungeeDebug()) {
plugin.debug(message);
}
}
};
redisThread = new Thread(new Runnable() {
@Override
public void run() {
if (plugin.isEnabled()) {
redisHandler.loadListener(
new RedisListener(redisHandler, plugin.getBungeeSettings().getRedisPrefix()
+ "VotingPlugin_" + plugin.getBungeeSettings().getServer()));
}
}
});
redisThread.start();
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
plugin.registerBungeeChannels("vp:vp");
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
@@ -275,274 +647,71 @@ public class BungeeHandler implements Listener {
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
if (args.size() > 8) {
int bungeeVersion = Integer.parseInt(args.get(8));
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
return;
}
String player = args.get(0);
String uuid = args.get(1);
String service = args.get(2);
long time = Long.parseLong(args.get(3));
plugin.debug("pluginmessaging vote received from " + player + "/" + uuid + " on " + service);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
player);
boolean wasOnline = Boolean.valueOf(args.get(4));
BungeeMessageData text = new BungeeMessageData(args.get(6));
bungeeVotePartyCurrent = text.getVotePartyCurrent();
bungeeVotePartyRequired = text.getVotePartyRequired();
plugin.getPlaceholders().onBungeeVotePartyUpdate();
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
boolean setTotals = Boolean.valueOf(args.get(7));
user.cache();
boolean broadcast = true;
boolean bungeeBroadcast = false;
if (args.size() > 9) {
bungeeBroadcast = Boolean.valueOf(args.get(9));
}
int num = 1;
if (args.size() > 10) {
num = Integer.valueOf(args.get(10));
}
int numberOfVotes = 1;
if (args.size() > 11) {
numberOfVotes = Integer.valueOf(args.get(11));
}
if (!bungeeBroadcast) {
if (!plugin.getBungeeSettings().isBungeeBroadcast()
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
if (num == 1) {
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
numberOfVotes);
}
} else {
VoteSite site = plugin.getVoteSite(service, true);
if (site != null) {
site.broadcastVote(user, false);
broadcast = false;
} else {
plugin.getLogger().warning("No votesite for " + service);
}
}
}
}
} else {
broadcast = false;
}
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
if (plugin.getBungeeSettings().isPerServerPoints()) {
user.addPoints(plugin.getConfigFile().getPointsOnVote());
}
if (Boolean.valueOf(args.get(5))) {
plugin.getServerData().addServiceSite(service);
}
} else {
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
}
globalMessageHandler.onMessage("Vote", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteOnline") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
if (args.size() > 8) {
int bungeeVersion = Integer.parseInt(args.get(8));
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
return;
}
String player = args.get(0);
String uuid = args.get(1);
String service = args.get(2);
long time = Long.parseLong(args.get(3));
BungeeMessageData text = new BungeeMessageData(args.get(6));
bungeeVotePartyCurrent = text.getVotePartyCurrent();
bungeeVotePartyRequired = text.getVotePartyRequired();
plugin.getPlaceholders().onBungeeVotePartyUpdate();
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
plugin.debug(
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
player);
user.cache();
if (plugin.getBungeeSettings().isPerServerPoints()) {
user.addPoints(plugin.getConfigFile().getPointsOnVote());
}
boolean setTotals = Boolean.valueOf(args.get(7));
boolean wasOnline = Boolean.valueOf(args.get(4));
boolean broadcast = true;
boolean bungeeBroadcast = false;
if (args.size() > 9) {
bungeeBroadcast = Boolean.valueOf(args.get(9));
}
int num = 1;
if (args.size() > 10) {
num = Integer.valueOf(args.get(10));
}
int numberOfVotes = 1;
if (args.size() > 11) {
numberOfVotes = Integer.valueOf(args.get(11));
}
if (!bungeeBroadcast) {
if (!plugin.getBungeeSettings().isBungeeBroadcast()
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
if (num == 1) {
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
numberOfVotes);
}
} else {
VoteSite site = plugin.getVoteSite(service, true);
if (site != null) {
site.broadcastVote(user, false);
broadcast = false;
} else {
plugin.getLogger().warning("No votesite for " + service);
}
}
}
}
} else {
broadcast = false;
}
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
if (plugin.getBungeeSettings().isPerServerPoints()) {
user.addPoints(plugin.getConfigFile().getPointsOnVote());
}
if (Boolean.valueOf(args.get(5))) {
plugin.getServerData().addServiceSite(service);
}
} else {
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
}
globalMessageHandler.onMessage("VoteOnline", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteUpdate") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
String player = args.get(0);
plugin.debug("pluginmessaging voteupdate received for " + player);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(player));
user.cache();
user.offVote();
if (args.size() > 2) {
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
}
plugin.setUpdate(true);
globalMessageHandler.onMessage("VoteUpdate", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("BungeeTimeChange") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
checkGlobalData();
globalMessageHandler.onMessage("BungeeTimeChange", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
if (args.size() > 2) {
String uuid = args.get(0);
String service = args.get(2);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
args.get(1));
VoteSite site = plugin.getVoteSite(service, true);
if (site != null) {
site.broadcastVote(user, false);
} else {
plugin.getLogger().warning("No votesite for " + service);
}
}
globalMessageHandler.onMessage("VoteBroadcast", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcastOffline") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
if (args.size() > 2) {
String uuid = args.get(0);
String votes = args.get(2);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
args.get(1));
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
globalMessageHandler.onMessage("VoteBroadcastOffline", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
String server = args.get(0);
plugin.getPluginMessaging().sendPluginMessage("statusokay", server);
globalMessageHandler.onMessage("Status", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("ServerName") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
globalMessageHandler.onMessage("ServerName", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
}
});
}
for (Player p : Bukkit.getOnlinePlayers()) {
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
}
globalMessageHandler.onMessage("VotePartyBungee", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBroadcast") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
String broadcast = args.get(0);
MiscUtils.getInstance().broadcast(broadcast);
globalMessageHandler.onMessage("VotePartyBroadcast", args);
}
});
@@ -54,9 +54,9 @@ import com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator;
import com.bencodez.advancedcore.api.skull.SkullHandler;
import com.bencodez.advancedcore.api.updater.Updater;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.api.yml.YMLConfig;
import com.bencodez.advancedcore.logger.Logger;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
import com.bencodez.votingplugin.commands.CommandLoader;
import com.bencodez.votingplugin.commands.executers.CommandAdminVote;
@@ -81,6 +81,8 @@ import com.bencodez.votingplugin.listeners.VotingPluginUpdateEvent;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.placeholders.MVdWPlaceholders;
import com.bencodez.votingplugin.placeholders.PlaceHolders;
import com.bencodez.votingplugin.placeholders.VotingPluginExpansion;
import com.bencodez.votingplugin.servicesites.ServiceSiteHandler;
import com.bencodez.votingplugin.signs.Signs;
import com.bencodez.votingplugin.specialrewards.SpecialRewards;
import com.bencodez.votingplugin.test.VoteTester;
@@ -222,7 +224,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private UserManager votingPluginUserManager;
private void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
public void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
getRewardHandler().addDirectlyDefined(directlyDefinedReward);
}
@@ -261,13 +263,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
if (ymlError) {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
plugin.getLogger().severe("Failed to load a file, check startup log");
}
}, 10);
}, 1);
}
}
@@ -341,28 +343,41 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
public ArrayList<VoteSite> getVoteSitesEnabled() {
ArrayList<VoteSite> sites = new ArrayList<VoteSite>();
for (VoteSite site : getVoteSites()) {
if (site.isEnabled()) {
sites.add(site);
}
}
return sites;
}
public String getVoteSiteName(boolean checkEnabled, String... urls) {
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames(checkEnabled);
for (String url : urls) {
if (url == null) {
return null;
}
if (sites != null) {
for (String siteName : sites) {
String URL = getConfigVoteSites().getServiceSite(siteName);
if (URL != null) {
if (URL.equalsIgnoreCase(url)) {
if (!url.isEmpty()) {
if (sites != null) {
for (String siteName : sites) {
String URL = getConfigVoteSites().getServiceSite(siteName);
if (URL != null) {
if (URL.equalsIgnoreCase(url)) {
return siteName;
}
}
if (siteName.equalsIgnoreCase(url)) {
return siteName;
}
}
if (siteName.equalsIgnoreCase(url)) {
return siteName;
}
}
}
}
return url;
}
for (String url : urls) {
return url;
}
@@ -928,10 +943,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
getBungeeSettings().setValue(path, value);
}
});
getRewardHandler().checkDirectlyDefined();
}
private void loadTimer() {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -956,7 +974,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}, 1000, 1000 * 30, TimeUnit.MILLISECONDS);
}
}, 40L);
}, 2);
}
@@ -1014,6 +1032,15 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private TimeQueueHandler timeQueueHandler;
private void loadBungeeHandler() {
bungeeHandler = new BungeeHandler(this);
bungeeHandler.load();
if (getOptions().getServer().equalsIgnoreCase("PleaseSet")) {
getLogger().warning("Bungeecoord is true and server name is not set, bungeecoord features may not work");
}
}
@Override
public void onPostLoad() {
loadVersionFile();
@@ -1024,20 +1051,18 @@ public class VotingPluginMain extends AdvancedCorePlugin {
loadVoteTimer();
if (bungeeSettings.isUseBungeecoord()) {
bungeeHandler = new BungeeHandler(this);
bungeeHandler.load();
if (getOptions().getServer().equalsIgnoreCase("PleaseSet")) {
getLogger()
.warning("Bungeecoord is true and server name is not set, bungeecoord features may not work");
}
loadBungeeHandler();
}
if (!bungeeSettings.isUseBungeecoord() || !bungeeSettings.isGloblalDataEnabled()) {
this.timeQueueHandler = new TimeQueueHandler(this);
}
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new VotingPluginExpansion(this).register();
getLogger().info("Loading PlaceholderAPI expansion");
}
registerCommands();
checkVotifier();
registerEvents();
@@ -1046,13 +1071,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
checkUpdate.startUp();
voteReminding = new VoteReminding(this);
voteReminding.loadRemindChecking();
voteReminding.loadReminds();
specialRewards = new SpecialRewards(this);
signs = new Signs(this);
coolDownCheck.checkEnabled();
coolDownCheck.load();
BukkitScheduler.runTask(plugin, new Runnable() {
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -1062,7 +1088,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
topVoterHandler = new TopVoterHandler(this);
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1085,7 +1111,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
topVoterHandler.register();
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1211,18 +1237,29 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
if (!issues) {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
plugin.getLogger().warning(
"Detected an issue with voting sites, check the server startup log for more details: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
}
}, 30l);
}, 5);
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
serviceSiteHandler = new ServiceSiteHandler(plugin);
}
}, 10);
}
}
@Getter
private ServiceSiteHandler serviceSiteHandler;
/*
* (non-Javadoc)
*
@@ -1273,7 +1310,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
voteTimer.shutdown();
try {
voteTimer.awaitTermination(10, TimeUnit.SECONDS);
voteTimer.awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -1310,7 +1347,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
Permission perm = Bukkit.getPluginManager().getPermission("VotingPlugin.Player");
if (perm != null) {
if (configFile.getGiveDefaultPermission()) {
if (configFile.isGiveDefaultPermission()) {
perm.setDefault(PermissionDefault.TRUE);
getLogger().info("Giving VotingPlugin.Player permission by default, can be disabled in the config");
} else {
@@ -1380,7 +1417,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
bungeeSettings.reloadData();
if (bungeeSettings.isUseBungeecoord()) {
getBungeeHandler().loadGlobalMysql();
if (getBungeeHandler() == null) {
loadBungeeHandler();
}
if (userStorage) {
getBungeeHandler().loadGlobalMysql();
}
}
checkYMLError();
@@ -1390,16 +1432,29 @@ public class VotingPluginMain extends AdvancedCorePlugin {
updateAdvancedCoreHook();
plugin.loadVoteSites();
loadDirectlyDefined();
reloadAdvancedCore(userStorage);
getOptions().setServer(bungeeSettings.getServer());
if (userStorage) {
placeholders.load();
placeholders.reload();
getCoolDownCheck().getTimer().schedule(new Runnable() {
@Override
public void run() {
for (VoteSite site : plugin.getVoteSites()) {
if (site.isVoteDelayDaily()) {
getCoolDownCheck().checkAllVoteSite(site);
}
}
}
}, 5, TimeUnit.SECONDS);
}
voteReminding.loadRemindChecking();
coolDownCheck.checkEnabled();
loadDirectlyDefined();
setUpdate(true);
}
@@ -1462,7 +1517,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
}
boolean topVoterIgnorePermissionUse = plugin.getConfigFile()
.getTopVoterIgnorePermission();
.isTopVoterIgnorePermission();
ArrayList<String> blackList = plugin.getConfigFile().getBlackList();
// ArrayList<String> uuids = getVotingPluginUserManager().getAllUUIDs();
@@ -1519,7 +1574,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
}
if (plugin != null) {
plugin.getPlaceholders().onUpdate(user);
if (!plugin.getPlaceholders().getCacheLevel().onlineOnly()
|| user.isOnline()) {
plugin.getPlaceholders().onUpdate(user, false);
}
}
user.clearTempCache();
user = null;
@@ -1593,7 +1651,23 @@ public class VotingPluginMain extends AdvancedCorePlugin {
public void updateAdvancedCoreHook() {
getJavascriptEngine().put("VotingPlugin", this);
allowDownloadingFromSpigot(15358);
setConfigData(configFile.getData());
setConfigData(new YMLConfig(this, configFile.getData()) {
@Override
public void setValue(String path, Object value) {
configFile.setValue(path, value);
}
@Override
public void saveData() {
configFile.saveData();
}
@Override
public void createSection(String key) {
configFile.createSection(key);
}
});
if (bungeeSettings.isUseBungeecoord()) {
getOptions().setPerServerRewards(getBungeeSettings().isPerServerRewards());
}
@@ -65,13 +65,20 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (!plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
if (!plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
return "False";
} else {
return "True";
}
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("placeholder_cache_level", new Callable<String>() {
@Override
public String call() throws Exception {
return plugin.getPlaceholders().getCacheLevel().toString();
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_milestone", new Callable<String>() {
@Override
@@ -154,7 +161,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
return "" + plugin.getVoteSites().size();
return "" + plugin.getVoteSitesEnabled().size();
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards", new Callable<String>() {
@@ -218,28 +225,28 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
return "" + plugin.getConfigFile().getVoteRemindingEnabled();
return "" + plugin.getConfigFile().isVoteRemindingEnabled();
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly", new Callable<String>() {
@Override
public String call() throws Exception {
return "" + plugin.getConfigFile().getLoadTopVoterMonthly();
return "" + plugin.getConfigFile().isLoadTopVoterMonthly();
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Weekly", new Callable<String>() {
@Override
public String call() throws Exception {
return "" + plugin.getConfigFile().getLoadTopVoterWeekly();
return "" + plugin.getConfigFile().isLoadTopVoterWeekly();
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Daily", new Callable<String>() {
@Override
public String call() throws Exception {
return "" + plugin.getConfigFile().getLoadTopVoterDaily();
return "" + plugin.getConfigFile().isLoadTopVoterDaily();
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeemethod", new Callable<String>() {
@@ -317,11 +324,11 @@ public class VotingPluginMetrics {
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("geyserprefixsupport", new Callable<String>() {
metrics.addCustomChart(new BStatsMetrics.SimplePie("bedrockplayerprefix", new Callable<String>() {
@Override
public String call() throws Exception {
return "" + plugin.getOptions().isGeyserPrefixSupport();
return "" + plugin.getOptions().getBedrockPlayerPrefix();
}
}));
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.bungee;
import java.util.regex.Pattern;
import lombok.Getter;
import lombok.Setter;
public class BungeeMessageData {
@@ -10,20 +11,28 @@ public class BungeeMessageData {
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired
@Getter
@Setter
private int allTimeTotal = 0;
@Getter
@Setter
private int dailyTotal = 0;
@Getter
@Setter
private int milestoneCount = 0;
@Getter
@Setter
private int monthTotal = 0;
@Getter
@Setter
private int points = 0;
@Getter
@Setter
private int weeklyTotal = 0;
@Getter
@Setter
private int votePartyCurrent = 0;
@Getter
@Setter
private int votePartyRequired = 0;
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
@@ -1,7 +1,7 @@
package com.bencodez.votingplugin.bungee;
public enum BungeeMethod {
MYSQL, PLUGINMESSAGING, SOCKETS;
MYSQL, PLUGINMESSAGING, SOCKETS, REDIS;
public static BungeeMethod getByName(String str) {
for (BungeeMethod method : values()) {
@@ -9,6 +9,6 @@ public enum BungeeMethod {
return method;
}
}
return SOCKETS;
return PLUGINMESSAGING;
}
}
@@ -21,6 +21,26 @@ public class Config {
this.bungee = bungee;
}
public String getRedisHost() {
return getData().getString("Redis.Host", "");
}
public int getRedisPort() {
return getData().getInt("Redis.Port", 6379);
}
public String getRedisUsername() {
return getData().getString("Redis.Username", "");
}
public String getRedisPrefix() {
return getData().getString("Redis.Prefix", "");
}
public String getRedisPassword() {
return getData().getString("Redis.Password", "");
}
public boolean getAllowUnJoined() {
return getData().getBoolean("AllowUnJoined", false);
}
@@ -37,12 +57,8 @@ public class Config {
return getData().getBoolean("Broadcast", false);
}
public boolean getGeyserSupport() {
return getData().getBoolean("GeyserSupport", false);
}
public String getGeyserPrefix() {
return getData().getString("GeyserPrefix", ".");
public String getBedrockPlayerPrefix() {
return getData().getString("BedrockPlayerPrefix", ".");
}
public boolean getOnlineMode() {
@@ -81,6 +97,10 @@ public class Config {
return getData().getBoolean("MultiProxySupport", false);
}
public int getMaxAmountOfVotesPerDay() {
return getData().getInt("MaxAmountOfVotesPerDay", -1);
}
public int getMultiProxySocketHostPort() {
return getData().getInt("MultiProxySocketHost.Port", 1297);
}
@@ -145,10 +165,30 @@ public class Config {
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
}
public int getVoteCacheTime() {
return getData().getInt("VoteCacheTime", -1);
}
public String getVotePartyBroadcast() {
return getData().getString("VoteParty.Broadcast", "");
}
public String getMultiProxyMethod() {
return getData().getString("MultiProxyMethod", "SOCKET");
}
public String getProxyServerName() {
return getData().getString("ProxyServerName", "SOCKET");
}
public List<String> getProxyServers() {
return getData().getStringList("ProxyServers");
}
public boolean getMultiProxyRedisUseExistingConnection() {
return getData().getBoolean("MultiProxyRedis.UseExistingConnection", false);
}
public List<String> getVotePartyServersToSend() {
return getData().getStringList("VoteParty.ServersToSend");
}
@@ -157,6 +197,22 @@ public class Config {
return getData().getStringList("VoteParty.BungeeCommands");
}
public String getMultiProxyRedisHost() {
return getData().getString("MultiProxyRedis.Host", "");
}
public int getMultiProxyRedisPort() {
return getData().getInt("MultiProxyRedis.Port", 6379);
}
public String getMultiProxyRedisUsername() {
return getData().getString("MultiProxyRedis.Username", "");
}
public String getMultiProxyRedisPassword() {
return getData().getString("MultiProxyRedis.Password", "");
}
public void load() {
if (!bungee.getDataFolder().exists()) {
bungee.getDataFolder().mkdir();
@@ -25,9 +25,16 @@ public class NonVotedPlayersCache {
}
}
private void addPlayer(String uuid, String playerName) {
public void addPlayer(String uuid, String playerName) {
getData().set("NonVotedPlayers." + playerName + ".UUID", uuid);
getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
save();
}
public void addPlayerCheck(String uuid, String playerName) {
if (!bungee.getMysql().containsKeyQuery(uuid)) {
addPlayer(uuid, playerName);
}
}
public void check() {
@@ -18,6 +18,7 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -44,10 +45,16 @@ import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConf
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
import com.bencodez.advancedcore.bungeeapi.mysql.BungeeMySQL;
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
import com.bencodez.advancedcore.bungeeapi.time.BungeeTimeChecker;
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyHandler;
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyMethod;
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfiguration;
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfigurationBungee;
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.google.gson.JsonElement;
@@ -71,16 +78,12 @@ import net.md_5.bungee.event.EventHandler;
public class VotingPluginBungee extends Plugin implements Listener {
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>>();
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedVotes = new ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>>();
private HashMap<String, ClientHandler> clientHandles;
private HashMap<String, ClientHandler> multiproxyClientHandles;
private SocketHandler multiproxySocketHandler;
@Getter
private Config config;
@@ -110,6 +113,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Getter
private GlobalDataHandlerProxy globalDataHandler;
@Getter
private RedisHandler redisHandler;
public synchronized void checkCachedVotes(String server) {
if (getProxy().getServerInfo(server) != null) {
if (!getProxy().getServerInfo(server).getPlayers().isEmpty()) {
@@ -132,7 +138,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
if (toSend) {
sendPluginMessageServer(server, "Vote", cache.getPlayerName(), cache.getUuid(),
sendMessageServer(server, "Vote", cache.getPlayerName(), cache.getUuid(),
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
"" + cache.isRealVote(), cache.getText(),
"" + getConfig().getBungeeManageTotals(),
@@ -164,7 +170,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
int num = 1;
int numberOfVotes = c.size();
for (OfflineBungeeVote cache : c) {
sendPluginMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
sendMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num,
@@ -173,13 +179,34 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
sendMultiProxyServerMessage("ClearVote", player.getName(), uuid);
multiProxyHandler.sendMultiProxyServerMessage("ClearVote", player.getName(), uuid);
}
}
}
}
}
public void checkVoteCacheTime() {
long cTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedOnlineVotes.entrySet()) {
ArrayList<OfflineBungeeVote> votes = entry.getValue();
for (int i = votes.size() - 1; i >= 0; i--) {
if (cTime - votes.get(i).getTime() > getConfig().getVoteCacheTime() * 24 * 60 * 60 * 1000) {
votes.remove(i);
}
}
}
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
ArrayList<OfflineBungeeVote> votes = entry.getValue();
for (int i = votes.size() - 1; i >= 0; i--) {
if (cTime - votes.get(i).getTime() > getConfig().getVoteCacheTime() * 24 * 60 * 60 * 1000) {
votes.remove(i);
}
}
}
}
public void debug(String msg) {
if (config.getDebug()) {
getLogger().info("Debug: " + msg);
@@ -531,6 +558,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
private VoteEventBungee voteEventBungee;
@Getter
private MultiProxyHandler multiProxyHandler;
@Override
public void onEnable() {
enabled = true;
@@ -582,6 +612,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Override
public void timeChanged(TimeType type, boolean fake, boolean pre, boolean post) {
if (getConfig().getVoteCacheTime() > 0) {
checkVoteCacheTime();
}
if (!config.getGlobalDataEnabled()) {
return;
}
@@ -774,6 +807,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
debug("Checking nonvotedplayers.yml...");
nonVotedPlayersCache.check();
}
if (voteCacheFile != null) {
voteCacheFile.save();
}
}
}, 1l, 60l, TimeUnit.MINUTES);
} else if (method.equals(BungeeMethod.SOCKETS)) {
@@ -826,13 +862,54 @@ public class VotingPluginBungee extends Plugin implements Listener {
encryptionHandler, config.getDebug()));
}
}
} else if (method.equals(BungeeMethod.REDIS)) {
redisHandler = new RedisHandler(config.getRedisHost(), config.getRedisPort(), config.getRedisUsername(),
config.getRedisPassword()) {
@Override
protected void onMessage(String channel, String[] message) {
if (message.length > 0) {
if (message[0].equalsIgnoreCase("statusokay")) {
String server = message[1];
getLogger().info("Status okay for " + server);
} else if (message[0].equalsIgnoreCase("login")) {
String player = message[1];
String uuid = message[2];
String server = "";
if (message.length > 3) {
server = message[3];
}
debug("Login: " + player + "/" + uuid + " " + server);
if (nonVotedPlayersCache != null) {
nonVotedPlayersCache.addPlayerCheck(uuid, player);
}
ProxiedPlayer p = getProxy().getPlayer(player);
login(p);
}
}
}
@Override
public void debug(String message) {
debug2(message);
}
};
getProxy().getScheduler().runAsync(this, new Runnable() {
@Override
public void run() {
redisHandler.loadListener(
new RedisListener(redisHandler, getConfig().getRedisPrefix() + "VotingPlugin"));
}
});
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
+ voteCacheFile.getVotePartyInreaseVotesRequired();
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
}
loadMultiProxySupport();
loadMultiProxySupport();
}
if (!votifierEnabled) {
if (!(getConfig().getMultiProxySupport() && !getConfig().getPrimaryServer())) {
@@ -881,63 +958,156 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (!buildNumber.equals("NOTSET")) {
getLogger().info("Detected using dev build number: " + buildNumber);
}
sendServerNameMessage();
}
public void loadMultiProxySupport() {
if (getConfig().getMultiProxySupport()) {
if (encryptionHandler == null) {
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
}
private void runAsyncNow(Runnable runnable) {
getProxy().getScheduler().runAsync(this, runnable);
}
if (multiproxySocketHandler != null) {
multiproxySocketHandler.closeConnection();
multiproxySocketHandler = null;
}
multiproxySocketHandler = new SocketHandler(getDescription().getVersion(),
config.getMultiProxySocketHostHost(), config.getMultiProxySocketHostPort(), encryptionHandler,
config.getDebug()) {
@Override
public void log(String str) {
getLogger().info(str);
}
};
multiproxySocketHandler.add(new SocketReceiver() {
@Override
public void onReceive(String[] data) {
if (data.length > 0) {
if (data[0].equalsIgnoreCase("Status")) {
getLogger().info("Multi-proxy status message received");
} else if (data[0].equalsIgnoreCase("ClearVote")) {
cachedOnlineVotes.remove(data[2]);
}
}
if (data.length > 8) {
if (data[0].equalsIgnoreCase("Vote")) {
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
data[1]);
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
data[1]);
}
}
}
});
multiproxyClientHandles = new HashMap<String, ClientHandler>();
for (
String s : config.getMultiProxyServers()) {
Configuration d = config.getMultiProxyServersConfiguration(s);
multiproxyClientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1234),
encryptionHandler, config.getDebug()));
}
getLogger().info("Loaded multi-proxy support");
private void loadMultiProxySupport() {
if (multiProxyHandler != null) {
multiProxyHandler.close();
}
multiProxyHandler = new MultiProxyHandler() {
@Override
public void triggerVote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
BungeeMessageData text, String uuid) {
vote(player, service, realVote, timeQueue, queueTime, text, uuid);
}
@Override
public void setEncryptionHandler(EncryptionHandler encryptionHandler1) {
encryptionHandler = encryptionHandler1;
}
@Override
public void logInfo(String msg) {
getLogger().info(msg);
}
@Override
public String getVersion() {
return getDescription().getVersion();
}
@Override
public boolean getMultiProxySupportEnabled() {
return config.getMultiProxySupport();
}
@Override
public int getMultiProxySocketHostPort() {
return config.getMultiProxySocketHostPort();
}
@Override
public String getMultiProxySocketHostHost() {
return config.getMultiProxySocketHostHost();
}
@Override
public MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s) {
return new MultiProxyServerSocketConfigurationBungee(s, config.getMultiProxyServersConfiguration(s));
}
@Override
public Collection<String> getMultiProxyServers() {
return config.getMultiProxyServers();
}
@Override
public EncryptionHandler getEncryptionHandler() {
return encryptionHandler;
}
@Override
public boolean getDebug() {
return config.getDebug();
}
@Override
public File getPluginDataFolder() {
return getDataFolder();
}
@Override
public void clearVote(String string) {
cachedOnlineVotes.remove(string);
}
@Override
public void addNonVotedPlayerCache(String uuid, String player) {
nonVotedPlayersCache.addPlayer(uuid, player);
}
@Override
public boolean getPrimaryServer() {
return config.getPrimaryServer();
}
@Override
public List<String> getProxyServers() {
return config.getProxyServers();
}
@Override
public void runAsnc(Runnable runnable) {
runAsyncNow(runnable);
}
@Override
public MultiProxyMethod getMultiProxyMethod() {
return MultiProxyMethod.getByName(config.getMultiProxyMethod());
}
@Override
public RedisHandler getRedisHandler() {
return redisHandler;
}
@Override
public boolean getMultiProxyRedisUseExistingConnection() {
return config.getMultiProxyRedisUseExistingConnection();
}
@Override
public String getMultiProxyPassword() {
return config.getMultiProxyRedisPassword();
}
@Override
public String getMultiProxyUsername() {
return config.getMultiProxyRedisUsername();
}
@Override
public int getMultiProxyRedisPort() {
return config.getMultiProxyRedisPort();
}
@Override
public String getMultiProxyRedisHost() {
return config.getMultiProxyRedisHost();
}
@Override
public String getMultiProxyServerName() {
return config.getProxyServerName();
}
};
multiProxyHandler.loadMultiProxySupport();
}
public void sendServerNameMessage() {
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
for (String s : getAvailableAllServers()) {
sendPluginMessageServer(s, "ServerName", s);
}
}
}
@EventHandler
@@ -965,14 +1135,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
public void login(ProxiedPlayer p) {
if (p != null && p.getServer() != null && p.getServer().getInfo() != null) {
final String server = p.getServer().getInfo().getName();
final ProxiedPlayer proixedPlayer = p;
final ProxiedPlayer proxiedPlayer = p;
getProxy().getScheduler().schedule(this, new Runnable() {
@Override
public void run() {
if (isOnline(p)) {
checkCachedVotes(server);
checkOnlineVotes(proixedPlayer, proixedPlayer.getUniqueId().toString(), server);
checkOnlineVotes(proxiedPlayer, proxiedPlayer.getUniqueId().toString(), server);
multiProxyHandler.login(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
}
}
}, 1, TimeUnit.SECONDS);
@@ -1073,6 +1244,22 @@ public class VotingPluginBungee extends Plugin implements Listener {
loadMultiProxySupport();
}
public void sendMessageServer(String server, String channel, String... messageData) {
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
sendPluginMessageServer(server, channel, messageData);
} else if (method.equals(BungeeMethod.REDIS)) {
sendRedisMessageServer(server, channel, messageData);
}
}
public void sendRedisMessageServer(String server, String channel, String... messageData) {
ArrayList<String> list = new ArrayList<String>();
list.add(channel);
list.addAll(ArrayUtils.getInstance().convert(messageData));
redisHandler.sendMessage(getConfig().getRedisPrefix() + "VotingPlugin_" + server,
ArrayUtils.getInstance().convert(list));
}
public void sendPluginMessageServer(String server, String channel, String... messageData) {
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteOutStream);
@@ -1100,12 +1287,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
public void sendMultiProxyServerMessage(String... messageData) {
for (ClientHandler h : multiproxyClientHandles.values()) {
h.sendMessage(messageData);
}
}
public void sendServerMessageServer(String server, String... messageData) {
if (clientHandles.containsKey(server)) {
clientHandles.get(server).sendMessage(messageData);
@@ -1148,7 +1329,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
public void status(CommandSender sender) {
if (method.equals(BungeeMethod.SOCKETS)) {
sendServerMessage("status");
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
} else if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
for (String s : getAvailableAllServers()) {
ServerInfo info = getProxy().getServerInfo(s);
if (info.getPlayers().isEmpty()) {
@@ -1156,7 +1337,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
} else {
// send
getLogger().info("Sending request for status message on " + s);
sendPluginMessageServer(s, "Status", s);
sendMessageServer(s, "Status", s);
}
}
}
@@ -1187,15 +1368,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
if (uuid.isEmpty()) {
if (config.getGeyserSupport()) {
if (!player.startsWith(config.getGeyserPrefix())) {
uuid = getUUID(config.getGeyserPrefix() + player);
player = config.getGeyserPrefix() + player;
}
if (player.startsWith(config.getBedrockPlayerPrefix())) {
getLogger().info("Ignoring vote since unable to get UUID of bedrock player");
return;
}
}
if (uuid.isEmpty()) {
if (config.getAllowUnJoined()) {
debug("Fetching UUID online, since allowunjoined is enabled");
UUID u = null;
@@ -1221,8 +1397,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
player = getProperName(uuid, player);
addVoteParty();
if (getConfig().getPrimaryServer() || !getConfig().getMultiProxySupport()) {
addVoteParty();
if (getConfig().getBungeeManageTotals()) {
if (mysql == null) {
@@ -1243,6 +1419,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
int milestoneCount = getValue(data, "MilestoneCount", 1);
int maxVotes = getConfig().getMaxAmountOfVotesPerDay();
if (maxVotes > 0) {
LocalDateTime cTime = getBungeeTimeChecker().getTime();
int days = cTime.getDayOfMonth();
if (monthTotal > days * maxVotes) {
monthTotal = days * maxVotes;
}
}
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
ArrayList<Column> update = new ArrayList<Column>();
@@ -1265,7 +1450,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
if (config.getSendVotesToAllServers()) {
for (String s : getAvailableAllServers()) {
@@ -1276,7 +1461,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
debug("Forcing vote to cache");
}
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
sendMessageServer(s, "VoteBroadcast", uuid, player, service);
}
if (info.getPlayers().isEmpty() || forceCache) {
// cache
@@ -1291,21 +1476,20 @@ public class VotingPluginBungee extends Plugin implements Listener {
} else {
// send
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
Boolean.TRUE.toString(), "" + realVote, text.toString(),
"" + getConfig().getBungeeManageTotals(),
sendMessageServer(s, "Vote", player, uuid, service, "" + time, Boolean.TRUE.toString(),
"" + realVote, text.toString(), "" + getConfig().getBungeeManageTotals(),
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "1", "1");
}
}
} else {
if (isOnline(p) && !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
if (isOnline(p) && getAvailableAllServers().contains(p.getServer().getInfo().getName())) {
sendMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
"" + config.getBroadcast(), "1", "1");
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
sendMultiProxyServerMessage("ClearVote", player, uuid);
multiProxyHandler.sendMultiProxyServerMessage("ClearVote", player, uuid);
}
} else {
if (!cachedOnlineVotes.containsKey(uuid)) {
@@ -1321,10 +1505,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
for (String s : getAvailableAllServers()) {
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
sendMessageServer(s, "VoteBroadcast", uuid, player, service);
}
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
"" + currentVotePartyVotesRequired);
sendMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
"" + currentVotePartyVotesRequired, text.toString());
}
}
@@ -1334,14 +1518,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (getConfig().getMultiProxySupport() && getConfig().getPrimaryServer()) {
if (!getConfig().getMultiProxyOneGlobalReward()) {
debug("Seending global proxy vote message");
sendMultiProxyServerMessage("Vote", uuid, player, service, "" + votePartyVotes,
multiProxyHandler.sendMultiProxyServerMessage("Vote", uuid, player, service, "" + votePartyVotes,
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
} else {
// check if reward should've already been given
if (!(isOnline(p) && !config.getBlockedServers().contains(p.getServer().getInfo().getName()))) {
debug("Sending global proxy voteonline message");
sendMultiProxyServerMessage("VoteOnline", uuid, player, service, "" + votePartyVotes,
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
multiProxyHandler.sendMultiProxyServerMessage("VoteOnline", uuid, player, service,
"" + votePartyVotes, "" + currentVotePartyVotesRequired, "" + time, "" + realVote,
text.toString());
} else {
debug("Not sending global proxy message for voteonline, player already got reward");
}
@@ -49,14 +49,20 @@ public class VotingPluginBungeeCommand extends Command {
sender.sendMessage(new TextComponent(
"&aChecking status, waiting for response, check console, method: plugin messaging"));
bungee.status(sender);
bungee.sendServerNameMessage();
} else if (bungee.getMethod().equals(BungeeMethod.REDIS)) {
sender.sendMessage(new TextComponent(
"&aChecking status, waiting for response, check console, method: redis"));
bungee.status(sender);
bungee.sendServerNameMessage();
} else {
sender.sendMessage(
new TextComponent("&aNot using socket/pluginmessage method, command unavailable"));
new TextComponent("&aNot using socket/pluginmessage/redis method, command unavailable"));
}
}
if (args[0].equalsIgnoreCase("multiproxystatus")) {
bungee.sendMultiProxyServerMessage("Status");
sender.sendMessage(new TextComponent("&aSending status message"));
bungee.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
sender.sendMessage(new TextComponent("Sending status message"));
}
if (args[0].equalsIgnoreCase("help")) {
TextComponent[] msg = new TextComponent[7];
@@ -0,0 +1,229 @@
package com.bencodez.votingplugin.bungee.global.multiproxy;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import lombok.Getter;
public abstract class MultiProxyHandler {
public abstract boolean getMultiProxySupportEnabled();
public abstract EncryptionHandler getEncryptionHandler();
public abstract File getPluginDataFolder();
public abstract void setEncryptionHandler(EncryptionHandler encryptionHandler);
public abstract void logInfo(String msg);
public abstract boolean getDebug();
public abstract String getVersion();
private HashMap<String, ClientHandler> multiproxyClientHandles;
private SocketHandler multiproxySocketHandler;
@Getter
private RedisHandler multiProxyRedis;
public MultiProxyHandler() {
}
public void sendMultiProxyServerMessage(String... messageData) {
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
for (ClientHandler h : multiproxyClientHandles.values()) {
h.sendMessage(messageData);
}
} else if (getMultiProxyMethod().equals(MultiProxyMethod.REDIS)) {
for (String server : getProxyServers()) {
multiProxyRedis.sendMessage("VotingPluginProxy_" + server, messageData);
}
}
}
public abstract List<String> getProxyServers();
public void close() {
if (multiproxySocketHandler != null) {
multiproxySocketHandler.closeConnection();
multiproxySocketHandler = null;
}
if (multiProxyRedis != null && !getMultiProxyRedisUseExistingConnection()) {
multiProxyRedis.close();
}
}
public void loadMultiProxySupport() {
if (getMultiProxySupportEnabled()) {
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
if (getEncryptionHandler() == null) {
setEncryptionHandler(new EncryptionHandler(new File(getPluginDataFolder(), "secretkey.key")));
}
if (multiproxySocketHandler != null) {
multiproxySocketHandler.closeConnection();
multiproxySocketHandler = null;
}
multiproxySocketHandler = new SocketHandler(getVersion(), getMultiProxySocketHostHost(),
getMultiProxySocketHostPort(), getEncryptionHandler(), getDebug()) {
@Override
public void log(String str) {
logInfo(str);
}
};
multiproxySocketHandler.add(new SocketReceiver() {
@Override
public void onReceive(String[] data) {
if (data.length > 0) {
if (data[0].equalsIgnoreCase("Status")) {
logInfo("Multi-proxy status message received");
} else if (data[0].equalsIgnoreCase("ClearVote")) {
clearVote(data[2]);
if (getPrimaryServer()) {
sendMultiProxyServerMessage("ClearVotePrimary", data[1], data[2]);
}
} else if (data[0].equalsIgnoreCase("ClearVotePrimary")) {
clearVote(data[2]);
} else if (data[0].equalsIgnoreCase("login")) {
addNonVotedPlayerCache(data[1], data[2]);
// nonVotedPlayersCache.addPlayer(data[1], data[2]);
}
}
if (data.length > 8) {
if (data[0].equalsIgnoreCase("Vote")) {
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
new BungeeMessageData(data[8]), data[1]);
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
new BungeeMessageData(data[8]), data[1]);
}
}
}
});
multiproxyClientHandles = new HashMap<String, ClientHandler>();
for (String s : getMultiProxyServers()) {
MultiProxyServerSocketConfiguration d = getMultiProxyServersConfiguration(s);
multiproxyClientHandles.put(s,
new ClientHandler(d.getHost(), d.getPort(), getEncryptionHandler(), getDebug()));
}
} else {
if (getMultiProxyRedisUseExistingConnection() && getRedisHandler() != null) {
multiProxyRedis = getRedisHandler();
} else {
multiProxyRedis = new RedisHandler(getMultiProxyRedisHost(), getMultiProxyRedisPort(),
getMultiProxyUsername(), getMultiProxyPassword()) {
@Override
public void onMessage(String channel, String[] data) {
if (data.length > 0) {
if (data[0].equalsIgnoreCase("Status")) {
logInfo("Multi-proxy status message received");
} else if (data[0].equalsIgnoreCase("ClearVote")) {
clearVote(data[2]);
if (getPrimaryServer()) {
sendMultiProxyServerMessage("ClearVotePrimary", data[1], data[2]);
}
} else if (data[0].equalsIgnoreCase("ClearVotePrimary")) {
clearVote(data[2]);
} else if (data[0].equalsIgnoreCase("login")) {
addNonVotedPlayerCache(data[1], data[2]);
// nonVotedPlayersCache.addPlayer(data[1], data[2]);
}
}
if (data.length > 8) {
if (data[0].equalsIgnoreCase("Vote")) {
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
new BungeeMessageData(data[8]), data[1]);
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
new BungeeMessageData(data[8]), data[1]);
}
}
}
@Override
public void debug(String message) {
if (getDebug()) {
logInfo("MultiProxyRedis: " + message);
}
}
};
}
runAsnc(new Runnable() {
@Override
public void run() {
multiProxyRedis.loadListener(
new RedisListener(multiProxyRedis, "VotingPluginProxy_" + getMultiProxyServerName()));
}
});
}
logInfo("Loaded multi-proxy support: " + getMultiProxyMethod().toString());
}
}
public abstract void runAsnc(Runnable runnable);
public abstract MultiProxyMethod getMultiProxyMethod();
public abstract RedisHandler getRedisHandler();
public abstract boolean getMultiProxyRedisUseExistingConnection();
public abstract String getMultiProxyPassword();
public abstract String getMultiProxyUsername();
public abstract String getMultiProxyServerName();
public abstract int getMultiProxyRedisPort();
public abstract String getMultiProxyRedisHost();
public abstract boolean getPrimaryServer();
public void login(String uuid, String playerName) {
if (!getMultiProxySupportEnabled()) {
return;
}
if (getPrimaryServer()) {
return;
}
sendMultiProxyServerMessage("Login", uuid, playerName);
}
public abstract int getMultiProxySocketHostPort();
public abstract String getMultiProxySocketHostHost();
public abstract MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s);
public abstract Collection<String> getMultiProxyServers();
public abstract void triggerVote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
BungeeMessageData text, String uuid);
public abstract void addNonVotedPlayerCache(String string, String string2);
public abstract void clearVote(String string);
}
@@ -0,0 +1,14 @@
package com.bencodez.votingplugin.bungee.global.multiproxy;
public enum MultiProxyMethod {
SOCKETS, REDIS;
public static MultiProxyMethod getByName(String str) {
for (MultiProxyMethod method : values()) {
if (method.toString().equalsIgnoreCase(str)) {
return method;
}
}
return MultiProxyMethod.SOCKETS;
}
}
@@ -0,0 +1,9 @@
package com.bencodez.votingplugin.bungee.global.multiproxy;
public interface MultiProxyServerSocketConfiguration {
String getServerName();
String getHost();
int getPort();
}
@@ -0,0 +1,31 @@
package com.bencodez.votingplugin.bungee.global.multiproxy;
import net.md_5.bungee.config.Configuration;
public class MultiProxyServerSocketConfigurationBungee implements MultiProxyServerSocketConfiguration {
private String server;
private String host;
private int port;
public MultiProxyServerSocketConfigurationBungee(String s, Configuration config) {
server = s;
host = config.getString("Host", "");
port = config.getInt("Port", 1234);
}
@Override
public String getServerName() {
return server;
}
@Override
public String getHost() {
return host;
}
@Override
public int getPort() {
return port;
}
}
@@ -0,0 +1,33 @@
package com.bencodez.votingplugin.bungee.global.multiproxy;
import ninja.leaping.configurate.ConfigurationNode;
public class MultiProxyServerSocketConfigurationVelocity implements MultiProxyServerSocketConfiguration {
private String server;
private String host;
private int port;
public MultiProxyServerSocketConfigurationVelocity(String s, ConfigurationNode config) {
server = s;
host = config.getNode("Host").getString("0.0.0.0");
port = config.getNode("Port").getInt(1298);
}
@Override
public String getServerName() {
return server;
}
@Override
public String getHost() {
return host;
}
@Override
public int getPort() {
return port;
}
}
@@ -53,6 +53,26 @@ public class Config extends VelocityYMLFile {
return getString(getNode("BungeeMethod"), "PLUGINMESSAGING");
}
public String getRedisHost() {
return getString(getNode("Redis", "Host"), "");
}
public int getRedisPort() {
return getInt(getNode("Redis", "Port"), 6379);
}
public String getRedisUsername() {
return getString(getNode("Redis", "Username"), "");
}
public String getRedisPrefix() {
return getString(getNode("Redis", "Prefix"), "");
}
public String getRedisPassword() {
return getString(getNode("Redis", "Password"), "");
}
public String getBungeeHost() {
return getString(getNode("BungeeServer", "Host"), "");
}
@@ -61,6 +81,14 @@ public class Config extends VelocityYMLFile {
return getInt(getNode("BungeeServer", "Port"), 1297);
}
public int getMaxAmountOfVotesPerDay() {
return getInt(getNode("MaxAmountOfVotesPerDay"), -1);
}
public int getVoteCacheTime() {
return getInt(getNode("VoteCacheTime"), -1);
}
public boolean getDebug() {
return getBoolean(getNode("Debug"), false);
}
@@ -133,16 +161,12 @@ public class Config extends VelocityYMLFile {
return getBoolean(getNode("MultiProxyOneGlobalReward"), false);
}
public boolean getGeyserSupport() {
return getBoolean(getNode("GeyserSupport"), false);
}
public boolean getPrimaryServer() {
return getBoolean(getNode("PrimaryServer"), false);
}
public String getGeyserPrefix() {
return getString(getNode("GeyserPrefix"), "*");
public String getBedrockPlayerPrefix() {
return getString(getNode("BedrockPlayerPrefix"), ".");
}
public ConfigurationNode getMultiProxyServers(String s) {
@@ -161,4 +185,36 @@ public class Config extends VelocityYMLFile {
return getInt(getNode("MultiProxySocketHost", "Port"), 1297);
}
public String getMultiProxyMethod() {
return getString(getNode("MultiProxyMethod"), "SOCKET");
}
public String getProxyServerName() {
return getString(getNode("ProxyServerName"), "SOCKET");
}
public List<String> getProxyServers() {
return getStringList(getNode("ProxyServers"), new ArrayList<String>());
}
public boolean getMultiProxyRedisUseExistingConnection() {
return getBoolean(getNode("MultiProxyRedis", "UseExistingConnection"), false);
}
public String getMultiProxyRedisHost() {
return getString(getNode("MultiProxyRedis", "Host"), "");
}
public int getMultiProxyRedisPort() {
return getInt(getNode("MultiProxyRedis", "Port"), 6379);
}
public String getMultiProxyRedisUsername() {
return getString(getNode("MultiProxyRedis", "Username"), "");
}
public String getMultiProxyRedisPassword() {
return getString(getNode("MultiProxyRedis", "Password"), "");
}
}
@@ -20,12 +20,18 @@ public class NonVotedPlayersCache extends VelocityJSONFile {
}
}
private void addPlayer(String uuid, String playerName) {
public void addPlayer(String uuid, String playerName) {
getNode("NonVotedPlayers", playerName, "UUID").setValue(uuid);
getNode("NonVotedPlayers", playerName, "LastTime").setValue(System.currentTimeMillis());
save();
}
public void addPlayerCheck(String uuid, String playerName) {
if (!plugin.getMysql().containsKeyQuery(uuid)) {
addPlayer(uuid, playerName);
}
}
public void check() {
for (String player : getKeys(getNode("NonVotedPlayers"))) {
long time = getNode("NonVotedPlayers", player, "LastTime").getLong(0);
@@ -55,6 +55,8 @@ import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConf
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
import com.bencodez.advancedcore.bungeeapi.mysql.VelocityMySQL;
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
@@ -64,6 +66,10 @@ import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.bungee.BungeeVersion;
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyHandler;
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyMethod;
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfiguration;
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfigurationVelocity;
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.google.gson.JsonElement;
@@ -93,8 +99,8 @@ import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
public class VotingPluginVelocity {
private static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.create("vp", "vp");
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
private HashMap<RegisteredServer, ArrayList<OfflineBungeeVote>> cachedVotes = new HashMap<RegisteredServer, ArrayList<OfflineBungeeVote>>();
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>>();
private ConcurrentHashMap<RegisteredServer, ArrayList<OfflineBungeeVote>> cachedVotes = new ConcurrentHashMap<RegisteredServer, ArrayList<OfflineBungeeVote>>();
private HashMap<String, ClientHandler> clientHandles;
@@ -134,9 +140,8 @@ public class VotingPluginVelocity {
@Getter
private GlobalDataHandlerProxy globalDataHandler;
private HashMap<String, ClientHandler> multiproxyClientHandles;
private SocketHandler multiproxySocketHandler;
@Getter
private RedisHandler redisHandler;
@Inject
public VotingPluginVelocity(ProxyServer server, Logger logger, Metrics.Factory metricsFactory,
@@ -174,7 +179,7 @@ public class VotingPluginVelocity {
}
if (toSend) {
sendPluginMessageServer(serverToCheck, "Vote", cache.getPlayerName(), cache.getUuid(),
sendMessageServer(serverToCheck, "Vote", cache.getPlayerName(), cache.getUuid(),
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num,
@@ -204,7 +209,7 @@ public class VotingPluginVelocity {
int num = 1;
int numberOfVotes = c.size();
for (OfflineBungeeVote cache : c) {
sendPluginMessageServer(serverToCheck, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
sendMessageServer(serverToCheck, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num,
@@ -213,7 +218,7 @@ public class VotingPluginVelocity {
}
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
sendMultiProxyServerMessage("ClearVote", player.getUsername(), uuid);
getMultiProxyHandler().sendMultiProxyServerMessage("ClearVote", player.getUsername(), uuid);
}
}
}
@@ -507,6 +512,7 @@ public class VotingPluginVelocity {
public void run() {
checkCachedVotes(server);
checkOnlineVotes(p1, p.getUniqueId().toString(), server);
getMultiProxyHandler().login(p1.getUniqueId().toString(), p1.getUsername());
}
});
@@ -533,6 +539,27 @@ public class VotingPluginVelocity {
}
}
public void checkVoteCacheTime() {
long cTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedOnlineVotes.entrySet()) {
ArrayList<OfflineBungeeVote> votes = entry.getValue();
for (int i = votes.size() - 1; i >= 0; i--) {
if (cTime - votes.get(i).getTime() > getConfig().getVoteCacheTime() * 24 * 60 * 60 * 1000) {
votes.remove(i);
}
}
}
for (Entry<RegisteredServer, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
ArrayList<OfflineBungeeVote> votes = entry.getValue();
for (int i = votes.size() - 1; i >= 0; i--) {
if (cTime - votes.get(i).getTime() > getConfig().getVoteCacheTime() * 24 * 60 * 60 * 1000) {
votes.remove(i);
}
}
}
}
@Subscribe
public void onProxyDisable(ProxyShutdownEvent event) {
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
@@ -622,6 +649,9 @@ public class VotingPluginVelocity {
@Override
public void timeChanged(TimeType type, boolean fake, boolean pre, boolean post) {
if (getConfig().getVoteCacheTime() > 0) {
checkVoteCacheTime();
}
if (!config.getGlobalDataEnabled()) {
return;
}
@@ -852,6 +882,9 @@ public class VotingPluginVelocity {
debug("Checking nonvotedplayerscache.yml...");
nonVotedPlayersCache.check();
}
if (voteCacheFile != null) {
voteCacheFile.save();
}
}).delay(1L, TimeUnit.MINUTES).repeat(60l, TimeUnit.MINUTES).schedule();
} else if (method.equals(BungeeMethod.SOCKETS)) {
encryptionHandler = new EncryptionHandler(new File(dataDirectory.toFile(), "secretkey.key"));
@@ -904,6 +937,62 @@ public class VotingPluginVelocity {
d.getNode("Port").getInt(1298), encryptionHandler, config.getDebug()));
}
}
} else if (method.equals(BungeeMethod.REDIS)) {
redisHandler = new RedisHandler(config.getRedisHost(), config.getRedisPort(), config.getRedisUsername(),
config.getRedisPassword()) {
@Override
protected void onMessage(String channel, String[] message) {
if (message.length > 0) {
if (message[0].equalsIgnoreCase("statusokay")) {
String server = message[1];
getLogger().info("Status okay for " + server);
} else if (message[0].equalsIgnoreCase("login")) {
String player = message[1];
String uuid = message[2];
String serverName = "";
if (message.length > 3) {
serverName = message[3];
}
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();
if (p.getCurrentServer().isPresent()) {
final RegisteredServer server = p.getCurrentServer().get().getServer();
final Player p1 = p;
timer.execute(new Runnable() {
@Override
public void run() {
checkCachedVotes(server);
checkOnlineVotes(p1, p.getUniqueId().toString(), server);
getMultiProxyHandler().login(p1.getUniqueId().toString(),
p1.getUsername());
}
});
}
}
return;
}
}
}
@Override
public void debug(String message) {
debug2(message);
}
};
server.getScheduler().buildTask(this, () -> {
redisHandler.loadListener(
new RedisListener(redisHandler, getConfig().getRedisPrefix() + "VotingPlugin"));
}).schedule();
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
@@ -963,64 +1052,162 @@ public class VotingPluginVelocity {
if (!buildNumber.equals("NOTSET")) {
logger.info("Detected using dev build number: " + buildNumber);
}
sendServerNameMessage();
}
public void loadMultiProxySupport() {
if (getConfig().getMultiProxySupport()) {
if (encryptionHandler == null) {
encryptionHandler = new EncryptionHandler(new File(dataDirectory.toFile(), "secretkey.key"));
}
if (multiproxySocketHandler != null) {
multiproxySocketHandler.closeConnection();
multiproxySocketHandler = null;
}
multiproxySocketHandler = new SocketHandler(
server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(),
config.getMultiProxySocketHostHost(), config.getMultiProxySocketHostPort(), encryptionHandler,
config.getDebug()) {
@Override
public void log(String str) {
getLogger().info(str);
}
};
multiproxySocketHandler.add(new SocketReceiver() {
@Override
public void onReceive(String[] data) {
if (data.length > 0) {
if (data[0].equalsIgnoreCase("Status")) {
getLogger().info("Multi-proxy status message received");
} else if (data[0].equalsIgnoreCase("ClearVote")) {
cachedOnlineVotes.remove(data[2]);
}
}
if (data.length > 8) {
if (data[0].equalsIgnoreCase("Vote")) {
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
data[1]);
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
data[1]);
}
}
}
});
multiproxyClientHandles = new HashMap<String, ClientHandler>();
for (ConfigurationNode s : config.getMultiProxyServers()) {
ConfigurationNode d = config.getMultiProxyServers(s.getKey().toString());
multiproxyClientHandles.put(s.getKey().toString(),
new ClientHandler(d.getNode("Host").getString("0.0.0.0"), d.getNode("Port").getInt(1298),
encryptionHandler, config.getDebug()));
}
getLogger().info("Loaded multi-proxy support");
private void loadMultiProxySupport() {
if (multiProxyHandler != null) {
multiProxyHandler.close();
}
multiProxyHandler = new MultiProxyHandler() {
@Override
public void triggerVote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
BungeeMessageData text, String uuid) {
vote(player, service, realVote, timeQueue, queueTime, text, uuid);
}
@Override
public void setEncryptionHandler(EncryptionHandler encryptionHandler1) {
encryptionHandler = encryptionHandler1;
}
@Override
public void logInfo(String msg) {
getLogger().info(msg);
}
@Override
public String getVersion() {
return server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get();
}
@Override
public boolean getMultiProxySupportEnabled() {
return config.getMultiProxySupport();
}
@Override
public int getMultiProxySocketHostPort() {
return config.getMultiProxySocketHostPort();
}
@Override
public String getMultiProxySocketHostHost() {
return config.getMultiProxySocketHostHost();
}
@Override
public MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s) {
return new MultiProxyServerSocketConfigurationVelocity(s, config.getMultiProxyServers(s));
}
@Override
public Collection<String> getMultiProxyServers() {
ArrayList<String> servers = new ArrayList<String>();
for (ConfigurationNode s : config.getMultiProxyServers()) {
servers.add(s.getKey().toString());
}
return servers;
}
@Override
public EncryptionHandler getEncryptionHandler() {
return encryptionHandler;
}
@Override
public boolean getDebug() {
return config.getDebug();
}
@Override
public File getPluginDataFolder() {
return dataDirectory.toFile();
}
@Override
public void clearVote(String string) {
cachedOnlineVotes.remove(string);
}
@Override
public void addNonVotedPlayerCache(String uuid, String player) {
nonVotedPlayersCache.addPlayer(uuid, player);
}
@Override
public boolean getPrimaryServer() {
return config.getPrimaryServer();
}
@Override
public List<String> getProxyServers() {
return config.getProxyServers();
}
@Override
public void runAsnc(Runnable runnable) {
runAsyncNow(runnable);
}
@Override
public MultiProxyMethod getMultiProxyMethod() {
return MultiProxyMethod.getByName(config.getMultiProxyMethod());
}
@Override
public RedisHandler getRedisHandler() {
return redisHandler;
}
@Override
public boolean getMultiProxyRedisUseExistingConnection() {
return config.getMultiProxyRedisUseExistingConnection();
}
@Override
public String getMultiProxyPassword() {
return config.getMultiProxyRedisPassword();
}
@Override
public String getMultiProxyUsername() {
return config.getMultiProxyRedisUsername();
}
@Override
public int getMultiProxyRedisPort() {
return config.getMultiProxyRedisPort();
}
@Override
public String getMultiProxyRedisHost() {
return config.getMultiProxyRedisHost();
}
@Override
public String getMultiProxyServerName() {
return config.getProxyServerName();
}
};
multiProxyHandler.loadMultiProxySupport();
}
private void runAsyncNow(Runnable runnable) {
server.getScheduler().buildTask(this, runnable).schedule();
}
@Getter
private MultiProxyHandler multiProxyHandler;
public void sendServerNameMessage() {
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
for (RegisteredServer s : getAvailableAllServers()) {
sendPluginMessageServer(s, "ServerName", s.getServerInfo().getName());
}
}
}
private String version = "";
@@ -1106,6 +1293,22 @@ public class VotingPluginVelocity {
loadMultiProxySupport();
}
public void sendMessageServer(RegisteredServer s, String channel, String... messageData) {
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
sendPluginMessageServer(s, channel, messageData);
} else if (method.equals(BungeeMethod.REDIS)) {
sendRedisMessageServer(s, channel, messageData);
}
}
public void sendRedisMessageServer(RegisteredServer s, String channel, String... messageData) {
ArrayList<String> list = new ArrayList<String>();
list.add(channel);
list.addAll(ArrayUtils.getInstance().convert(messageData));
redisHandler.sendMessage(getConfig().getRedisPrefix() + "VotingPlugin_" + s.getServerInfo().getName(),
ArrayUtils.getInstance().convert(list));
}
public void sendPluginMessageServer(RegisteredServer s, String channel, String... messageData) {
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteOutStream);
@@ -1175,14 +1378,14 @@ public class VotingPluginVelocity {
public void status() {
if (method.equals(BungeeMethod.SOCKETS)) {
sendServerMessage("status");
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
} else if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
for (RegisteredServer s : getAvailableAllServers()) {
if (s.getPlayersConnected().size() == 0) {
getLogger().info("No players on server " + s + " to send test status message");
} else {
// send
getLogger().info("Sending request for status message on " + s);
sendPluginMessageServer(s, "Status", s.getServerInfo().getName());
sendMessageServer(s, "Status", s.getServerInfo().getName());
}
}
@@ -1223,17 +1426,12 @@ public class VotingPluginVelocity {
uuid = getUUID(player);
}
if (uuid.isEmpty()) {
if (config.getGeyserSupport()) {
if (!player.startsWith(config.getGeyserPrefix())) {
uuid = getUUID(config.getGeyserPrefix() + player);
player = config.getGeyserPrefix() + player;
}
}
}
if (uuid.isEmpty()) {
if (config.getAllowUnJoined()) {
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 {
@@ -1258,8 +1456,8 @@ public class VotingPluginVelocity {
player = getProperName(uuid, player);
addVoteParty();
if (getConfig().getPrimaryServer() || !getConfig().getMultiProxySupport()) {
addVoteParty();
if (getConfig().getBungeeManageTotals()) {
if (mysql == null) {
@@ -1279,6 +1477,15 @@ public class VotingPluginVelocity {
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
int milestoneCount = getValue(data, "MilestoneCount", 1);
int maxVotes = getConfig().getMaxAmountOfVotesPerDay();
if (maxVotes > 0) {
LocalDateTime cTime = getBungeeTimeChecker().getTime();
int days = cTime.getDayOfMonth();
if (monthTotal > days * maxVotes) {
monthTotal = days * maxVotes;
}
}
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
ArrayList<Column> update = new ArrayList<Column>();
@@ -1304,7 +1511,7 @@ public class VotingPluginVelocity {
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
p = server.getPlayer(UUID.fromString(uuid)).get();
}
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
if (config.getSendVotesToAllServers()) {
for (RegisteredServer s : getAvailableAllServers()) {
@@ -1327,9 +1534,8 @@ public class VotingPluginVelocity {
} else {
// send
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
Boolean.TRUE.toString(), "" + realVote, text.toString(),
"" + getConfig().getBungeeManageTotals(),
sendMessageServer(s, "Vote", player, uuid, service, "" + time, Boolean.TRUE.toString(),
"" + realVote, text.toString(), "" + getConfig().getBungeeManageTotals(),
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "1", "1");
}
if (config.getBroadcast()) {
@@ -1338,14 +1544,13 @@ public class VotingPluginVelocity {
}
} else {
if (isOnline(p) && !config.getBlockedServers()
.contains(p.getCurrentServer().get().getServerInfo().getName())) {
sendPluginMessageServer(p.getCurrentServer().get().getServer(), "VoteOnline", player, uuid,
service, "" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
if (isOnline(p) && isInAvailableServers(p.getCurrentServer().get().getServerInfo().getName())) {
sendMessageServer(p.getCurrentServer().get().getServer(), "VoteOnline", player, uuid, service,
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
"" + config.getBroadcast(), "1", "1");
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
sendMultiProxyServerMessage("ClearVote", player, uuid);
getMultiProxyHandler().sendMultiProxyServerMessage("ClearVote", player, uuid);
}
} else {
if (!cachedOnlineVotes.containsKey(uuid)) {
@@ -1361,10 +1566,10 @@ public class VotingPluginVelocity {
}
for (RegisteredServer s : getAvailableAllServers()) {
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
"" + currentVotePartyVotesRequired);
sendMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
"" + currentVotePartyVotesRequired, text.toString());
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
sendMessageServer(s, "VoteBroadcast", uuid, player, service);
}
}
}
@@ -1375,15 +1580,17 @@ public class VotingPluginVelocity {
if (getConfig().getMultiProxySupport() && getConfig().getPrimaryServer()) {
if (!getConfig().getMultiProxyOneGlobalReward()) {
debug("Sending global proxy vote message");
sendMultiProxyServerMessage("Vote", uuid, player, service, "" + votePartyVotes,
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
getMultiProxyHandler().sendMultiProxyServerMessage("Vote", uuid, player, service,
"" + votePartyVotes, "" + currentVotePartyVotesRequired, "" + time, "" + realVote,
text.toString());
} else {
// check if reward should've already been given
if (!(isOnline(p) && !config.getBlockedServers()
.contains(p.getCurrentServer().get().getServerInfo().getName()))) {
debug("Seending global proxy voteonline message");
sendMultiProxyServerMessage("VoteOnline", uuid, player, service, "" + votePartyVotes,
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
getMultiProxyHandler().sendMultiProxyServerMessage("VoteOnline", uuid, player, service,
"" + votePartyVotes, "" + currentVotePartyVotesRequired, "" + time, "" + realVote,
text.toString());
} else {
debug("Not sending global proxy message for voteonline, player already got reward");
}
@@ -1395,6 +1602,15 @@ public class VotingPluginVelocity {
}
}
public boolean isInAvailableServers(String server) {
for (RegisteredServer s : getAvailableAllServers()) {
if (s.getServerInfo().getName().equalsIgnoreCase(server)) {
return true;
}
}
return false;
}
public Set<RegisteredServer> getAvailableAllServers() {
Set<RegisteredServer> servers = new HashSet<RegisteredServer>();
if (config.getWhiteListedServers().isEmpty()) {
@@ -1422,12 +1638,6 @@ public class VotingPluginVelocity {
return false;
}
public void sendMultiProxyServerMessage(String... messageData) {
for (ClientHandler h : multiproxyClientHandles.values()) {
h.sendMessage(messageData);
}
}
@Getter
private int votePartyVotes = 0;
@Getter
@@ -55,13 +55,21 @@ public class VotingPluginVelocityCommand implements SimpleCommand {
.text("Checking status, waiting for response, check console, method: pluginmessaging")
.color(NamedTextColor.AQUA));
plugin.status();
plugin.sendServerNameMessage();
} else if (plugin.getMethod().equals(BungeeMethod.REDIS)) {
source.sendMessage(
Component.text("Checking status, waiting for response, check console, method: redis")
.color(NamedTextColor.AQUA));
plugin.status();
plugin.sendServerNameMessage();
} else {
source.sendMessage(Component.text("Not using socket/pluginmessage method, command unavailable")
.color(NamedTextColor.AQUA));
}
}
if (args[0].equalsIgnoreCase("multiproxystatus")) {
plugin.sendMultiProxyServerMessage("Status");
plugin.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
source.sendMessage(Component.text("Sending status message").color(NamedTextColor.AQUA));
}
if (args[0].equalsIgnoreCase("help")) {
File diff suppressed because it is too large. Load diff
@@ -1,11 +1,11 @@
package com.bencodez.votingplugin.commands.executers;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -36,7 +36,7 @@ public class CommandAdminVote implements CommandExecutor {
}
// invalid command
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
return true;
}
@@ -2,12 +2,12 @@ package com.bencodez.votingplugin.commands.executers;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
@@ -91,9 +91,11 @@ public class CommandAliases implements CommandExecutor {
// invalid command
if (adminCommand) {
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
sender.sendMessage(
StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
} else {
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
sender.sendMessage(
StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
}
return true;
}
@@ -1,11 +1,11 @@
package com.bencodez.votingplugin.commands.executers;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -61,7 +61,7 @@ public class CommandVote implements CommandExecutor {
}
// invalid command
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
return true;
}
@@ -25,9 +25,9 @@ import com.bencodez.advancedcore.api.valuerequest.InputMethod;
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
import com.bencodez.advancedcore.api.yml.editor.ConfigEditor;
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteBungeeSettings;
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty;
import com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative;
import com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteMilestones;
@@ -167,11 +167,40 @@ public class AdminGUI {
}
});
buttons.add(new BInventoryButton(new ItemBuilder("GRASS_BLOCK").setName("&cEdit BungeeSettings.yml")) {
buttons.add(new BInventoryButton(
new ItemBuilder("GRASS_BLOCK").setName("&cEdit BungeeSettings.yml").addLoreLine("&aCurrently WIP")) {
@Override
public void onClick(ClickEvent clickEvent) {
new AdminVoteBungeeSettings(plugin, clickEvent.getPlayer()).open();
new ConfigEditor(plugin, plugin.getBungeeSettings()).open(clickEvent.getPlayer());
}
});
buttons.add(new BInventoryButton(
new ItemBuilder("GRASS_BLOCK").setName("&cEdit Config.yml").addLoreLine("&aCurrently WIP")) {
@Override
public void onClick(ClickEvent clickEvent) {
new ConfigEditor(plugin, plugin.getConfigFile(), plugin.getOptions().getYmlConfig(),
plugin.getOptions().getClass()).open(clickEvent.getPlayer());
}
});
buttons.add(new BInventoryButton(
new ItemBuilder(Material.CHEST).setName("&cEdit GUI.yml").addLoreLine("&aCurrently WIP")) {
@Override
public void onClick(ClickEvent clickEvent) {
new ConfigEditor(plugin, plugin.getGui()).open(clickEvent.getPlayer());
}
});
buttons.add(new BInventoryButton(
new ItemBuilder("GRASS_BLOCK").setName("&cEdit SpecialRewards.yml").addLoreLine("&aCurrently WIP")) {
@Override
public void onClick(ClickEvent clickEvent) {
new ConfigEditor(plugin, plugin.getSpecialRewardsConfig()).open(clickEvent.getPlayer());
}
});
@@ -213,7 +242,9 @@ public class AdminGUI {
int count = 0;
for (VoteSite voteSite : plugin.getVoteSites()) {
ArrayList<String> lore = new ArrayList<String>();
lore.add("Enabled: " + voteSite.isEnabled());
lore.add("Priority: " + voteSite.getPriority());
lore.add("Name: " + voteSite.getDisplayName());
lore.add("ServiceSite: " + voteSite.getServiceSite());
lore.add("VoteURL: " + voteSite.getVoteURL());
@@ -340,6 +371,17 @@ public class AdminGUI {
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelayDailyHour", voteSite.getVoteDelayDailyHour()) {
@Override
public void setValue(Player player, Number num) {
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
String siteName = voteSite.getKey();
plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
plugin.reload();
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("Enabled", voteSite.isEnabled()) {
@Override
@@ -1,147 +0,0 @@
package com.bencodez.votingplugin.commands.gui.admin;
import java.util.ArrayList;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean;
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
import com.bencodez.votingplugin.VotingPluginMain;
public class AdminVoteBungeeSettings extends GUIHandler {
private VotingPluginMain plugin;
public AdminVoteBungeeSettings(VotingPluginMain plugin, CommandSender player) {
super(plugin, player);
this.plugin = plugin;
}
@Override
public ArrayList<String> getChat(CommandSender sender) {
return null;
}
@Override
public void onBook(Player player) {
}
@Override
public void onChat(CommandSender sender) {
}
@Override
public void onChest(Player player) {
EditGUI inv = new EditGUI("Edit BungeeSettings");
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.BungeeSettings");
inv.addButton(new EditGUIButton(
new EditGUIValueBoolean("UseBungeecord", plugin.getBungeeSettings().isUseBungeecoord()) {
@Override
public void setValue(Player player, boolean value) {
setPathData(getKey(), value);
}
}));
inv.addButton(
new EditGUIButton(new EditGUIValueString("BungeeMethod", plugin.getBungeeSettings().getBungeeMethod()) {
@Override
public void setValue(Player player, String value) {
setPathData(getKey(), value);
}
}).addOptions("PLUGINMESSAGING", "SOCKETS", "MYSQL"));
inv.addButton(
new EditGUIButton(new EditGUIValueBoolean("BungeeDebug", plugin.getBungeeSettings().isBungeeDebug()) {
@Override
public void setValue(Player player, boolean value) {
setPathData(getKey(), value);
}
}));
inv.addButton(new EditGUIButton(
new EditGUIValueBoolean("BungeeBroadcast", plugin.getBungeeSettings().isBungeeBroadcast()) {
@Override
public void setValue(Player player, boolean value) {
setPathData(getKey(), value);
}
}.addLore("Triggers a broadcast for the entire network, most cases it is best for this to be false")));
inv.addButton(new EditGUIButton(
new EditGUIValueBoolean("BungeeBroadcastAlways", plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
@Override
public void setValue(Player player, boolean value) {
setPathData(getKey(), value);
}
}.addLore("Whether or not to broadcast on cached votes").addLore("PLUGINMESSAGING ONLY")));
inv.addButton(new EditGUIButton(
new EditGUIValueBoolean("PerServerRewards", plugin.getBungeeSettings().isPerServerRewards()) {
@Override
public void setValue(Player player, boolean value) {
setPathData(getKey(), value);
}
}));
inv.addButton(new EditGUIButton(
new EditGUIValueBoolean("PerServerMilestones", plugin.getBungeeSettings().isPerServerMilestones()) {
@Override
public void setValue(Player player, boolean value) {
setPathData(getKey(), value);
}
}));
inv.addButton(new EditGUIButton(
new EditGUIValueBoolean("PerServerPoints", plugin.getBungeeSettings().isPerServerPoints()) {
@Override
public void setValue(Player player, boolean value) {
setPathData(getKey(), value);
}
}));
inv.addButton(new EditGUIButton(
new EditGUIValueBoolean("TriggerVotifierEvent", plugin.getBungeeSettings().isTriggerVotifierEvent()) {
@Override
public void setValue(Player player, boolean value) {
setPathData(getKey(), value);
}
}));
inv.addButton(new EditGUIButton(new EditGUIValueString("Server", plugin.getBungeeSettings().getServer()) {
@Override
public void setValue(Player player, String value) {
setPathData(getKey(), value);
}
}.addLore("Server name as stated in proxy")));
inv.openInventory(player);
}
@Override
public void open() {
open(GUIMethod.CHEST);
}
private void setPathData(String path, Object value) {
plugin.getBungeeSettings().getData().set(path, value);
plugin.getBungeeSettings().saveData();
plugin.reload();
}
}
@@ -64,7 +64,7 @@ public class AdminVoteHelp extends GUIHandler {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
if (!requirePerms || cmdHandle.hasPerm(sender)) {
@@ -52,7 +52,7 @@ public class AdminVoteVoteParty extends GUIHandler {
// to add
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
new EditGUIValueBoolean("Enabled", plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
new EditGUIValueBoolean("Enabled", plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
@Override
public void setValue(Player player, boolean name) {
@@ -70,7 +70,7 @@ public class AdminVoteVoteParty extends GUIHandler {
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.LADDER, 1), new EditGUIValueNumber(
"IncreaseVotesRquired", plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired()) {
"IncreaseVotesRquired", plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRequired()) {
@Override
public void setValue(Player player, Number num) {
@@ -106,7 +106,7 @@ public class AdminVoteVoteParty extends GUIHandler {
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("GiveAllPlayers",
plugin.getSpecialRewardsConfig().getVotePartyGiveAllPlayers()) {
plugin.getSpecialRewardsConfig().isVotePartyGiveAllPlayers()) {
@Override
public void setValue(Player player, boolean name) {
@@ -124,7 +124,7 @@ public class AdminVoteVoteParty extends GUIHandler {
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
new EditGUIValueBoolean("ResetEachDay", plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {
new EditGUIValueBoolean("ResetEachDay", plugin.getSpecialRewardsConfig().isVotePartyResetEachDay()) {
@Override
public void setValue(Player player, boolean name) {
@@ -133,7 +133,7 @@ public class AdminVoteVoteParty extends GUIHandler {
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
new EditGUIValueBoolean("ResetWeekly", plugin.getSpecialRewardsConfig().getVotePartyResetWeekly()) {
new EditGUIValueBoolean("ResetWeekly", plugin.getSpecialRewardsConfig().isVotePartyResetWeekly()) {
@Override
public void setValue(Player player, boolean name) {
@@ -142,7 +142,7 @@ public class AdminVoteVoteParty extends GUIHandler {
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
new EditGUIValueBoolean("ResetMonthly", plugin.getSpecialRewardsConfig().getVotePartyResetMontly()) {
new EditGUIValueBoolean("ResetMonthly", plugin.getSpecialRewardsConfig().isVotePartyResetMonthly()) {
@Override
public void setValue(Player player, boolean name) {
@@ -151,7 +151,7 @@ public class AdminVoteVoteParty extends GUIHandler {
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("OnlyOncePerDay",
plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerDay()) {
@Override
public void setValue(Player player, boolean name) {
@@ -169,7 +169,7 @@ public class AdminVoteVoteParty extends GUIHandler {
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("CountFakeVotes",
plugin.getSpecialRewardsConfig().getVotePartyCountFakeVotes()) {
plugin.getSpecialRewardsConfig().isVotePartyCountFakeVotes()) {
@Override
public void setValue(Player player, boolean name) {
@@ -178,7 +178,7 @@ public class AdminVoteVoteParty extends GUIHandler {
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("CountOfflineVotes",
plugin.getSpecialRewardsConfig().getVotePartyCountOfflineVotes()) {
plugin.getSpecialRewardsConfig().isVotePartyCountOfflineVotes()) {
@Override
public void setValue(Player player, boolean name) {
@@ -44,7 +44,7 @@ public class AdminVoteVotePlayer extends GUIHandler {
EditGUI inv = new EditGUI("Trigger vote for " + playerName);
inv.requirePermission("VotingPlugin.Commands.AdminVote.Vote|VotingPlugin.Admin");
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
inv.addButton(new BInventoryButton(site.getItem().setName(site.getKey())) {
@Override
@@ -1,6 +1,8 @@
package com.bencodez.votingplugin.commands.gui.admin.voteshop;
import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
@@ -109,6 +111,31 @@ public class AdminVoteVoteShopItem extends GUIHandler {
setPathData(getKey(), value);
}
}));
inv.addButton(new BInventoryButton(
new ItemBuilder(player.getInventory().getItemInMainHand().clone()).addLoreLine("&cClick to add")) {
@Override
public void onClick(ClickEvent clickEvent) {
ItemBuilder item = new ItemBuilder(clickEvent.getPlayer().getInventory().getItemInMainHand().clone());
Map<String, Object> map = item.getConfiguration(false);
for (Entry<String, Object> entry : map.entrySet()) {
setPathData(entry.getKey(), entry.getValue());
}
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(player.getInventory().getItemInMainHand().clone())
.addLoreLine("&cClick to add with exact data")) {
@Override
public void onClick(ClickEvent clickEvent) {
ItemBuilder item = new ItemBuilder(clickEvent.getPlayer().getInventory().getItemInMainHand().clone());
Map<String, Object> map = item.getConfiguration(true);
for (Entry<String, Object> entry : map.entrySet()) {
setPathData("ItemStack." + entry.getKey(), entry.getValue());
}
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")) {
@Override
@@ -162,13 +162,19 @@ public class VoteGUI extends GUIHandler {
} else {
plugin.getCommandLoader().processSlotClick(player, user, slot);
}
String prefix = "";
if (event.getButton().getBuilder().isConditional()) {
prefix = "Item.";
}
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(), plugin.getGui()
.getChestVoteGUISlotRewardsPath(slot, event.getButton().getLastRewardsPath(player)))) {
plugin.getRewardHandler().giveReward(plugin.getVotingPluginUserManager().getVotingPluginUser(player),
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
prefix + event.getButton().getLastRewardsPath(player)))) {
plugin.getRewardHandler().giveReward(
plugin.getVotingPluginUserManager().getVotingPluginUser(player),
plugin.getGui().getData(),
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
event.getButton().getLastRewardsPath(player)),
prefix + event.getButton().getLastRewardsPath(player)),
new RewardOptions().addPlaceholder("identifier", slot));
}
}
@@ -37,7 +37,7 @@ public class VoteHelp extends GUIHandler {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
String colorStr = plugin.getConfigFile().getFormatCommandsVoteHelpHoverColor();
ChatColor hoverColor = null;
@@ -68,7 +68,7 @@ public class VoteHelp extends GUIHandler {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
if (!requirePerms || cmdHandle.hasPerm(sender)) {
@@ -39,7 +39,7 @@ public class VoteLast extends GUIHandler {
msg.add(StringParser.getInstance().replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(),
"%player%", playerName));
for (VoteSite voteSite : plugin.getVoteSites()) {
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
msg.add(user.voteCommandLastLine(voteSite));
}
@@ -62,7 +62,7 @@ public class VoteLast extends GUIHandler {
public void onChest(Player player) {
BInventory inv = new BInventory(plugin.getGui().getChestVoteLastName());
inv.addPlaceholder("player", user.getPlayerName());
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
if (!site.isHidden()) {
inv.addButton(inv.getNextSlot(),
new UpdatingBInventoryButton(plugin, site.getItem().setName(site.getDisplayName())
@@ -114,7 +114,7 @@ public class VoteLast extends GUIHandler {
});
}
if (plugin.getGui().getChestVoteLastBackButton()) {
if (plugin.getGui().isChestVoteLastBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
@@ -43,7 +43,7 @@ public class VoteNext extends GUIHandler {
msg.add(StringParser.getInstance().colorize(StringParser.getInstance()
.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteNextTitle(), "%player%", playerName)));
for (VoteSite voteSite : plugin.getVoteSites()) {
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
@@ -63,7 +63,7 @@ public class VoteNext extends GUIHandler {
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
// add colors/config options
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
if (!site.isHidden()) {
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
nextLayout.replaceTextComponent("[Json]",
@@ -87,7 +87,7 @@ public class VoteNext extends GUIHandler {
public void onChest(Player player) {
BInventory inv = new BInventory(plugin.getGui().getChestVoteNextName());
inv.addPlaceholder("player", user.getPlayerName());
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
if (!site.isHidden()) {
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
if (siteNameDisplay.isEmpty()) {
@@ -130,7 +130,7 @@ public class VoteNext extends GUIHandler {
});
}
if (plugin.getGui().getChestVoteNextBackButton()) {
if (plugin.getGui().isChestVoteNextBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
inv.openInventory(player);
@@ -45,7 +45,7 @@ public class VoteShop extends GUIHandler {
@Override
public void onChest(Player player) {
if (!plugin.getGui().getChestVoteShopEnabled()) {
if (!plugin.getGui().isChestVoteShopEnabled()) {
player.sendMessage(StringParser.getInstance().colorize(plugin.getGui().getChestVoteShopDisabled()));
return;
}
@@ -86,7 +86,8 @@ public class VoteShop extends GUIHandler {
}
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
if (hasPerm && (limitPass || !plugin.getGui().isChestVoteShopHideLimitedReached())) {
if ((hasPerm || !plugin.getGui().getChestVoteShopHideOnNoPermission(identifier))
&& (limitPass || !plugin.getGui().isChestVoteShopHideLimitedReached())) {
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
inv.addButton(new BInventoryButton(builder) {
@@ -146,14 +147,21 @@ public class VoteShop extends GUIHandler {
plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
}
} else {
new VoteShopConfirm(plugin, player, user, identifier).open(GUIMethod.CHEST);
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
new VoteShopConfirm(plugin, player, user, identifier)
.open(GUIMethod.CHEST);
}
});
}
} else {
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
}
plugin.getCommandLoader().processSlotClick(player, user, identifier);
if (plugin.getGui().getChestVoteShopReopenGUIOnPurchase()) {
if (plugin.getGui().isChestVoteShopReopenGUIOnPurchase()) {
plugin.getCommandLoader().processSlotClick(player, user, "shop");
}
}
@@ -189,7 +197,7 @@ public class VoteShop extends GUIHandler {
});
}
if (plugin.getGui().getChestVoteShopBackButton()) {
if (plugin.getGui().isChestVoteShopBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
@@ -136,7 +136,7 @@ public class VoteStreak extends GUIHandler {
});
}
if (plugin.getGui().getChestVoteStreakBackButton()) {
if (plugin.getGui().isChestVoteStreakBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
@@ -133,7 +133,7 @@ public class VoteToday extends GUIHandler {
});
}
if (plugin.getGui().getChestVoteTodayBackButton()) {
if (plugin.getGui().isChestVoteTodayBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
inv.openInventory(player);
@@ -119,7 +119,7 @@ public class VoteTopVoter extends GUIHandler {
@Override
public void onClick(ClickEvent clickEvent) {
if (plugin.getGui().getChestVoteTopOpenMainGUIOnClick()) {
if (plugin.getGui().isChestVoteTopOpenMainGUIOnClick()) {
TopVoterPlayer user = (TopVoterPlayer) getData("User");
new VoteGUI(plugin, player, user.getUser())
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
@@ -131,7 +131,7 @@ public class VoteTopVoter extends GUIHandler {
button.setSlot(playerSlots.remove());
}
inv.setCloseInv(plugin.getGui().getChestVoteTopCloseGUIOnClick());
inv.setCloseInv(plugin.getGui().isChestVoteTopCloseGUIOnClick());
inv.addButton(button);
pos++;
@@ -174,7 +174,7 @@ public class VoteTopVoter extends GUIHandler {
});
}
if (plugin.getGui().getChestVoteTopBackButton()) {
if (plugin.getGui().isChestVoteTopBackButton()) {
if (customzationEnabled) {
inv.addButton(plugin.getCommandLoader().getBackButton(user)
.setSlot(customization.getInt("BackButtonSlot", 0)));
@@ -199,7 +199,7 @@ public class VoteTopVoter extends GUIHandler {
});
}
if (customization == null || (customzationEnabled && !customization.getBoolean("RemoveBottomBar"))) {
if (customization == null || !customzationEnabled || !customization.getBoolean("RemoveBottomBar")) {
inv.setPages(true);
}
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
@@ -82,7 +82,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
pos++;
}
if (plugin.getGui().getChestVoteTopBackButton()) {
if (plugin.getGui().isChestVoteTopBackButton()) {
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
}
@@ -102,7 +102,7 @@ public class VoteTotal extends GUIHandler {
});
}
if (plugin.getGui().getChestVoteTotalBackButton()) {
if (plugin.getGui().isChestVoteTotalBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
inv.openInventory(player);
@@ -57,9 +57,9 @@ public class VoteURL extends GUIHandler {
if (title != null) {
sites.addAll(title);
}
if (plugin.getConfigFile().getFormatCommandsVoteAutoInputSites()) {
if (plugin.getConfigFile().isFormatCommandsVoteAutoInputSites()) {
int counter = 0;
for (VoteSite voteSite : plugin.getVoteSites()) {
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
counter++;
String voteURL = voteSite.getVoteURL(json);
@@ -117,13 +117,16 @@ public class VoteURL extends GUIHandler {
if (user.canVoteSite(voteSite)) {
builder = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteItemSection());
builder.setName(
plugin.getGui().getChestVoteURLGUISiteNameCanVote().replace("%Name%", voteSite.getDisplayName()));
builder.setName(plugin.getGui().getChestVoteURLGUISiteNameCanVote());
} else {
builder.setName(plugin.getGui().getChestVoteURLGUISiteName().replace("%Name%", voteSite.getDisplayName()));
builder.addLoreLine(
plugin.getGui().getChestVoteURLNextVote().replace("%Info%", user.voteCommandNextInfo(voteSite)));
builder.setName(plugin.getGui().getChestVoteURLGUISiteName());
builder.addLoreLine(plugin.getGui().getChestVoteURLNextVote());
}
builder.addPlaceholder("ServiceSite", voteSite.getServiceSite());
builder.addPlaceholder("Name", voteSite.getDisplayName());
builder.addPlaceholder("VoteDelay", "" + voteSite.getVoteDelay());
builder.addPlaceholder("VoteHour", "" + voteSite.getVoteDelayDailyHour());
builder.addPlaceholder("Info", user.voteCommandNextInfo(voteSite));
return builder;
}
@@ -132,7 +135,12 @@ public class VoteURL extends GUIHandler {
public void onBook(Player player) {
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
for (VoteSite site : plugin.getVoteSites()) {
if (plugin.getGui().isBookVoteURLBookGUIManual()) {
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUITopLayout());
book.addLayout(layout);
}
int i = 1;
for (VoteSite site : plugin.getVoteSitesEnabled()) {
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename",
site.getDisplayName());
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
@@ -141,12 +149,12 @@ public class VoteURL extends GUIHandler {
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
}
String url = StringParser.getInstance().replacePlaceHolder(site.getVoteURLJsonStrip(), "player",
user.getPlayerName());
String url = StringParser.getInstance().replacePlaceHolder(StringParser.getInstance()
.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);
@@ -161,7 +169,7 @@ public class VoteURL extends GUIHandler {
public void onChest(Player player) {
// normal GUI
BInventory inv = new BInventory(plugin.getGui().getChestVoteURLName());
if (plugin.getGui().getChestVoteURLViewAllUrlsButtonEnabled()) {
if (plugin.getGui().isChestVoteURLViewAllUrlsButtonEnabled()) {
ItemBuilder builderAll = getItemAll();
inv.addButton(new UpdatingBInventoryButton(plugin, builderAll, 5000, 5000) {
@@ -181,7 +189,7 @@ public class VoteURL extends GUIHandler {
}
int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
for (final VoteSite voteSite : plugin.getVoteSites()) {
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
ItemBuilder builder = getItemVoteSite(voteSite);
if (startSlot >= 0) {
@@ -196,11 +204,14 @@ public class VoteURL extends GUIHandler {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
user.sendMessage(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance()
.replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
plugin.getGui().getChestVoteURLURLText(), "voteurl", voteSite.getVoteURL()),
"sitename", voteSite.getDisplayName()),
"player", player.getName()));
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);
}
@@ -228,7 +239,7 @@ public class VoteURL extends GUIHandler {
});
}
if (plugin.getGui().getChestVoteURLBackButton()) {
if (plugin.getGui().isChestVoteURLBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
@@ -94,7 +94,7 @@ public class VoteURLVoteSite extends GUIHandler {
}
});
if (plugin.getGui().getChestVoteURLBackButton()) {
if (plugin.getGui().isChestVoteURLBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
inv.openInventory(player);
@@ -31,6 +31,26 @@ public class BungeeSettings extends YMLFile {
@Getter
private String bungeeMethod = "PLUGINMESSAGING";
@ConfigDataString(path = "Redis.Host")
@Getter
private String RedisHost = "";
@ConfigDataString(path = "Redis.Username")
@Getter
private String RedisUsername = "";
@ConfigDataString(path = "Redis.Prefix")
@Getter
private String RedisPrefix = "";
@ConfigDataString(path = "Redis.Password")
@Getter
private String RedisPassword = "";
@ConfigDataInt(path = "Redis.Port")
@Getter
private int RedisPort = 6379;
@ConfigDataString(path = "BungeeServer.Host")
@Getter
private String bungeeServerHost = "";
@@ -47,6 +67,10 @@ public class BungeeSettings extends YMLFile {
@Getter
private boolean perServerMilestones = false;
@ConfigDataBoolean(path = "GiveExtraAllSitesRewards")
@Getter
private boolean giveExtraAllSitesRewards = false;
@ConfigDataBoolean(path = "PerServerRewards")
@Getter
private boolean perServerRewards = false;
@@ -12,6 +12,7 @@ import com.bencodez.advancedcore.api.yml.YMLFile;
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataKeys;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
import com.bencodez.votingplugin.VotingPluginMain;
@@ -34,6 +35,10 @@ public class Config extends YMLFile {
@Getter
private boolean addTotals = true;
@ConfigDataBoolean(path = "AddTotalsOffline")
@Getter
private boolean addTotalsOffline = true;
@ConfigDataBoolean(path = "PerSiteCoolDownEvents")
@Getter
private boolean perSiteCoolDownEvents = false;
@@ -42,6 +47,10 @@ public class Config extends YMLFile {
@Getter
private boolean queueVotesDuringTimeChange = false;
@ConfigDataBoolean(path = "AdvancedServiceSiteHandling")
@Getter
private boolean advancedServiceSiteHandling = false;
@ConfigDataBoolean(path = "AllowUnjoined")
@Getter
private boolean allowUnjoined = false;
@@ -194,6 +203,10 @@ public class Config extends YMLFile {
@Getter
private String formatCommandsVoteLastNeverVoted;
@ConfigDataBoolean(path = "Format.Commands.Vote.Last.IncludeSeconds")
@Getter
private boolean formatCommandsVoteLastIncludeSeconds = true;
@ConfigDataString(path = "Format.Commands.Vote.Last.TimeFormat", defaultValue = "%amount% %TimeType%")
@Getter
private String formatCommandsVoteLastTimeFormat;
@@ -282,6 +295,14 @@ public class Config extends YMLFile {
@Getter
private boolean preventRepeatMilestones = false;
@ConfigDataBoolean(path = "OfflineVotesLimit.Enabled")
@Getter
private boolean offlineVotesLimitEnabled = false;
@ConfigDataInt(path = "OfflineVotesLimit.Amount")
@Getter
private int offlineVotesLimitAmount = 5;
@ConfigDataBoolean(path = "UpdateWithPlayersOnlineOnly")
@Getter
private boolean updateWithPlayersOnlineOnly = false;
@@ -324,21 +345,13 @@ public class Config extends YMLFile {
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<String>());
}
public Set<String> getCustomCommands() {
Set<String> str = getData().getConfigurationSection("CustomCommands").getKeys(false);
if (str == null) {
str = new HashSet<String>();
}
return str;
}
@ConfigDataKeys(path = "CustomCommands")
@Getter
private Set<String> customCommands = new HashSet<String>();
public Set<String> getCustomPlaceholderReturns() {
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns").getKeys(false);
if (str == null) {
str = new HashSet<String>();
}
return str;
}
@ConfigDataKeys(path = "CustomPlaceholderReturns")
@Getter
private Set<String> customPlaceholderReturns = new HashSet<String>();
public Set<String> getCustomPlaceholderReturns(String placeholder) {
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
@@ -356,141 +369,77 @@ public class Config extends YMLFile {
return getData().getConfigurationSection("CustomCommands." + ident);
}
/**
* Gets the broad cast msg.
*
* @return the broad cast msg
*/
public String getFormatBroadCastMsg() {
return getData().getString("Format.BroadcastMsg",
"&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%");
@ConfigDataString(path = "Format.BroadcastMsg")
@Getter
private String formatBroadCastMsg = "&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%";
}
@ConfigDataBoolean(path = "Format.BroadcastWhenOnline")
@Getter
private boolean formatBroadcastWhenOnline = false;
/**
* Gets the broadcast when online.
*
* @return the broadcast when online
*/
public boolean getFormatBroadcastWhenOnline() {
return getData().getBoolean("Format.BroadcastWhenOnline");
}
@ConfigDataBoolean(path = "Format.Commands.Vote.AutoInputSites")
@Getter
private boolean formatCommandsVoteAutoInputSites = true;
/**
* Gets the commands vote auto input sites.
*
* @return the commands vote auto input sites
*/
public boolean getFormatCommandsVoteAutoInputSites() {
return getData().getBoolean("Format.Commands.Vote.AutoInputSites");
}
@ConfigDataListString(path = "Format.Commands.Vote.Best.Lines")
@Getter
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<String>();
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteBestLines() {
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Best.Lines", new ArrayList<String>());
}
@ConfigDataString(path = "Format.Commands.Vote.Best.Title")
@Getter
private String formatCommandsVoteBestTitle = "&3&l%player% Best Votes";
public String getFormatCommandsVoteBestTitle() {
return getData().getString("Format.Commands.Vote.Best.Title", "&3&l%player% Best Votes");
}
@ConfigDataString(path = "Format.Commands.Vote.Help.HoverColor")
@Getter
private String formatCommandsVoteHelpHoverColor = "AQUA";
public String getFormatCommandsVoteHelpHoverColor() {
return getData().getString("Format.Commands.Vote.Help.HoverColor", "AQUA");
}
@ConfigDataString(path = "Format.Commands.Vote.Help.Line")
@Getter
private String formatCommandsVoteHelpLine = "&6%Command% - &6%HelpMessage%";
/**
* Gets the commands vote help line.
*
* @return the commands vote help line
*/
public String getFormatCommandsVoteHelpLine() {
return getData().getString("Format.Commands.Vote.Help.Line", "&6%Command% - &6%HelpMessage%");
}
@ConfigDataBoolean(path = "Format.Commands.Vote.Help.RequirePermission")
@Getter
private boolean formatCommandsVoteHelpRequirePermission = false;
/**
* Gets the commands vote help require permission.
*
* @return the commands vote help require permission
*/
public boolean getFormatCommandsVoteHelpRequirePermission() {
return getData().getBoolean("Format.Commands.Vote.Help.RequirePermission");
}
@ConfigDataString(path = "Format.Commands.Vote.Help.Title")
@Getter
private String formatCommandsVoteHelpTitle = "&6Voting Player Help";
/**
* Gets the commands vote help title.
*
* @return the commands vote help title
*/
public String getFormatCommandsVoteHelpTitle() {
return getData().getString("Format.Commands.Vote.Help.Title", "&6Voting Player Help");
@ConfigDataString(path = "Format.Commands.Vote.Last.Title")
@Getter
private String formatCommandsVoteLastTitle = "&3&l%player% Last Vote Times:";
}
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.CanVote")
@Getter
private String formatCommandsVoteNextInfoCanVote = "Go Vote!";
/**
* Gets the commands vote last title.
*
* @return the commands vote last title
*/
public String getFormatCommandsVoteLastTitle() {
return getData().getString("Format.Commands.Vote.Last.Title", "&3&l%player% Last Vote Times:");
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.Error")
@Getter
private String formatCommandsVoteNextInfoError = "";
}
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.TimeUntilVote")
@Getter
private String formatCommandsVoteNextInfoTime = "&cCould not caculate time until next vote!";
/**
* Gets the commands vote next info can vote.
*
* @return the commands vote next info can vote
*/
public String getFormatCommandsVoteNextInfoCanVote() {
return getData().getString("Format.Commands.Vote.Next.Info.CanVote", "Go Vote!");
}
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.VoteDelayDaily")
@Getter
private String formatCommandsVoteNextInfoVoteDelayDaily = "%hours% Hours and %minutes% Minutes";
/**
* Gets the commands vote next info error.
*
* @return the commands vote next info error
*/
public String getFormatCommandsVoteNextInfoError() {
return getData().getString("Format.Commands.Vote.Next.Info.Error", "");
}
/**
* Gets the commands vote next info time.
*
* @return the commands vote next info time
*/
public String getFormatCommandsVoteNextInfoTime() {
return getData().getString("Format.Commands.Vote.Next.Info.TimeUntilVote",
"&cCould not caculate time until next vote!");
}
public String getFormatCommandsVoteNextInfoVoteDelayDaily() {
return getData().getString("Format.Commands.Vote.Next.Info.VoteDelayDaily",
"%hours% Hours and %minutes% Minutes");
}
@ConfigDataString(path = "PlaceholderCacheLevel", options = { "AUTO", "SPECIFIC", "NONE" })
@Getter
private String placeholderCacheLevelString = "AUTO";
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
return PlaceholderCacheLevel.getCache(getData().getString("PlaceholderCacheLevel", "AUTO"));
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
}
/**
* Gets the commands vote next layout.
*
* @return the commands vote next layout
*/
public String getFormatCommandsVoteNextLayout() {
return getData().getString("Format.Commands.Vote.Next.Layout", "&3%SiteName%: &6%info%");
}
@ConfigDataString(path = "Format.Commands.Vote.Next.Layout")
@Getter
private String formatCommandsVoteNextLayout = "&3%SiteName%: &6%info%";
/**
* Gets the commands vote next title.
*
* @return the commands vote next title
*/
public String getFormatCommandsVoteNextTitle() {
return getData().getString("Format.Commands.Vote.Next.Title", "&3&l%player% Next Votes:");
}
@ConfigDataString(path = "Format.Commands.Vote.Next.Title")
@Getter
private String formatCommandsVoteNextTitle = "&3&l%player% Next Votes:";
/**
* Gets the commands vote party.
@@ -510,9 +459,9 @@ public class Config extends YMLFile {
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<String>());
}
public String getFormatCommandsVoteStreakTitle() {
return getData().getString("Format.Commands.Vote.Streak.Title", "&3&l%player% Vote Streak");
}
@ConfigDataString(path = "Format.Commands.Vote.Streak.Title")
@Getter
private String formatCommandsVoteStreakTitle = "&3&l%player% Vote Streak";
/**
* Gets the commands vote text.
@@ -555,168 +504,103 @@ public class Config extends YMLFile {
return list;
}
/**
* Gets the commands vote URLS.
*
* @return the commands vote URLS
*/
public String getFormatCommandsVoteURLS() {
return getData().getString("Format.Commands.Vote.Sites", "&4%num%: &c&l%SiteName% - &c%url%");
}
@ConfigDataString(path = "Format.Commands.Vote.Sites")
@Getter
private String formatCommandsVoteURLS = "&4%num%: &c&l%SiteName% - &c%url%";
/**
* Gets the command vote points.
*
* @return the command vote points
*/
public String getFormatCommandVotePoints() {
return getData().getString("Format.Commands.Vote.Points", "&a%Player% currently has &a&l%Points%&a Points!");
@ConfigDataString(path = "Format.Commands.Vote.Points")
@Getter
private String formatCommandsVotePoints = "&a%Player% currently has &a&l%Points%&a Points!";
}
@ConfigDataString(path = "Format.Commands.Vote.Top.Line")
@Getter
private String formatCommandsVoteTopLine = "&c%num%: &6%player%, %votes%";
/**
* Gets the command vote top line.
*
* @return the command vote top line
*/
public String getFormatCommandVoteTopLine() {
return getData().getString("Format.Commands.Vote.Top.Line", "&c%num%: &6%player%, %votes%");
}
@ConfigDataString(path = "Format.Commands.Vote.Top.Title")
@Getter
private String formatCommandVoteTopTitle = "&3Top %Top% Voters %page%/%maxpages%";
/**
* Gets the command vote top title.
*
* @return the command vote top title
*/
public String getFormatCommandVoteTopTitle() {
return getData().getString("Format.Commands.Vote.Top.Title", "&3Top %Top% Voters %page%/%maxpages%");
@ConfigDataString(path = "Format.NextPage")
@Getter
private String formatNextPage = "&aNext Page";
}
@ConfigDataString(path = "Format.NoPerms")
@Getter
private String formatNoPerms = "&cYou do not have enough permission!";
public String getFormatNextPage() {
return getData().getString("Format.NextPage", "&aNext Page");
}
@ConfigDataString(path = "Format.NotNumber")
@Getter
private String formatNotNumber = "&cError on &6%arg%&c, number expected!";
/**
* Gets the format no perms.
*
* @return the format no perms
*/
public String getFormatNoPerms() {
return getData().getString("Format.NoPerms", "&cYou do not have enough permission!");
}
@ConfigDataString(path = "Format.PrevPage")
@Getter
private String formatPrevPage = "&aPrevious Page";
public String getFormatNotNumber() {
return getData().getString("Format.NotNumber", "&cError on &6%arg%&c, number expected!");
}
@ConfigDataString(path = "Format.ShopFailed")
@Getter
private String formatShopFailedMsg = "&cYou do not have %Points% points to purhcase this!";
public String getFormatPrevPage() {
return getData().getString("Format.PrevPage", "&aPrevious Page");
}
@ConfigDataString(path = "Format.ShopNotPurchasable")
@Getter
private String formatShopNotPurchasable = "&cThis item is not buyable!";
public String getFormatShopFailedMsg() {
return getData().getString("Format.ShopFailed", "&cYou do not have %Points% points to purhcase this!");
}
@ConfigDataString(path = "Format.ShopPurchase")
@Getter
private String formatShopPurchaseMsg = "&aYou bought the %Identifier% for %Points% Points!";
public String getFormatShopNotPurchasable() {
return getData().getString("Format.ShopNotPurchasable", "&cThis item is not buyable!");
}
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line1")
@Getter
private String formatSignTopVoterSignLine1 = "TopVoter: %SiteName%";
public String getFormatShopPurchaseMsg() {
return getData().getString("Format.ShopPurchase", "&aYou bought the %Identifier% for %Points% Points!");
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line2")
@Getter
private String formatSignTopVoterSignLine2 = "#%position%";
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line3")
@Getter
private String formatSignTopVoterSignLine3 = "%player%";
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line4")
@Getter
private String formatSignTopVoterSignLine4 = "%votes% Votes";
}
@ConfigDataString(path = "Format.Signs.RightClickMessage")
@Getter
private String formatSignTopVoterSignRightClickMessage = "&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cin &c&l%SiteName%";
/**
* Gets the sign top voter sign line 1.
*
* @return the sign top voter sign line 1
*/
public String getFormatSignTopVoterSignLine1() {
return getData().getString("Format.Signs.TopVoterSign.Line1", "TopVoter: %SiteName%");
@ConfigDataString(path = "Format.TimeFormat")
@Getter
private String formatTimeFormat = "EEE, d MMM yyyy HH:mm";
}
@ConfigDataString(path = "Format.TopVoter.AllTime")
@Getter
private String formatTopVoterAllTime = "AllTime";
/**
* Gets the sign top voter sign line 2.
*
* @return the sign top voter sign line 2
*/
public String getFormatSignTopVoterSignLine2() {
return getData().getString("Format.Signs.TopVoterSign.Line2", "#%position%");
}
@ConfigDataString(path = "Format.TopVoter.Daily")
@Getter
private String formatTopVoterDaily = "Daily";
/**
* Gets the sign top voter sign line 3.
*
* @return the sign top voter sign line 3
*/
public String getFormatSignTopVoterSignLine3() {
return getData().getString("Format.Signs.TopVoterSign.Line3", "%player%");
@ConfigDataString(path = "Format.TopVoter.Monthly")
@Getter
private String formatTopVoterMonthly = "Monthly";
}
@ConfigDataString(path = "Format.TopVoterAwardMsg")
@Getter
private String formatTopVoterRewardMsg = "&aYou came in %place% in top voters of the month! Here is an award!";
/**
* Gets the sign top voter sign line 4.
*
* @return the sign top voter sign line 4
*/
public String getFormatSignTopVoterSignLine4() {
return getData().getString("Format.Signs.TopVoterSign.Line4", "%votes% Votes");
@ConfigDataString(path = "Format.TopVoter.Weekly")
@Getter
private String formatTopVoterWeekly = "Weekly";
}
@ConfigDataString(path = "Format.UserNotExist")
@Getter
private String formatUserNotExist = "&cUser does not exist: %player%";
/**
* Gets the sign top voter sign right click message.
*
* @return the sign top voter sign right click message
*/
public String getFormatSignTopVoterSignRightClickMessage() {
return getData().getString("Format.Signs.RightClickMessage",
"&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cin &c&l%SiteName%");
@ConfigDataString(path = "Format.InvalidCommand.Vote")
@Getter
private String formatInvalidCommandVote = "&4No valid arguments, see /vote help!";
}
/**
* Gets the time format.
*
* @return the time format
*/
public String getFormatTimeFormat() {
return getData().getString("Format.TimeFormat", "EEE, d MMM yyyy HH:mm");
}
public String getFormatTopVoterAllTime() {
return getData().getString("Format.TopVoter.AllTime", "AllTime");
}
public String getFormatTopVoterDaily() {
return getData().getString("Format.TopVoter.Daily", "Daily");
}
public String getFormatTopVoterMonthly() {
return getData().getString("Format.TopVoter.Monthly", "Monthly");
}
/**
* Gets the top voter reward msg.
*
* @return the top voter reward msg
*/
public String getFormatTopVoterRewardMsg() {
return getData().getString("Format.TopVoterAwardMsg",
"&aYou came in %place% in top voters of the month! Here is an award!");
}
public String getFormatTopVoterWeekly() {
return getData().getString("Format.TopVoter.Weekly", "Weekly");
}
public String getFormatUserNotExist() {
return getData().getString("Format.UserNotExist", "&cUser does not exist: %player%");
}
@ConfigDataString(path = "Format.InvalidCommand.AdminVote")
@Getter
private String formatInvalidCommandAdminVote = "&4No valid arguments, see /adminvote help!";
/**
* Gets the vote help.
@@ -728,133 +612,92 @@ public class Config extends YMLFile {
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<String>());
}
public boolean getGiveDefaultPermission() {
return getData().getBoolean("GiveDefaultPermission", true);
}
@ConfigDataBoolean(path = "GiveDefaultPermission")
@Getter
private boolean giveDefaultPermission = true;
public boolean getLoadTopVoter(TopVoter top) {
switch (top) {
case AllTime:
return getLoadTopVoterAllTime();
return isLoadTopVoterAllTime();
case Daily:
return getLoadTopVoterDaily();
return isLoadTopVoterDaily();
case Monthly:
return getLoadTopVoterMonthly();
return isLoadTopVoterMonthly();
case Weekly:
return getLoadTopVoterWeekly();
return isLoadTopVoterWeekly();
default:
return false;
}
}
public boolean getLoadTopVoterAllTime() {
return getData().getBoolean("LoadTopVoter.AllTime", true);
}
@ConfigDataBoolean(path = "LoadTopVoter.AllTime")
@Getter
private boolean loadTopVoterAllTime = true;
public boolean getLoadTopVoterDaily() {
return getData().getBoolean("LoadTopVoter.Daily", false);
}
@ConfigDataBoolean(path = "LoadTopVoter.Monthly")
@Getter
private boolean loadTopVoterMonthly = true;
public boolean getLoadTopVoterMonthly() {
return getData().getBoolean("LoadTopVoter.Monthly", true);
}
@ConfigDataBoolean(path = "LoadTopVoter.Daily")
@Getter
private boolean loadTopVoterDaily = false;
public boolean getLoadTopVoterWeekly() {
return getData().getBoolean("LoadTopVoter.Weekly", false);
}
@ConfigDataBoolean(path = "LoadTopVoter.Weekly")
@Getter
private boolean loadTopVoterWeekly = false;
public int getPointsOnVote() {
return getData().getInt("PointsOnVote", 1);
}
@ConfigDataInt(path = "PointsOnVote")
@Getter
private int pointsOnVote = 1;
public int getPurgeMin() {
return getData().getInt("PurgeMin", 90);
}
@ConfigDataInt(path = "PurgeMin")
@Getter
private int purgeMin = 90;
public boolean getPurgeOldData() {
return getData().getBoolean("PurgeOldData");
}
@ConfigDataBoolean(path = "PurgeOldData")
@Getter
private boolean purgeOldData = false;
/**
* Gets the request API default method.
*
* @return the request API default method
*/
public String getRequestAPIDefaultMethod() {
return getData().getString("RequestAPI.DefaultMethod", "Anvil");
}
@ConfigDataString(path = "RequestAPI.DefaultMethod")
@Getter
private String requestAPIDefaultMethod = "ANVIL";
/**
* Gets the request API disabled methods.
*
* @return the request API disabled methods
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getRequestAPIDisabledMethods() {
return (ArrayList<String>) getData().getList("RequestAPI.DisabledMethods", new ArrayList<String>());
}
@ConfigDataListString(path = "RequestAPI.DisabledMethods")
@Getter
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<String>();
/**
* Gets the store top voters daily.
*
* @return the store top voters daily
*/
public boolean getStoreTopVotersDaily() {
return getData().getBoolean("StoreTopVoters.Daily");
}
@ConfigDataBoolean(path = "StoreTopVoters.Daily")
@Getter
private boolean storeTopVotersDaily = false;
/**
* Gets the store top voters weekly.
*
* @return the store top voters weekly
*/
public boolean getStoreTopVotersWeekly() {
return getData().getBoolean("StoreTopVoters.Weekly");
}
@ConfigDataBoolean(path = "StoreTopVoters.Weekly")
@Getter
private boolean storeTopVotersWeekly = false;
public boolean getTopVoterAwardsTies() {
return getData().getBoolean("TopVoterAwardsTies", true);
}
@ConfigDataBoolean(path = "TopVoterAwardsTies")
@Getter
private boolean topVoterAwardsTies = true;
public boolean getTopVoterIgnorePermission() {
return getData().getBoolean("TopVoterIgnorePermission");
}
@ConfigDataBoolean(path = "TopVoterIgnorePermission")
@Getter
private boolean topVoterIgnorePermission = false;
/**
* Gets the enabled.
*
* @return the enabled
*/
public boolean getVoteRemindingEnabled() {
return getData().getBoolean("VoteReminding.Enabled");
}
@ConfigDataBoolean(path = "VoteReminding.Enabled")
@Getter
private boolean voteRemindingEnabled = true;
/**
* Gets the remind delay.
*
* @return the remind delay
*/
public int getVoteRemindingRemindDelay() {
return getData().getInt("VoteReminding.RemindDelay", 30);
}
@ConfigDataInt(path = "VoteReminding.RemindDelay")
@Getter
private int voteRemindingRemindDelay = 30;
/**
* Gets the remind on login.
*
* @return the remind on login
*/
public boolean getVoteRemindingRemindOnLogin() {
return getData().getBoolean("VoteReminding.RemindOnLogin");
}
@ConfigDataBoolean(path = "VoteReminding.RemindOnLogin")
@Getter
private boolean voteRemindingRemindOnLogin = false;
/**
* Gets the remind only once.
*
* @return the remind only once
*/
public boolean getVoteRemindingRemindOnlyOnce() {
return getData().getBoolean("VoteReminding.RemindOnlyOnce");
}
@ConfigDataBoolean(path = "VoteReminding.RemindOnlyOnce")
@Getter
private boolean voteRemindingRemindOnlyOnce = false;
/**
* Gets the rewards.
@@ -865,9 +708,9 @@ public class Config extends YMLFile {
return "VoteReminding.Rewards";
}
public String getVoteTopDefault() {
return getData().getString("VoteTopDefault", "Monthly");
}
@ConfigDataString(path = "VoteTopDefault")
@Getter
private String voteTopDefault = "Monthly";
@Override
public void loadValues() {
@@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
import com.bencodez.advancedcore.api.yml.YMLFile;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
@@ -47,12 +48,59 @@ public class ConfigVoteSites extends YMLFile {
setServiceSite(siteName, org);
setVoteURL(siteName, "VoteURL");
setVoteDelay(siteName, 24);
set(siteName, "DisplayItem.Material", "GRASS");
set(siteName, "DisplayItem.Material", "STONE");
set(siteName, "DisplayItem.Amount", 1);
set(siteName, "Rewards.Messages.Player", "&aThanks for voting on %ServiceSite%!");
plugin.loadVoteSites();
plugin.addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteSites." + siteName + ".Rewards") {
@Override
public void createSection(String key) {
plugin.getConfigVoteSites().createSection(key);
}
@Override
public ConfigurationSection getFileData() {
return plugin.getConfigVoteSites().getData();
}
@Override
public void save() {
plugin.getConfigVoteSites().saveData();
}
@Override
public void setData(String path, Object value) {
plugin.getConfigVoteSites().setValue(path, value);
}
});
plugin.addDirectlyDefinedRewards(
new DirectlyDefinedReward("VoteSites." + siteName + ".CoolDownEndRewards") {
@Override
public void createSection(String key) {
plugin.getConfigVoteSites().createSection(key);
}
@Override
public ConfigurationSection getFileData() {
return plugin.getConfigVoteSites().getData();
}
@Override
public void save() {
plugin.getConfigVoteSites().saveData();
}
@Override
public void setData(String path, Object value) {
plugin.getConfigVoteSites().setValue(path, value);
}
});
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.hasPermission("VotingPlugin.Admin.GenerateServiceSite") || p.isOp()) {
p.sendMessage(StringParser.getInstance().colorize("&cGenerating votesite for service site "
@@ -120,8 +168,8 @@ public class ConfigVoteSites extends YMLFile {
return getData(siteName).getString("ServiceSite");
}
public int getTimeOffSet(String siteName) {
return getData(siteName).getInt("TimeOffSet", 0);
public int getVoteDelayDailyHour(String siteName) {
return getData(siteName).getInt("VoteDelayDailyHour", 0);
}
/**
@@ -12,6 +12,8 @@ import com.bencodez.advancedcore.api.yml.YMLFile;
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataConfigurationSection;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataKeys;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
import com.bencodez.votingplugin.VotingPluginMain;
@@ -33,6 +35,10 @@ public class GUI extends YMLFile {
@Getter
private String bookVoteURLBookGUICanVoteColor = "GREEN";
@ConfigDataBoolean(path = "BOOK.VoteURLBookGUI.Manual")
@Getter
private boolean bookVoteURLBookGUIManual = false;
@ConfigDataString(path = "BOOK.VoteURLBookGUI.CanVoteText")
@Getter
private String bookVoteURLBookGUICanVoteText = "Click me";
@@ -42,6 +48,10 @@ public class GUI extends YMLFile {
private ArrayList<String> bookVoteURLBookGUILayout = ArrayUtils.getInstance()
.convert(new String[] { "&c%Sitename%", "[UrlText]" });
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.TopLayout")
@Getter
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<String>();
@ConfigDataString(path = "BOOK.VoteURLBookGUI.Title")
@Getter
private String bookVoteURLBookGUITitle = "&cVoteURL";
@@ -173,9 +183,9 @@ public class GUI extends YMLFile {
saveData();
}
public ConfigurationSection getCHESTBackButton() {
return getData().getConfigurationSection("CHEST.BackButton");
}
@ConfigDataConfigurationSection(path = "CHEST.BackButton")
@Getter
private ConfigurationSection CHESTBackButton;
public int getChestShopIdentifierCost(String identifier) {
return getData().getInt("CHEST.Shop." + identifier + ".Cost");
@@ -205,25 +215,25 @@ public class GUI extends YMLFile {
return getData().getConfigurationSection("CHEST.Shop." + identifier);
}
public ConfigurationSection getChestVoteBestDayBestItem() {
return getData().getConfigurationSection("CHEST.VoteBest.DayBest.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.DayBest.Item")
@Getter
private ConfigurationSection chestVoteBestDayBestItem;
public ConfigurationSection getChestVoteBestMonthBestItem() {
return getData().getConfigurationSection("CHEST.VoteBest.MonthBest.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.MonthBest.Item")
@Getter
private ConfigurationSection chestVoteBestMonthBestItem;
public String getChestVoteBestName() {
return getData().getString("CHEST.VoteBest.Name", "VoteBest: %player%");
}
@ConfigDataString(path = "CHEST.VoteBest.Name")
@Getter
private String chestVoteBestName = "VoteBest: %player%";
public ConfigurationSection getChestVoteBestWeekBestItem() {
return getData().getConfigurationSection("CHEST.VoteBest.WeekBest.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.WeekBest.Item")
@Getter
private ConfigurationSection chestVoteBestWeekBestItem;
public String getChestVoteGUIName() {
return getData().getString("CHEST.VoteGUIName", "&cVoteGUI: &c&l%player%");
}
@ConfigDataString(path = "CHEST.VoteGUIName")
@Getter
private String chestVoteGUIName = "&cVoteGUI: &c&l%player%";
/**
* Gets the vote GUI slot command.
@@ -251,26 +261,17 @@ public class GUI extends YMLFile {
return "CHEST.VoteGUI." + slot + "." + lastPath;
}
/**
* Gets the vote GUI slots.
*
* @return the vote GUI slots
*/
public Set<String> getChestVoteGUISlots() {
try {
return getData().getConfigurationSection("CHEST.VoteGUI").getKeys(false);
} catch (Exception ex) {
return new HashSet<String>();
}
}
@ConfigDataKeys(path = "CHEST.VoteGUI")
@Getter
private Set<String> chestVoteGUISlots = new HashSet<String>();
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
}
public ConfigurationSection getChestVoteTopCustomization() {
return getData().getConfigurationSection("CHEST.VoteTop.Customization");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.Customization")
@Getter
private ConfigurationSection chestVoteTopCustomization;
/**
* Gets the vote GUI slot slot.
@@ -282,57 +283,61 @@ public class GUI extends YMLFile {
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
}
public boolean getChestVoteLastBackButton() {
return getData().getBoolean("CHEST.VoteLast.BackButton");
}
@ConfigDataBoolean(path = "CHEST.VoteLast.BackButton")
@Getter
private boolean chestVoteLastBackButton = false;
public String getChestVoteLastLine() {
return getData().getString("CHEST.VoteLast.Line", "&6%timeSince%");
}
@ConfigDataString(path = "CHEST.VoteLast.Line")
@Getter
private String chestVoteLastLine = "&6%timeSince%";
public String getChestVoteLastName() {
return getData().getString("CHEST.VoteLast.Name", "VoteLast: %player%");
}
@ConfigDataString(path = "CHEST.VoteLast.Name")
@Getter
private String chestVoteLastName = "VoteLast: %player%";
public boolean getChestVoteNextBackButton() {
return getData().getBoolean("CHEST.VoteNext.BackButton");
}
@ConfigDataBoolean(path = "CHEST.VoteNext.BackButton")
@Getter
private boolean chestVoteNextBackButton = false;
@ConfigDataString(path = "CHEST.VoteNext.Name")
@Getter
private String chestVoteNextName = "VoteNext: %player%";
@ConfigDataString(path = "CHEST.VoteNext.Line")
@Getter
private String chestVoteNextLine = "%time%";
public String getChestVoteNextName() {
return getData().getString("CHEST.VoteNext.Name", "VoteNext: %player%");
}
public String getChestVoteNextLine() {
return getData().getString("CHEST.VoteNext.Line", "%time%");
}
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
}
public String getChestVoteRewardName() {
return getData().getString("CHEST.VoteRewardName", "VoteReward");
}
@ConfigDataString(path = "CHEST.VoteRewardName")
@Getter
private String chestVoteRewardName = "VoteReward";
public boolean getChestVoteShopBackButton() {
return getData().getBoolean("CHEST.VoteShopBackButton", true);
}
public boolean getChestVoteShopReopenGUIOnPurchase() {
return getData().getBoolean("CHEST.VoteShopReopenGUIOnPurchase", false);
}
@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 getChestVoteShopEnabled() {
return getData().getBoolean("CHEST.VoteShopEnabled", true);
public boolean getChestVoteShopHideOnNoPermission(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".HideOnNoPermission", true);
}
public String getChestVoteShopName() {
return getData().getString("CHEST.VoteShopName", "VoteShop");
}
@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);
@@ -359,94 +364,93 @@ public class GUI extends YMLFile {
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Weekly", false);
}
public boolean getChestVoteStreakBackButton() {
return getData().getBoolean("CHEST.VoteStreak.BackButton");
}
@ConfigDataBoolean(path = "CHEST.VoteStreak.BackButton")
@Getter
private boolean chestVoteStreakBackButton = false;
public ConfigurationSection getChestVoteStreakCurrentDayStreakItem() {
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentDayStreak.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentDayStreak.Item")
@Getter
private ConfigurationSection chestVoteStreakCurrentDayStreakItem;
public ConfigurationSection getChestVoteStreakCurrentMonthStreakItem() {
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentMonthStreak.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentMonthStreak.Item")
@Getter
private ConfigurationSection chestVoteStreakCurrentMonthStreakItem;
public ConfigurationSection getChestVoteStreakCurrentWeekStreakItem() {
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentWeekStreak.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentWeekStreak.Item")
@Getter
private ConfigurationSection chestVoteStreakCurrentWeekStreakItem;
public ConfigurationSection getChestVoteStreakHighestDayStreakItem() {
return getData().getConfigurationSection("CHEST.VoteStreak.HighestDayStreak.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestDayStreak.Item")
@Getter
private ConfigurationSection chestVoteStreakHighestDayStreakItem;
public ConfigurationSection getChestVoteStreakHighestMonthStreakItem() {
return getData().getConfigurationSection("CHEST.VoteStreak.HighestMonthStreak.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestMonthStreak.Item")
@Getter
private ConfigurationSection chestVoteStreakHighestMonthStreakItem;
public ConfigurationSection getChestVoteStreakHighestWeekStreakItem() {
return getData().getConfigurationSection("CHEST.VoteStreak.HighestWeekStreak.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestWeekStreak.Item")
@Getter
private ConfigurationSection chestVoteStreakHighestWeekStreakItem;
public String getChestVoteStreakName() {
return getData().getString("CHEST.VoteStreak.Name", "VoteStreak");
}
@ConfigDataString(path = "CHEST.VoteStreak.Name")
@Getter
private String chestVoteStreakName = "VoteStreak";
public boolean getChestVoteTodayBackButton() {
return getData().getBoolean("CHEST.VoteToday.BackButton");
}
@ConfigDataBoolean(path = "CHEST.VoteToday.BackButton")
@Getter
private boolean chestVoteTodayBackButton = false;
public String getChestVoteTodayName() {
return getData().getString("CHEST.VoteToday.Name", "VoteToday");
}
@ConfigDataString(path = "CHEST.VoteToday.Name")
@Getter
private String chestVoteTodayName = "VoteToday";
public boolean getChestVoteTopBackButton() {
return getData().getBoolean("CHEST.VoteTop.BackButton");
}
@ConfigDataBoolean(path = "CHEST.VoteTop.BackButton")
@Getter
private boolean chestVoteTopBackButton = false;
public String getChestVoteTopItemLore() {
return getData().getString("CHEST.VoteTop.Item.Lore", "&3&lVotes: &3%votes%");
}
@ConfigDataString(path = "CHEST.VoteTop.Item.Lore")
@Getter
private String chestVoteTopItemLore = "&3&lVotes: &3%votes%";
public String getChestVoteTopItemName() {
return getData().getString("CHEST.VoteTop.Item.Name", "&3&l%position%: &3%player%");
}
@ConfigDataString(path = "CHEST.VoteTop.Item.Name")
@Getter
private String chestVoteTopItemName = "&3&l%position%: &3%player%";
public String getChestVoteTopName() {
return getData().getString("CHEST.VoteTop.Name", "VoteTop %topvoter%");
}
@ConfigDataString(path = "CHEST.VoteTop.Name")
@Getter
private String chestVoteTopName = "VoteTop %topvoter%";
public boolean getChestVoteTopOpenMainGUIOnClick() {
return getData().getBoolean("CHEST.VoteTop.OpenMainGUIOnClick", true);
}
@ConfigDataBoolean(path = "CHEST.VoteTop.OpenMainGUIOnClick")
@Getter
private boolean chestVoteTopOpenMainGUIOnClick = true;
public boolean getChestVoteTopCloseGUIOnClick() {
return getData().getBoolean("CHEST.VoteTop.CloseGUIOnClick", true);
}
@ConfigDataBoolean(path = "CHEST.VoteTop.CloseGUIOnClick")
@Getter
private boolean chestVoteTopCloseGUIOnClick = true;
public int getChestVoteTopSize() {
return getData().getInt("CHEST.VoteTop.Size", 27);
}
@ConfigDataInt(path = "CHEST.VoteTop.Size")
@Getter
private int chestVoteTopSize = 27;
public ConfigurationSection getChestVoteTopSwitchItem() {
return getData().getConfigurationSection("CHEST.VoteTop.SwitchItem");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.SwitchItem")
@Getter
private ConfigurationSection chestVoteTopSwitchItem;
@SuppressWarnings("unchecked")
public ArrayList<String> getChestVoteTopSwitchItemTopVoters() {
return (ArrayList<String>) getData().getList("CHEST.VoteTop.SwitchItem.TopVoters", new ArrayList<String>());
}
@ConfigDataListString(path = "CHEST.VoteTop.SwitchItem.TopVoters")
@Getter
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<String>();
public ConfigurationSection getChestVoteTotalAllTimeTotalItem() {
return getData().getConfigurationSection("CHEST.VoteTotal.AllTimeTotal.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.AllTimeTotal.Item")
@Getter
private ConfigurationSection chestVoteTotalAllTimeTotalItem;
public boolean getChestVoteTotalBackButton() {
return getData().getBoolean("CHEST.VoteTotal.BackButton");
}
@ConfigDataBoolean(path = "CHEST.VoteTotal.BackButton")
@Getter
private boolean chestVoteTotalBackButton = false;
public ConfigurationSection getChestVoteTotalDayTotalItem() {
return getData().getConfigurationSection("CHEST.VoteTotal.DayTotal.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.DayTotal.Item")
@Getter
private ConfigurationSection chestVoteTotalDayTotalItem;
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
switch (top) {
@@ -464,60 +468,49 @@ public class GUI extends YMLFile {
}
}
public ConfigurationSection getChestVoteTotalMonthTotalItem() {
return getData().getConfigurationSection("CHEST.VoteTotal.MonthTotal.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.MonthTotal.Item")
@Getter
private ConfigurationSection chestVoteTotalMonthTotalItem;
public String getChestVoteTotalName() {
return getData().getString("CHEST.VoteTotal.Name", "VoteTotal: %player%");
}
@ConfigDataString(path = "CHEST.VoteTotal.Name")
@Getter
private String chestVoteTotalName = "VoteTotal: %player%";
public ConfigurationSection getChestVoteTotalWeekTotalItem() {
return getData().getConfigurationSection("CHEST.VoteTotal.WeekTotal.Item");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.WeekTotal.Item")
@Getter
private ConfigurationSection chestVoteTotalWeekTotalItem;
public int getChestVoteURLAllUrlsButtonSlot() {
return getData().getInt("CHEST.VoteURL.AllUrlsButton.Slot", -1);
}
@ConfigDataInt(path = "CHEST.VoteURL.AllUrlsButton.Slot")
@Getter
private int chestVoteURLAllUrlsButtonSlot = -1;
public int getChestVoteURLAllUrlsButtonStartSlot() {
return getData().getInt("CHEST.VoteURL.StartSlot", -1);
}
@ConfigDataInt(path = "CHEST.VoteURL.StartSlot")
@Getter
private int chestVoteURLAllUrlsButtonStartSlot = -1;
public ConfigurationSection getChestVoteURLAlreadyVotedAllUrlsButtonItemSection() {
if (getData().isConfigurationSection("CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem")) {
return getData().getConfigurationSection("CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem");
} else {
return getData().getConfigurationSection("CHEST.VoteURL.AlreadyVotedItem");
}
}
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem", secondPath = "CHEST.VoteURL.AlreadyVotedItem")
@Getter
private ConfigurationSection chestVoteURLAlreadyVotedAllUrlsButtonItemSection;
public ConfigurationSection getChestVoteURLAlreadyVotedItemSection() {
return getData().getConfigurationSection("CHEST.VoteURL.AlreadyVotedItem");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AlreadyVotedItem")
@Getter
private ConfigurationSection chestVoteURLAlreadyVotedItemSection;
public boolean getChestVoteURLBackButton() {
return getData().getBoolean("CHEST.VoteURL.BackButton");
}
@ConfigDataBoolean(path = "CHEST.VoteURL.BackButton")
@Getter
private boolean chestVoteURLBackButton = false;
public ConfigurationSection getChestVoteURLCanVoteAllUrlsButtonItemSection() {
if (getData().isConfigurationSection("CHEST.VoteURL.AllUrlsButton.CanVoteItem")) {
return getData().getConfigurationSection("CHEST.VoteURL.AllUrlsButton.CanVoteItem");
} else {
return getData().getConfigurationSection("CHEST.VoteURL.CanVoteItem");
}
}
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AllUrlsButton.CanVoteItem", secondPath = "CHEST.VoteURL.CanVoteItem")
@Getter
private ConfigurationSection chestVoteURLCanVoteAllUrlsButtonItemSection;
public ConfigurationSection getChestVoteURLCanVoteItemSection() {
return getData().getConfigurationSection("CHEST.VoteURL.CanVoteItem");
}
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.CanVoteItem")
@Getter
private ConfigurationSection chestVoteURLCanVoteItemSection;
public Set<String> getChestVoteURLExtraItems() {
if (getData().isConfigurationSection("CHEST.VoteURL.ExtraItems")) {
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems").getKeys(false);
}
return new HashSet<String>();
}
@ConfigDataKeys(path = "CHEST.VoteURL.ExtraItems")
@Getter
private Set<String> chestVoteURLExtraItems = new HashSet<String>();
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
@@ -534,69 +527,45 @@ public class GUI extends YMLFile {
return getData().getConfigurationSection("CHEST.VoteShopExtraItems." + item);
}
public Set<String> getChestGUIVoteShopExtraItems() {
if (getData().isConfigurationSection("CHEST.VoteShopExtraItems")) {
return getData().getConfigurationSection("CHEST.VoteShopExtraItems").getKeys(false);
}
return new HashSet<String>();
}
@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);
}
/**
* Gets the vote URL site name.
*
* @return the vote URL site name
*/
public String getChestVoteURLGUISiteName() {
return getData().getString("CHEST.VoteURL.SiteName", "&c%Name%");
}
@ConfigDataString(path = "CHEST.VoteURL.SiteName")
@Getter
private String chestVoteURLGUISiteName = "&c%Name%";
public String getChestVoteURLGUISiteNameCanVote() {
return getData().getString("CHEST.VoteURL.SiteNameCanVote", "&a%Name%");
}
@ConfigDataString(path = "CHEST.VoteURL.SiteNameCanVote")
@Getter
private String chestVoteURLGUISiteNameCanVote = "&a%Name%";
public String getChestVoteURLName() {
return getData().getString("CHEST.VoteURL.Name", "&cVoteURL");
}
@ConfigDataString(path = "CHEST.VoteURL.Name")
@Getter
private String chestVoteURLName = "&cVoteURL";
/**
* Gets the vote URL next vote.
*
* @return the vote URL next vote
*/
public String getChestVoteURLNextVote() {
return getData().getString("CHEST.VoteURL.NextVote", "&cCan Vote In: %Info%");
@ConfigDataString(path = "CHEST.VoteURL.NextVote")
@Getter
private String chestVoteURLNextVote = "&cCan Vote In: %Info%";
}
@ConfigDataString(path = "CHEST.VoteURL.SeeURL")
@Getter
private String chestVoteURLSeeURL = "&cClick to see URL";
/**
* Gets the vote URL see URL.
*
* @return the vote URL see URL
*/
public String getChestVoteURLSeeURL() {
return getData().getString("CHEST.VoteURL.SeeURL", "&cClick to see URL");
}
@ConfigDataString(path = "CHEST.VoteURLSite.Name")
@Getter
private String chestVoteURLSiteName = "VoteSite %site%";
public String getChestVoteURLSiteName() {
return getData().getString("CHEST.VoteURLSite.Name", "VoteSite %site%");
}
@ConfigDataString(path = "CHEST.VoteURL.URLText")
@Getter
private String chestVoteURLURLText = "%VoteUrl%";
public String getChestVoteURLURLText() {
return getData().getString("CHEST.VoteURL.URLText", "%VoteUrl%");
}
/**
* Gets the vote URL view all urls button enabled.
*
* @return the vote URL view all urls button enabled
*/
public boolean getChestVoteURLViewAllUrlsButtonEnabled() {
return getData().getBoolean("CHEST.VoteURL.ViewAllUrlsButtonEnabled");
}
@ConfigDataBoolean(path = "CHEST.VoteURL.ViewAllUrlsButtonEnabled")
@Getter
private boolean chestVoteURLViewAllUrlsButtonEnabled = false;
public boolean isChestVoteShopRequireConfirmation(String identifier) {
return getData().getBoolean("CHEST.Shop." + identifier + ".RequireConfirmation",
@@ -10,6 +10,10 @@ import com.bencodez.advancedcore.api.yml.YMLFile;
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataDouble;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataKeys;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -62,6 +66,22 @@ public class SpecialRewardsConfig extends YMLFile {
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
@Getter
private boolean votePartyResetExtraVotesMonthly = false;
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesWeekly")
@Getter
private boolean votePartyResetExtraVotesWeekly = false;
@ConfigDataString(path = "VoteParty.VoteReminderBroadcast")
@Getter
private String votePartyVoteReminderBroadcast = "%votesrequired% left to go, go vote!";
@ConfigDataListString(path = "VoteParty.VoteReminderAtVotes")
@Getter
private ArrayList<String> votePartyVoteReminderAtVotes = new ArrayList<String>();
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
@Getter
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<String>();
@Getter
private String votePartyRewardsPath = "VoteParty.Rewards";
@@ -103,29 +123,10 @@ public class SpecialRewardsConfig extends YMLFile {
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
}
/**
* Gets the cumulative votes.
*
* @return the cumulative votes
*/
public Set<String> getCumulativeVotes() {
try {
Set<String> set = getData().getConfigurationSection("Cumulative").getKeys(false);
if (set != null) {
return set;
}
return new HashSet<String>();
} catch (Exception ex) {
return new HashSet<String>();
}
}
@ConfigDataKeys(path = "Cumulative")
@Getter
private Set<String> cumulativeVotes = new HashSet<String>();
/**
* Gets the cumulative votes in same day.
*
* @param cumulative the cumulative
* @return the cumulative votes in same day
*/
@Deprecated
public boolean getCumulativeVotesInSameDay(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
@@ -159,19 +160,9 @@ public class SpecialRewardsConfig extends YMLFile {
return "DailyAwards." + path + ".Rewards";
}
/**
* Gets the daily possible reward places.
*
* @return the daily possible reward places
*/
public Set<String> getDailyPossibleRewardPlaces() {
try {
return getData().getConfigurationSection("DailyAwards").getKeys(false);
} catch (Exception ex) {
return new HashSet<String>();
}
}
@ConfigDataKeys(path = "DailyAwards")
@Getter
private Set<String> dailyPossibleRewardPlaces = new HashSet<String>();
/**
* Gets the milestone reward enabled.
@@ -193,22 +184,9 @@ public class SpecialRewardsConfig extends YMLFile {
return "MileStones." + milestones + ".Rewards";
}
/**
* Gets the milestone votes.
*
* @return the milestone votes
*/
public Set<String> getMilestoneVotes() {
try {
Set<String> set = getData().getConfigurationSection("MileStones").getKeys(false);
if (set != null) {
return set;
}
return new HashSet<String>();
} catch (Exception ex) {
return new HashSet<String>();
}
}
@ConfigDataKeys(path = "MileStones")
@Getter
private Set<String> milestoneVotes = new HashSet<String>();
public String getMonthlyAwardRewardsPath(String path) {
return "MonthlyAwards." + path + ".Rewards";
@@ -227,82 +205,64 @@ public class SpecialRewardsConfig extends YMLFile {
}
}
public boolean getResetMilestonesMonthly() {
return getData().getBoolean("ResetMilestonesMonthly");
}
@ConfigDataBoolean(path = "ResetMilestonesMonthly")
@Getter
private boolean resetMilestonesMonthly = false;
@ConfigDataString(path = "VoteParty.Broadcast")
@Getter
private String votePartyBroadcast = "";
public String getVotePartyBroadcast() {
return getData().getString("VoteParty.Broadcast", "");
}
@ConfigDataListString(path = "VoteParty.GlobalCommands", secondPath = "VoteParty.Commands")
@Getter
private ArrayList<String> votePartyGlobalCommands = new ArrayList<String>();
@SuppressWarnings("unchecked")
public ArrayList<String> getVotePartyGlobalCommands() {
return (ArrayList<String>) getData().getList("VoteParty.GlobalCommands",
(ArrayList<String>) getData().getList("VoteParty.Commands", new ArrayList<String>()));
}
@ConfigDataBoolean(path = "VoteParty.CountFakeVotes")
@Getter
private boolean votePartyCountFakeVotes = true;
public boolean getVotePartyCountFakeVotes() {
return getData().getBoolean("VoteParty.CountFakeVotes", true);
}
@ConfigDataBoolean(path = "VoteParty.CountOfflineVotes")
@Getter
private boolean votePartyCountOfflineVotes = true;
public boolean getVotePartyCountOfflineVotes() {
return getData().getBoolean("VoteParty.CountOfflineVotes", true);
}
@ConfigDataBoolean(path = "VoteParty.Enabled")
@Getter
private boolean votePartyEnabled = false;
/**
* Gets the vote party enabled.
*
* @return the vote party enabled
*/
public boolean getVotePartyEnabled() {
return getData().getBoolean("VoteParty.Enabled");
}
@ConfigDataBoolean(path = "VoteParty.GiveAllPlayers")
@Getter
private boolean votePartyGiveAllPlayers = false;
/**
* Gets the vote party give all players.
*
* @return the vote party give all players
*/
public boolean getVotePartyGiveAllPlayers() {
return getData().getBoolean("VoteParty.GiveAllPlayers");
}
@ConfigDataInt(path = "VoteParty.IncreaseVotesRquired")
@Getter
private int votePartyIncreaseVotesRequired = 0;
public int getVotePartyIncreaseVotesRquired() {
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
}
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerDay")
@Getter
private boolean votePartyOnlyOncePerDay = false;
public boolean getVotePartyOnlyOncePerDay() {
return getData().getBoolean("VoteParty.OnlyOncePerDay");
}
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerWeek")
@Getter
private boolean votePartyOnlyOncePerWeek = false;
public boolean getVotePartyOnlyOncePerWeek() {
return getData().getBoolean("VoteParty.OnlyOncePerWeek");
}
@ConfigDataBoolean(path = "VoteParty.ResetEachDay")
@Getter
private boolean votePartyResetEachDay = false;
public boolean getVotePartyResetEachDay() {
return getData().getBoolean("VoteParty.ResetEachDay");
}
@ConfigDataBoolean(path = "VoteParty.ResetMonthly")
@Getter
private boolean votePartyResetMonthly = false;
public boolean getVotePartyResetMontly() {
return getData().getBoolean("VoteParty.ResetMonthly");
}
@ConfigDataBoolean(path = "VoteParty.ResetWeekly")
@Getter
private boolean votePartyResetWeekly = false;
public boolean getVotePartyResetWeekly() {
return getData().getBoolean("VoteParty.ResetWeekly");
}
@ConfigDataInt(path = "VoteParty.UserVotesRequired")
@Getter
private int votePartyUserVotesRequired = 0;
public int getVotePartyUserVotesRequired() {
return getData().getInt("VoteParty.UserVotesRequired");
}
/**
* Gets the vote party votes required.
*
* @return the vote party votes required
*/
public int getVotePartyVotesRequired() {
return getData().getInt("VoteParty.VotesRequired");
}
@ConfigDataInt(path = "VoteParty.VotesRequired")
@Getter
private int votePartyVotesRequired = 0;
public boolean getVoteStreakRewardEnabled(String type, String s) {
return getData().getBoolean("VoteStreak." + type + "." + s + ".Enabled");
@@ -328,18 +288,9 @@ public class SpecialRewardsConfig extends YMLFile {
return "WeeklyAwards." + path + ".Rewards";
}
/**
* Gets the weekly possible reward places.
*
* @return the weekly possible reward places
*/
public Set<String> getWeeklyPossibleRewardPlaces() {
try {
return getData().getConfigurationSection("WeeklyAwards").getKeys(false);
} catch (Exception ex) {
return new HashSet<String>();
}
}
@ConfigDataKeys(path = "WeeklyAwards")
@Getter
private Set<String> weeklyPossibleRewardPlaces = new HashSet<String>();
@Override
public void loadValues() {
@@ -1,6 +1,8 @@
package com.bencodez.votingplugin.cooldown;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -14,12 +16,15 @@ import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
import com.bencodez.advancedcore.api.user.UserStartup;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
public class CoolDownCheck implements Listener {
private VotingPluginMain plugin;
@@ -33,6 +38,7 @@ public class CoolDownCheck implements Listener {
this.timer = Executors.newScheduledThreadPool(1);
}
@Getter
private ScheduledExecutorService timer;
private boolean cooldownCheckEnabled = false;
@@ -47,45 +53,56 @@ public class CoolDownCheck implements Listener {
}
public void check(UUID uuid) {
check(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
if (!user.isOnline()) {
user.dontCache();
}
check(user);
}
public void checkPerSite(UUID uuid) {
checkPerSite(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
if (!user.isOnline()) {
user.dontCache();
}
checkPerSite(user);
}
public void vote(VotingPluginUser user, VoteSite site) {
if (cooldownCheckEnabled) {
schedule(user);
schedule(user, true);
}
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
user.setCoolDownCheckSite(site, Boolean.FALSE);
schedulePerSite(user);
schedulePerSite(user, true);
}
}
public void check(VotingPluginUser user) {
public synchronized void check(VotingPluginUser user) {
boolean coolDownCheck = user.getCoolDownCheck();
if (user.canVoteAll() && coolDownCheck) {
user.setCoolDownCheck(false);
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
plugin.getServer().getPluginManager().callEvent(event);
allSiteTasks.remove(user.getJavaUUID());
} else if (!coolDownCheck) {
schedule(user);
if (coolDownCheck) {
if (user.canVoteAll()) {
user.setCoolDownCheck(false);
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
plugin.getServer().getPluginManager().callEvent(event);
allSiteTasks.remove(user.getJavaUUID());
} else {
schedulePerSite(user, false);
}
}
}
public synchronized void checkPerSite(VotingPluginUser user) {
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
HashMap<VoteSite, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
boolean changed = false;
for (VoteSite site : plugin.getVoteSites()) {
if (user.canVoteSite(site)) {
if (!coolDownChecks.containsKey(site) || !coolDownChecks.get(site).booleanValue()) {
coolDownChecks.put(site, Boolean.TRUE);
for (VoteSite site : plugin.getVoteSitesEnabled()) {
if (!coolDownChecks.containsKey(site.getKey()) || !coolDownChecks.get(site.getKey()).booleanValue()) {
if (user.canVoteSite(site)) {
coolDownChecks.put(site.getKey(), Boolean.TRUE);
changed = true;
plugin.extraDebug("Triggering votesitecooldownend event for " + user.getUUID());
PlayerVoteSiteCoolDownEndEvent event = new PlayerVoteSiteCoolDownEndEvent(user, site);
plugin.getServer().getPluginManager().callEvent(event);
}
@@ -94,63 +111,72 @@ public class CoolDownCheck implements Listener {
if (changed) {
user.setCoolDownCheckSite(coolDownChecks);
}
}
schedulePerSite(user);
schedulePerSite(user, false);
}
}
public void schedulePerSite(VotingPluginUser user) {
final UUID uuid = UUID.fromString(user.getUUID());
long time = user.getNextTimeFirstSiteAvailable();
if (time > 0) {
public void schedulePerSite(VotingPluginUser user, boolean force) {
if (user.getSitesVotedOn() > 0 || force) {
final UUID uuid = UUID.fromString(user.getUUID());
long time = user.getNextTimeFirstSiteAvailable();
if (perSiteTasks.containsKey(uuid)) {
perSiteTasks.get(uuid).cancel(false);
perSiteTasks.remove(uuid);
}
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time);
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
if (time > 0) {
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time + " seconds");
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
@Override
public void run() {
if (plugin != null && plugin.isEnabled()) {
checkPerSite(uuid);
@Override
public void run() {
if (plugin != null && plugin.isEnabled()) {
checkPerSite(uuid);
}
}
}
}, time + 2, TimeUnit.SECONDS);
perSiteTasks.put(uuid, scheduledFuture);
}, time + 2, TimeUnit.SECONDS);
perSiteTasks.put(uuid, scheduledFuture);
} else {
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling cooldown check");
}
}
}
public void schedule(VotingPluginUser user) {
final UUID uuid = UUID.fromString(user.getUUID());
long time = user.getNextTimeAllSitesAvailable();
if (time > 0) {
user.setCoolDownCheck(true);
public void schedule(VotingPluginUser user, boolean force) {
if (user.getSitesVotedOn() > 0 || force) {
final UUID uuid = UUID.fromString(user.getUUID());
long time = user.getNextTimeAllSitesAvailable();
if (allSiteTasks.containsKey(uuid)) {
allSiteTasks.get(uuid).cancel(false);
allSiteTasks.remove(uuid);
}
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
if (time > 0) {
user.setCoolDownCheck(true);
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
@Override
public void run() {
check(uuid);
}
}, time + 2, TimeUnit.SECONDS);
allSiteTasks.put(uuid, scheduledFuture);
@Override
public void run() {
if (plugin != null && plugin.isEnabled()) {
check(uuid);
}
}
}, time + 2, TimeUnit.SECONDS);
allSiteTasks.put(uuid, scheduledFuture);
} else {
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling cooldown check");
}
}
}
public void load() {
plugin.addUserStartup(new UserStartup() {
@Override
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
user.dontCache();
if (cooldownCheckEnabled) {
check(user);
}
@@ -169,6 +195,32 @@ public class CoolDownCheck implements Listener {
}
});
}
public void checkAllVoteSite(VoteSite site) {
plugin.getLogger().info("Checking vote cooldown rewards for all players: " + site.getKey());
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
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);
checkPerSite(user);
user.clearTempCache();
user = null;
}
}
}
cols.clear();
cols = null;
plugin.getLogger().info("Finished checking vote cooldown rewards for all players: " + site.getKey());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@@ -180,7 +232,8 @@ public class CoolDownCheck implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
new RewardOptions());
new RewardOptions().addPlaceholder("sitename", event.getSite().getDisplayName()).addPlaceholder("url",
event.getSite().getVoteURL(false)));
}
}
@@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -72,6 +73,10 @@ public class ServerData {
return getData().getStringList("AutoCachePlaceholders");
}
public List<String> getDisabledReminders() {
return getData().getStringList("DisabledReminders");
}
public synchronized void addServiceSite(String site) {
ArrayList<String> l = getServiceSites();
if (!getServiceSites().contains(site)) {
@@ -327,6 +332,15 @@ public class ServerData {
saveData();
}
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
ArrayList<String> uuids = new ArrayList<String>();
for (UUID uuid : disabledReminders) {
uuids.add(uuid.toString());
}
getData().set("DisabledReminders", uuids);
saveData();
}
/**
* Update values.
*/
@@ -55,17 +55,22 @@ public class PlayerPostVoteEvent extends Event {
@Getter
@Setter
private VoteSite voteSite;
@Getter
@Setter
private long voteTime = 0;
@Getter
@Setter
private VotingPluginUser votingPluginUser;
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee) {
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee, long voteTime) {
super(true);
this.user = user;
this.voteSite = voteSite;
this.realVote = realVote;
this.forceBungee = forceBungee;
this.voteTime = voteTime;
}
/*
@@ -7,7 +7,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.signs.SignHandler;
@@ -39,7 +38,7 @@ public class BlockBreak implements Listener {
if (event.getBlock().getState() instanceof Sign) {
Sign s = (Sign) event.getBlock().getState();
final Location loc = s.getLocation();
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1,6 +1,5 @@
package com.bencodez.votingplugin.listeners;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.vexsoftware.votifier.model.Vote;
@@ -9,7 +8,7 @@ import com.vexsoftware.votifier.model.VotifierEvent;
public class BungeeVotifierEvent {
public void send(VotingPluginMain plugin, PlayerVoteEvent event) {
plugin.debug("Triggering vote event");
BukkitScheduler.runTask(plugin, new Runnable() {
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -46,12 +46,13 @@ public class PlayerJoinEvent implements Listener {
user.loginRewards();
plugin.getPlaceholders().onUpdate(user);
plugin.getPlaceholders().onUpdate(user, true);
if (plugin.getBungeeSettings().isUseBungeecoord()
&& plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
plugin.getPluginMessaging().sendPluginMessage("Login", user.getPlayerName(), user.getUUID(),
plugin.getBungeeSettings().getServer());
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.REDIS))) {
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("Login", user.getPlayerName(),
user.getUUID(), plugin.getBungeeSettings().getServer());
}
}
@@ -83,6 +84,7 @@ public class PlayerJoinEvent implements Listener {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
user.dontCache();
user.logoutRewards();
plugin.getPlaceholders().onLogout(user);
}
});
}
@@ -12,12 +12,12 @@ import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.events.PlayerPostVoteEvent;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.user.VotingPluginUser;
// TODO: Auto-generated Javadoc
@@ -91,7 +91,7 @@ public class PlayerVoteListener implements Listener {
services.add(site.getServiceSite());
}
plugin.getLogger()
.warning("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
.warning("Currently set service sites: " + ArrayUtils.getInstance().makeStringList(services));
}
return;
}
@@ -115,8 +115,17 @@ public class PlayerVoteListener implements Listener {
}
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
return;
if (!event.isRealVote()) {
plugin.getLogger().info(user.getPlayerName() + " did a not real vote, bypassing WaitUntilVoteDelay");
} else {
if (user.hasPermission("VotingPlugin.BypassWaitUntilVoteDelay")) {
plugin.getLogger()
.info(user.getPlayerName() + " has bypass permission for WaitUntilVoteDelay, bypassing");
} else {
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
return;
}
}
}
final String uuid = user.getUUID();
@@ -133,7 +142,7 @@ public class PlayerVoteListener implements Listener {
// broadcast vote if enabled in config
if (plugin.getConfigFile().isBroadcastVotesEnabled()
&& (plugin.getBungeeSettings().isBungeeBroadcast() || !event.isBungee())) {
if (!plugin.getConfigFile().getFormatBroadcastWhenOnline() || user.isOnline()) {
if (!plugin.getConfigFile().isFormatBroadcastWhenOnline() || user.isOnline()) {
voteSite.broadcastVote(user);
}
}
@@ -143,11 +152,14 @@ public class PlayerVoteListener implements Listener {
plugin.getBroadcastHandler().onVote(playerName);
}
long voteTime = 0;
// update last vote time
if (event.getTime() != 0) {
user.setTime(voteSite, event.getTime());
voteTime = event.getTime();
} else {
user.setTime(voteSite);
voteTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
}
// try logging to file
@@ -164,7 +176,7 @@ public class PlayerVoteListener implements Listener {
plugin.getSpecialRewards().checkFirstVote(user, event.isForceBungee());
plugin.getSpecialRewards().checkFirstVoteToday(user, event.isForceBungee());
if (user.isReminded() && plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
if (user.isReminded() && plugin.getConfigFile().isVoteRemindingRemindOnlyOnce()) {
user.setReminded(false);
}
@@ -183,21 +195,43 @@ public class PlayerVoteListener implements Listener {
user.closeInv();
}
} else {
user.addOfflineVote(voteSite.getKey());
plugin.debug("Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
if (!plugin.getConfigFile().isOfflineVotesLimitEnabled()
|| user.getNumberOfOfflineVotes(voteSite) <= plugin.getConfigFile().getOfflineVotesLimitAmount()) {
user.addOfflineVote(voteSite.getKey());
plugin.debug(
"Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
} else {
plugin.debug("Not setting offline vote, offline vote limit reached");
}
}
// add to total votes
if ((plugin.getConfigFile().isCountFakeVotes() || event.isRealVote()) && event.isAddTotals()) {
if (plugin.getConfigFile().isAddTotals()) {
user.addTotal();
user.addTotalDaily();
user.addTotalWeekly();
if (plugin.getConfigFile().isAddTotalsOffline() || user.isOnline()) {
user.addTotal();
user.addTotalDaily();
user.addTotalWeekly();
}
}
user.addPoints();
}
user.checkDayVoteStreak(event.isForceBungee());
if (plugin.getConfigFile().isLimitMonthlyVotes()) {
int value = 0;
if (event.isBungee()) {
value = event.getBungeeTextTotals().getMonthTotal();
} else {
value = user.getTotal(TopVoter.Monthly);
}
LocalDateTime cTime = plugin.getTimeChecker().getTime();
int days = cTime.getDayOfMonth();
if (value >= days * plugin.getVoteSitesEnabled().size()) {
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSitesEnabled().size());
}
}
// other rewards
plugin.getSpecialRewards().checkAllSites(user, event.isForceBungee());
plugin.getSpecialRewards().checkAlmostAllSites(user, event.isForceBungee());
@@ -208,22 +242,26 @@ public class PlayerVoteListener implements Listener {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)) {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if (Bukkit.getOnlinePlayers().size() > 0) {
plugin.getPluginMessaging().sendPluginMessage("VoteUpdate", uuid);
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("VoteUpdate", uuid);
}
}
}, 40);
}, 2);
}
}
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
event.isForceBungee());
event.isForceBungee(), voteTime);
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
if (user.isOnline()) {
plugin.getPlaceholders().onUpdate(user, true);
}
if (!user.isOnline()) {
user.clearCache();
}
@@ -6,7 +6,6 @@ import org.bukkit.event.block.SignChangeEvent;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -47,7 +46,7 @@ public class SignChange implements Listener {
plugin.getServerData().addSign(event.getBlock().getLocation(), event.getLine(2),
Integer.parseInt(event.getLine(1)));
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&aAdded sign!"));
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -77,7 +77,14 @@ public class VotiferEvent implements Listener {
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled, this means you aren't setup correctly for those methods, please check: https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups");
return;
}
String voteSiteNameStr = plugin.getVoteSiteName(false, voteSite);
String matchSite = "";
if (plugin.getConfigFile().isAdvancedServiceSiteHandling()) {
if (plugin.getServiceSiteHandler() != null) {
matchSite = plugin.getServiceSiteHandler().matchReverse(voteSite);
}
}
String voteSiteNameStr = plugin.getVoteSiteName(false, voteSite, matchSite);
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
boolean createSite = false;
@@ -89,6 +96,8 @@ public class VotiferEvent implements Listener {
createSite = true;
}
String serviceSite = voteSite;
if (plugin.getConfigFile().isAutoCreateVoteSites() && createSite) {
plugin.getLogger().warning("VoteSite with service site '" + voteSiteNameStr
+ "' does not exist, attempting to generate...");
@@ -107,7 +116,7 @@ public class VotiferEvent implements Listener {
return;
}
String voteSiteName = plugin.getVoteSiteName(true, voteSite);
String voteSiteName = plugin.getVoteSiteName(true, serviceSite, matchSite);
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName, true),
voteUsername, voteSite, true);
@@ -64,7 +64,7 @@ public class VoteSite {
@Getter
@Setter
private double timeOffSet;
private int voteDelayDailyHour;
@Getter
@Setter
@@ -133,6 +133,8 @@ public class VoteSite {
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
placeholders.put("sitename", getDisplayName());
placeholders.put("servicesite", getServiceSite());
placeholders.put("votesrequired", "" + plugin.getVoteParty().getVotesRequired());
placeholders.put("neededvotes", "" + plugin.getVoteParty().getNeededVotes());
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
ArrayList<Player> players = new ArrayList<Player>();
@@ -230,7 +232,7 @@ public class VoteSite {
voteDelayDaily = plugin.getConfigVoteSites().getVoteSiteResetVoteDelayDaily(key);
giveOffline = plugin.getConfigVoteSites().getVoteSiteGiveOffline(key);
waitUntilVoteDelay = plugin.getConfigVoteSites().getWaitUntilVoteDelay(key);
timeOffSet = plugin.getConfigVoteSites().getTimeOffSet(key);
voteDelayDailyHour = plugin.getConfigVoteSites().getVoteDelayDailyHour(key);
hidden = plugin.getConfigVoteSites().getVoteSiteHidden(key);
ignoreCanVote = plugin.getConfigVoteSites().getVoteSiteIgnoreCanVote(key);
}
@@ -247,7 +249,7 @@ public class VoteSite {
str += ", VoteDelayDaily: " + isVoteDelayDaily();
str += ", IsWaitUntilVoteDelay: " + isWaitUntilVoteDelay();
str += ", ServiceSite: " + getServiceSite();
str += ", TimeOffSet:" + getTimeOffSet();
str += ", VoteDelayDailyHour:" + getVoteDelayDailyHour();
str += ", Url: " + getVoteURL();
str += ", IgnoreCanVote: " + isIgnoreCanVote();
str += ", Hidden: " + isHidden();
@@ -3,6 +3,8 @@ package com.bencodez.votingplugin.placeholders;
import java.text.NumberFormat;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.TemporalField;
import java.time.temporal.WeekFields;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -55,7 +57,7 @@ public class PlaceHolders {
onUpdate();
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
for (Player player : Bukkit.getOnlinePlayers()) {
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(player));
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(player), player.isOnline());
}
}
}
@@ -286,6 +288,20 @@ public class PlaceHolders {
}
}.withDescription("Returns true/false if user has broadcast disabled").updateDataKey("DisableBroadcast"));
placeholders.add(new PlaceHolder<VotingPluginUser>("DisableReminders") {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
if (plugin.getVoteReminding().getRemindersEnabled().containsKey(user.getJavaUUID())) {
if (!plugin.getVoteReminding().getRemindersEnabled().get(user.getJavaUUID()).booleanValue()) {
return "True";
}
}
return "False";
}
}.withDescription("Returns true/false if user has reminders disabled"));
placeholders.add(new PlaceHolder<VotingPluginUser>("MilestoneCount") {
@Override
@@ -471,7 +487,7 @@ public class PlaceHolders {
}
long smallest = -1;
HashMap<Long, VoteSite> times = new HashMap<Long, VoteSite>();
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
long t = user.voteNextDurationTime(site);
if (smallest == -1) {
smallest = t;
@@ -491,7 +507,15 @@ public class PlaceHolders {
}
}.withDescription("How long until user can vote on anysite").updateDataKey("LastVotes"));
for (final VoteSite voteSite : plugin.getVoteSites()) {
placeholders.add(new PlaceHolder<VotingPluginUser>("SitesAvailable") {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
return "" + user.getSitesNotVotedOn();
}
}.withDescription("Get number of sites available to be voted on").updateDataKey("LastVotes"));
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
placeholders.add(new CalculatingPlaceholder<VotingPluginUser>("Next_" + voteSite.getKey()) {
@Override
@@ -607,6 +631,59 @@ public class PlaceHolders {
}
}.withDescription("Get user top voter position"));
if (plugin.getGui().isLastMonthGUI()) {
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_LastMonth_Position") {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
int num = 1;
UUID toMatch = UUID.fromString(user.getUUID());
for (Entry<TopVoterPlayer, Integer> entry : plugin.getLastMonthTopVoter().entrySet()) {
if (entry.getKey().getUuid().equals(toMatch)) {
return "" + num;
}
num++;
}
return "";
}
}.withDescription("Get user top voter position for lastmonth"));
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_LastMonth_") {
@Override
public String placeholderRequest(String identifier) {
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
return null;
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
for (Entry<TopVoterPlayer, Integer> entry : plugin.getLastMonthTopVoter().entrySet()) {
if (num == number) {
return entry.getKey().getPlayerName();
}
num++;
}
return "";
}
}.useStartsWith().withDescription("Get user at position in last month top voter"));
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_LastMonthVotes_") {
@Override
public String placeholderRequest(String identifier) {
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
for (Entry<TopVoterPlayer, Integer> entry : plugin.getLastMonthTopVoter().entrySet()) {
if (num == number) {
return "" + entry.getValue().intValue();
}
num++;
}
return "";
}
}.useStartsWith().withDescription("Get user votes at position in last month top voter"));
}
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Month_") {
@Override
@@ -785,7 +862,7 @@ public class PlaceHolders {
if (plugin.getBungeeHandler() != null) {
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyCurrent());
}
return "" + 0;
return "-1";
}
}.withDescription("Current amount of bungee voteparty votes"));
@@ -797,7 +874,7 @@ public class PlaceHolders {
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyRequired()
- plugin.getBungeeHandler().getBungeeVotePartyCurrent());
}
return "" + 0;
return "-1";
}
}.withDescription("Voteparty bungee votes needed"));
@@ -808,7 +885,7 @@ public class PlaceHolders {
if (plugin.getBungeeHandler() != null) {
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyRequired());
}
return "" + 0;
return "-1";
}
}.withDescription("Amount of votes needed for bungee voteparty"));
@@ -864,7 +941,7 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime now = plugin.getTimeChecker().getTime();
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0);
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0)
.withMinute(0);
@@ -898,6 +975,82 @@ public class PlaceHolders {
}
}.withDescription("Time until plugin time day changes"));
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("TimeUntilWeekReset") {
@Override
public String placeholderRequest(String identifier) {
LocalDateTime now = plugin.getTimeChecker().getTime();
LocalDateTime newWeek = plugin.getTimeChecker().getTime().withHour(0).withMinute(0);
TemporalField woy = WeekFields.of(Locale.getDefault()).weekOfWeekBasedYear();
int weekNumber = newWeek.get(woy);
int newWeekNumber = weekNumber;
while (weekNumber == newWeekNumber) {
newWeek = newWeek.plusDays(1);
newWeekNumber = newWeek.get(woy);
}
String timeMsg = "%days% Days %hours% Hours %minutes% Minutes";
Duration dur = Duration.between(now, newWeek);
int diffDays = (int) (dur.getSeconds() / (60 * 60 * 24));
int diffHours = (int) (dur.getSeconds() / (60 * 60) - diffDays * 24);
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60 - diffDays * 24 * 60;
if (diffHours < 0) {
diffHours = diffHours * -1;
}
if (diffHours >= 24) {
diffHours = diffHours - 24;
}
if (diffMinutes < 0) {
diffMinutes = diffMinutes * -1;
}
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%days%", Integer.toString(diffDays));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
Long.toString(diffMinutes));
return timeMsg;
}
}.withDescription("Time until plugin time week changes"));
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("TimeUntilMonthReset") {
@Override
public String placeholderRequest(String identifier) {
LocalDateTime now = plugin.getTimeChecker().getTime();
LocalDateTime newMonth = plugin.getTimeChecker().getTime().plusMonths(1).withDayOfMonth(1).withHour(0)
.withMinute(0);
String timeMsg = "%days% Days %hours% Hours %minutes% Minutes";
Duration dur = Duration.between(now, newMonth);
int diffDays = (int) (dur.getSeconds() / (60 * 60 * 24));
int diffHours = (int) (dur.getSeconds() / (60 * 60) - diffDays * 24);
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60 - diffDays * 24 * 60;
if (diffHours < 0) {
diffHours = diffHours * -1;
}
if (diffHours >= 24) {
diffHours = diffHours - 24;
}
if (diffMinutes < 0) {
diffMinutes = diffMinutes * -1;
}
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%days%", Integer.toString(diffDays));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
Long.toString(diffMinutes));
return timeMsg;
}
}.withDescription("Time until plugin time month changes"));
Set<String> placeholdersSet = new HashSet<String>();
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
if (getCacheLevel().equals(PlaceholderCacheLevel.AUTO)) {
@@ -934,34 +1087,39 @@ public class PlaceHolders {
vpUser.dontCache();
}
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder instanceof CalculatingPlaceholder<?>) {
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache()) {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
for (String ident : placeholder.getCache().keySet()) {
String value = placeholder.placeholderRequest(vpUser, ident);
cPlaceholder.getCacheData().put(user.getJavaUUID(),
cPlaceholder.placeholderDataRequest(vpUser, ident));
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
plugin.devDebug("Updated calculating placeholder cache for " + vpUser.getUUID()
+ " on " + key + " with " + value);
if (placeholder.isUsesCache()) {
if (placeholder.isCached(placeholder.getIdentifier(), user.getJavaUUID())
|| !getCacheLevel().onlineOnly() || user.isOnline()) {
if (placeholder instanceof CalculatingPlaceholder<?>) {
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache()) {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
for (String ident : placeholder.getCache().keySet()) {
String value = placeholder.placeholderRequest(vpUser, ident);
cPlaceholder.getCacheData().put(user.getJavaUUID(),
cPlaceholder.placeholderDataRequest(vpUser, ident));
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
plugin.devDebug("Updated calculating placeholder cache for "
+ vpUser.getUUID() + " on " + key + " with " + value);
}
}
}
}
}
}
} else {
if (placeholder.isUsesCache()) {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
for (String ident : placeholder.getCache().keySet()) {
String value = placeholder.placeholderRequest(vpUser, ident);
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID() + " on "
+ key + " with " + value);
} else {
if (placeholder.isUsesCache()) {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
for (String ident : placeholder.getCache().keySet()) {
String value = placeholder.placeholderRequest(vpUser, ident);
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID()
+ " on " + key + " with " + value);
}
}
}
}
}
}
@@ -972,48 +1130,58 @@ public class PlaceHolders {
}
public void onVotePartyUpdate() {
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
if (placeholder.isUsesCache()) {
if (placeholder.getIdentifier().startsWith("VoteParty")) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
}
}
}
}
/*
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { if
* (placeholder.getIdentifier().startsWith("VoteParty")) { for (String ident :
* placeholder.getCache().keySet()) { placeholder.getCache().put(ident,
* placeholder.placeholderRequest(ident)); } } } }
*/
}
public void onBungeeVotePartyUpdate() {
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
if (placeholder.isUsesCache()) {
if (placeholder.getIdentifier().startsWith("BungeeVoteParty")) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
}
/*
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { if
* (placeholder.getIdentifier().startsWith("BungeeVoteParty")) { for (String
* ident : placeholder.getCache().keySet()) { placeholder.getCache().put(ident,
* placeholder.placeholderRequest(ident)); } } } }
*/
}
public void onLogout(VotingPluginUser user) {
if (plugin.getPlaceholders().getCacheLevel().onlineOnly()) {
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.isUsesCache()) {
placeholder.clearCachePlayer(user.getJavaUUID());
}
}
}
}
public void onUpdate(VotingPluginUser user) {
public void onUpdate(VotingPluginUser user, boolean login) {
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder instanceof CalculatingPlaceholder<?>) {
if (placeholder.isUsesCache()) {
if (placeholder.isCached(placeholder.getIdentifier(), user.getJavaUUID()) || login) {
if (placeholder instanceof CalculatingPlaceholder<?>) {
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
cPlaceholder.getCacheData().put(user.getJavaUUID(),
cPlaceholder.placeholderDataRequest(user, ident));
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
}
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
cPlaceholder.getCacheData().put(user.getJavaUUID(),
cPlaceholder.placeholderDataRequest(user, ident));
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
}
}
} else {
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
}
} else {
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
}
}
}
}
}
@@ -1026,15 +1194,15 @@ public class PlaceHolders {
if (toCache.startsWith("votingplugin")) {
toCache = toCache.substring("votingplugin_".length());
}
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
if (placeholder.matches(toCache)) {
placeholder.setUseCache(true, toCache);
cachedPlaceholders.add(toCache);
plugin.getServerData().addAutoCachedPlaceholder(toCache);
plugin.extraDebug("Auto Caching placeholder " + toCache);
}
}
/*
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
* nonPlayerPlaceholders) { if (placeholder.matches(toCache)) {
* placeholder.setUseCache(true, toCache); cachedPlaceholders.add(toCache);
* plugin.getServerData().addAutoCachedPlaceholder(toCache);
* plugin.extraDebug("Auto Caching placeholder " + toCache); }
*
* }
*/
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.matches(toCache)) {
placeholder.setUseCache(true, toCache);
@@ -1053,27 +1221,24 @@ public class PlaceHolders {
@Override
public void run() {
checkNonCachedPlaceholders();
onUpdate(user);
onUpdate(user, user.isOnline());
}
});
}
public void onUpdate() {
checkNonCachedPlaceholders();
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
if (ident != null) {
String str = placeholder.placeholderRequest(ident);
if (str != null) {
placeholder.getCache().put(ident, str);
}
} else {
plugin.debug("ident null: " + placeholder.getIdentifier());
}
}
}
for (Player p : Bukkit.getOnlinePlayers()) {
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(p), true);
}
/*
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { for (String ident :
* placeholder.getCache().keySet()) { if (ident != null) { String str =
* placeholder.placeholderRequest(ident); if (str != null) {
* placeholder.getCache().put(ident, str); } } else {
* plugin.debug("ident null: " + placeholder.getIdentifier()); } } } }
*/
}
}
@@ -1,7 +1,7 @@
package com.bencodez.votingplugin.placeholders;
public enum PlaceholderCacheLevel {
NONE, SPECIFC, AUTO;
NONE, SPECIFIC, AUTO, AUTOALL, SPECIFICALL;
public static PlaceholderCacheLevel getCache(String str) {
for (PlaceholderCacheLevel v : PlaceholderCacheLevel.values()) {
@@ -12,14 +12,28 @@ public enum PlaceholderCacheLevel {
return AUTO;
}
public boolean onlineOnly() {
if (this == AUTOALL) {
return false;
}
if (this == SPECIFICALL) {
return false;
}
return true;
}
public boolean shouldCache() {
switch (this) {
case AUTO:
return true;
case NONE:
return false;
case SPECIFC:
case SPECIFIC:
return false;
case SPECIFICALL:
return false;
case AUTOALL:
return true;
default:
return false;
}
@@ -0,0 +1,41 @@
package com.bencodez.votingplugin.placeholders;
import org.bukkit.OfflinePlayer;
import com.bencodez.votingplugin.VotingPluginMain;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
public class VotingPluginExpansion extends PlaceholderExpansion {
private VotingPluginMain plugin;
public VotingPluginExpansion(VotingPluginMain plugin) {
this.plugin = plugin;
}
@Override
public String getAuthor() {
return "bencodez";
}
@Override
public String getIdentifier() {
return "votingplugin";
}
@Override
public String getVersion() {
return "1.6";
}
@Override
public boolean persist() {
return true;
}
@Override
public String onRequest(OfflinePlayer p, String indendifier) {
return plugin.getPlaceholders().getPlaceHolder(p, indendifier);
}
}
@@ -0,0 +1,97 @@
package com.bencodez.votingplugin.servicesites;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map.Entry;
import com.bencodez.votingplugin.VotingPluginMain;
import lombok.Getter;
public class ServiceSiteHandler {
@Getter
private HashMap<String, String> serviceSites = new HashMap<String, String>();
private VotingPluginMain plugin;
public String match(String service) {
for (Entry<String, String> entry : serviceSites.entrySet()) {
if (entry.getKey().equalsIgnoreCase(service)) {
return entry.getValue();
}
}
return service;
}
public String matchReverse(String service) {
for (Entry<String, String> entry : serviceSites.entrySet()) {
if (entry.getValue().equalsIgnoreCase(service)) {
return entry.getKey();
}
}
return service;
}
public ServiceSiteHandler(VotingPluginMain plugin) {
this.plugin = plugin;
loadFromGithub();
for (Entry<String, String> entry : serviceSites.entrySet()) {
plugin.extraDebug(entry.getKey() + " - " + entry.getValue());
}
}
public void readFromWeb(String webURL) throws IOException {
serviceSites.clear();
URL url = new URL(webURL);
InputStream is = url.openStream();
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String line;
boolean rawFound = false;
while ((line = br.readLine()) != null) {
if (line.contains("<ul>")) {
rawFound = true;
} else if (!line.contains(" - ")) {
rawFound = false;
} else if (rawFound) {
String data = line.replaceAll("<li>", "").replaceAll("</li>", "");
String[] split = data.split(" - ");
if (split.length > 0) {
serviceSites.put(split[0], split[1]);
}
}
}
} catch (MalformedURLException e) {
plugin.debug(e);
// e.printStackTrace();
// throw new MalformedURLException("URL is malformed!!");
} catch (IOException e) {
plugin.debug(e);
// e.printStackTrace();
// throw new IOException();
}
}
public void loadFromGithub() {
try {
readFromWeb("https://github.com/BenCodez/VotingPlugin/wiki/Minecraft-Server-Lists");
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean contains(String service) {
for (Entry<String, String> entry : serviceSites.entrySet()) {
if (entry.getKey().equalsIgnoreCase(service)) {
return true;
}
}
return false;
}
}
@@ -13,7 +13,6 @@ import org.bukkit.block.data.Directional;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
@@ -111,7 +110,7 @@ public class SignHandler {
* Check valid sign.
*/
public void checkValidSign() {
BukkitScheduler.runTask(plugin, new Runnable() {
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -240,7 +239,7 @@ public class SignHandler {
* @param delay the delay
*/
public void updateSign(int delay) {
BukkitScheduler.runTaskLater(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskLater(plugin, new Runnable() {
@SuppressWarnings("deprecation")
@Override
@@ -77,7 +77,7 @@ public class Signs {
} else {
getSigns().get(i).updateLines();
getSigns().get(i).updateSign(time);
time += 5;
time += 1;
}
}
@@ -49,8 +49,26 @@ public class SpecialRewards {
return checkAllVotes;
}
public void bungeeAllSitesCheck(VotingPluginUser user, int numberOfVotes, int num) {
if (plugin.getBungeeSettings().isGiveExtraAllSitesRewards()) {
int numberOfSites = plugin.getVoteSitesEnabled().size();
if (numberOfVotes >= numberOfSites * 2) {
if (num > numberOfSites) {
if (num % numberOfSites == 0) {
// should give extra allsites?
if (user.checkAllVotes()) {
plugin.debug("Giving extra allsites reward from bungee");
giveAllSitesRewards(user, user.isOnline(), true);
}
}
}
}
}
}
public boolean checkAlmostAllSites(VotingPluginUser user, boolean forceBungee) {
boolean checkAllVotes = user.checkAlmostAllVotes();
plugin.extraDebug("Checking almostallsites reward: " + checkAllVotes + "/" + user.getSitesNotVotedOn());
if (checkAllVotes) {
int currentDay = LocalDateTime.now().getDayOfYear();
int day = user.getGottenAlmostAllSitesDay();
@@ -245,7 +263,9 @@ public class SpecialRewards {
if (streak.contains("-")) {
// multiple
multiple = true;
}
plugin.debug("Streak: " + streak + " multiple: " + multiple);
if (StringParser.getInstance().isInt(s)) {
int streakRequired = Integer.parseInt(s);
if (streakRequired != 0) {
@@ -270,8 +290,7 @@ public class SpecialRewards {
}
} else {
if (curStreak != 0 && curStreak % streakRequired == 0) {
giveVoteStreakReward(user, user.isOnline(), type, streakRequired + "-", curStreak,
forceBungee);
giveVoteStreakReward(user, user.isOnline(), type, streak, curStreak, forceBungee);
gotReward = true;
plugin.debug(
user.getPlayerName() + " got VoteStreak " + streakRequired + "* for " + type);
@@ -6,7 +6,6 @@ import java.util.UUID;
import com.bencodez.advancedcore.api.rewards.Reward;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -125,7 +124,7 @@ public class VoteTester {
.info("Time to process votes (" + amount + "): " + time + " ms, average per vote "
+ timePerVoteAvg + " ms. " + VotingPluginMain.plugin.getStorageType() + ", "
+ plugin.getVotingPluginUserManager().getAllUUIDs().size() + " users. "
+ VotingPluginMain.plugin.getVoteSites().size() + " votesites");
+ plugin.getVoteSitesEnabled().size() + " votesites");
}
});
@@ -134,7 +133,7 @@ public class VoteTester {
public void testSpam(int amount, String name, String site) {
for (int i = 0; i < amount; i++) {
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -83,16 +83,16 @@ public enum TopVoter {
if (switchItems != null && !switchItems.isEmpty()) {
list.addAll(switchItems);
} else {
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterAllTime()) {
list.add(TopVoter.AllTime);
}
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterMonthly()) {
list.add(TopVoter.Monthly);
}
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterWeekly()) {
list.add(TopVoter.Weekly);
}
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterDaily()) {
list.add(TopVoter.Daily);
}
}
@@ -114,16 +114,16 @@ public enum TopVoter {
if (switchItems != null && !switchItems.isEmpty()) {
list.addAll(switchItems);
} else {
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterAllTime()) {
list.add(TopVoter.AllTime);
}
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterMonthly()) {
list.add(TopVoter.Monthly);
}
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterWeekly()) {
list.add(TopVoter.Weekly);
}
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterDaily()) {
list.add(TopVoter.Daily);
}
}
@@ -54,7 +54,7 @@ public class TopVoterHandler implements Listener {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<TopVoterPlayer> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Weekly).keySet());
for (int i = 0; i < users.size(); i++) {
String line = plugin.getConfigFile().getFormatCommandVoteTopLine().replace("%num%", "" + (i + 1))
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine().replace("%num%", "" + (i + 1))
.replace("%player%", users.get(i).getPlayerName())
.replace("%votes%", "" + plugin.getTopVoter(TopVoter.Weekly).get(users.get(i)));
msg.add(line);
@@ -93,7 +93,8 @@ public class TopVoterHandler implements Listener {
String uuid = playerData.getKey().toString();
if (plugin != null && plugin.isEnabled()) {
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
@@ -131,7 +132,7 @@ public class TopVoterHandler implements Listener {
public void onDayChange(DayChangeEvent event) {
synchronized (VotingPluginMain.plugin) {
long startTime = System.currentTimeMillis();
if (plugin.getConfigFile().getStoreTopVotersDaily()) {
if (plugin.getConfigFile().isStoreTopVotersDaily()) {
plugin.getLogger().info("Saving TopVoters Daily");
storeTopVoters(TopVoter.Daily);
}
@@ -140,7 +141,8 @@ public class TopVoterHandler implements Listener {
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(), false);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(),
false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
@@ -173,7 +175,7 @@ public class TopVoterHandler implements Listener {
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Daily).clone();
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
if (entry.getValue().intValue() != lastTotal) {
i++;
}
@@ -183,10 +185,10 @@ public class TopVoterHandler implements Listener {
if (places.containsKey(i)) {
VotingPluginUser user = entry.getKey().getUser();
user.dontCache();
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
if (!plugin.getConfigFile().isTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
user.giveDailyTopVoterAward(i, places.get(i));
plugin.getLogger().info("Giving daily top voter reward " + i + " to "
+ entry.getKey().getPlayerName());
plugin.getLogger().info(
"Giving daily top voter reward " + i + " to " + entry.getKey().getPlayerName());
}
}
lastTotal = entry.getValue().intValue();
@@ -203,7 +205,7 @@ public class TopVoterHandler implements Listener {
}
// give time for other servers to catch up
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
if (!plugin.getTopVoterHandler().bungeeHandleResets() && plugin.getBungeeSettings().isUseBungeecoord()) {
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
try {
Thread.sleep(10000);
@@ -237,7 +239,8 @@ public class TopVoterHandler implements Listener {
if (plugin.getConfigFile().isUseHighestTotals() || plugin.getConfigFile().isUseVoteStreaks()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(), false);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(),
false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
@@ -282,7 +285,7 @@ public class TopVoterHandler implements Listener {
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Monthly).clone();
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
if (entry.getValue().intValue() != lastTotal) {
i++;
}
@@ -293,7 +296,7 @@ public class TopVoterHandler implements Listener {
if (places.containsKey(i)) {
VotingPluginUser user = entry.getKey().getUser();
user.dontCache();
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
if (!plugin.getConfigFile().isTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
user.giveMonthlyTopVoterAward(i, places.get(i));
plugin.getLogger().info("Giving Monthly top voter reward " + i + " to "
+ entry.getKey().getPlayerName());
@@ -307,7 +310,7 @@ public class TopVoterHandler implements Listener {
e.printStackTrace();
}
if (plugin.getSpecialRewardsConfig().getResetMilestonesMonthly()) {
if (plugin.getSpecialRewardsConfig().isResetMilestonesMonthly()) {
resetMilestoneCount();
resetGottenMilestones();
}
@@ -319,7 +322,7 @@ public class TopVoterHandler implements Listener {
}
// give time for other servers to catch up
if (!bungeeHandleResets()) {
if (!bungeeHandleResets() && plugin.getBungeeSettings().isUseBungeecoord()) {
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
try {
Thread.sleep(10000);
@@ -349,7 +352,7 @@ public class TopVoterHandler implements Listener {
public void onWeekChange(WeekChangeEvent event) {
long startTime = System.currentTimeMillis();
synchronized (VotingPluginMain.plugin) {
if (plugin.getConfigFile().getStoreTopVotersWeekly()) {
if (plugin.getConfigFile().isStoreTopVotersWeekly()) {
plugin.getLogger().info("Saving TopVoters Weekly");
storeTopVoters(TopVoter.Weekly);
}
@@ -359,7 +362,8 @@ public class TopVoterHandler implements Listener {
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(), false);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(),
false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
@@ -398,7 +402,7 @@ public class TopVoterHandler implements Listener {
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Weekly).clone();
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
if (entry.getValue().intValue() != lastTotal) {
i++;
}
@@ -408,7 +412,7 @@ public class TopVoterHandler implements Listener {
if (places.containsKey(i)) {
VotingPluginUser user = entry.getKey().getUser();
user.dontCache();
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
if (!plugin.getConfigFile().isTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
user.giveWeeklyTopVoterAward(i, places.get(i));
plugin.getLogger().info("Giving weekly top voter reward " + i + " to "
+ entry.getKey().getPlayerName());
@@ -428,7 +432,7 @@ public class TopVoterHandler implements Listener {
}
// give time for other servers to catch up
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
if (!plugin.getTopVoterHandler().bungeeHandleResets() && plugin.getBungeeSettings().isUseBungeecoord()) {
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
try {
Thread.sleep(10000);
@@ -458,7 +462,14 @@ public class TopVoterHandler implements Listener {
}
public void resetGottenMilestones() {
plugin.getUserManager().removeAllKeyValues("GottenMileStones", DataType.STRING);
plugin.getUserManager().removeAllKeyValues(getGottenMilestonesPath(), DataType.STRING);
}
public String getGottenMilestonesPath() {
if (plugin.getBungeeSettings().isPerServerMilestones()) {
return plugin.getBungeeSettings().getServerNameStorage() + "_" + "GottenMilestones";
}
return "GottenMileStones";
}
public void resetVoteShopLimit(String shopIdent) {
@@ -569,7 +580,7 @@ public class TopVoterHandler implements Listener {
ArrayList<String> topVoters = new ArrayList<String>();
int count = 1;
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine();
line = line.replace("%num%", "" + count);
line = line.replace("%player%", entry.getKey().getPlayerName());
line = line.replace("%votes%", "" + entry.getValue());
@@ -608,7 +619,7 @@ public class TopVoterHandler implements Listener {
ArrayList<String> topVoters = new ArrayList<String>();
int count = 1;
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine();
line = line.replace("%num%", "" + count);
line = line.replace("%player%", entry.getKey().getPlayerName());
line = line.replace("%votes%", "" + entry.getValue());
@@ -647,7 +658,7 @@ public class TopVoterHandler implements Listener {
ArrayList<String> topVoters = new ArrayList<String>();
int count = 1;
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine();
line = line.replace("%num%", "" + count);
line = line.replace("%player%", entry.getKey().getPlayerName());
line = line.replace("%votes%", "" + entry.getValue());
@@ -767,7 +778,7 @@ public class TopVoterHandler implements Listener {
ArrayList<String> topVoters = new ArrayList<String>();
int count = 1;
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine();
line = line.replace("%num%", "" + count);
line = line.replace("%player%", entry.getKey().getPlayerName());
line = line.replace("%votes%", "" + entry.getValue());
@@ -4,7 +4,6 @@ import java.util.Timer;
import java.util.TimerTask;
import com.bencodez.advancedcore.api.updater.Updater;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -73,7 +72,7 @@ public class CheckUpdate {
if (plugin.getConfigFile().isDisableUpdateChecking()) {
return;
}
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -87,7 +86,7 @@ public class CheckUpdate {
}, 1000 * 60 * 1200, 1000 * 60 * 1200);
}
}, 10l);
}, 10);
}
}
@@ -15,7 +15,6 @@ import com.bencodez.votingplugin.VotingPluginMain;
public class UserManager {
private VotingPluginMain plugin;
public UserManager(VotingPluginMain plugin) {
this.plugin = plugin;
}
@@ -25,7 +24,7 @@ public class UserManager {
manager.addKey(new UserDataKeyBoolean("TopVoterIgnore"));
manager.addKey(new UserDataKeyInt("VotePartyVotes"));
manager.addKey(new UserDataKeyString("LastVotes"));
manager.addKey(new UserDataKeyBoolean("CoolDownCheck"));
manager.addKey(new UserDataKeyBoolean(getCoolDownCheckPath()));
manager.addKey(new UserDataKeyString("OfflineVotes").setColumnType("MEDIUMTEXT"));
manager.addKey(new UserDataKeyInt("MilestoneCount"));
manager.addKey(new UserDataKeyInt("MonthTotal"));
@@ -49,6 +48,7 @@ public class UserManager {
manager.addKey(new UserDataKeyInt("LastWeeklyTotal"));
manager.addKey(new UserDataKeyInt("LastDailyTotal"));
manager.addKey(new UserDataKeyInt("BestMonthVoteStreak"));
manager.addKey(new UserDataKeyString(getCoolDownCheckSitePath()).setColumnType("LONGTEXT"));
if (plugin.getOptions().isPerServerRewards()) {
manager.addKey(new UserDataKeyString("OfflineRewards" + plugin.getOptions().getServer())
.setColumnType("MEDIUMTEXT"));
@@ -73,6 +73,22 @@ public class UserManager {
return "AlmostAllSitesLast";
}
public String getCoolDownCheckSitePath() {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage() + "_Sites";
} else {
return "CoolDownCheck" + "_Sites";
}
}
public String getCoolDownCheckPath() {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage();
} else {
return "CoolDownCheck";
}
}
public ArrayList<String> getAllUUIDs() {
return plugin.getUserManager().getAllUUIDs();
}
@@ -4,7 +4,6 @@ import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
@@ -12,8 +11,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -25,6 +24,8 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
@@ -224,7 +225,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
* @return true, if successful
*/
public boolean canVoteAll() {
for (VoteSite voteSite : plugin.getVoteSites()) {
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
boolean canVote = canVoteSite(voteSite);
if (!canVote) {
@@ -236,7 +237,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
public boolean canVoteAny() {
for (VoteSite voteSite : plugin.getVoteSites()) {
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isIgnoreCanVote() && !voteSite.isHidden()) {
boolean canVote = canVoteSite(voteSite);
if (canVote) {
@@ -276,24 +277,21 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
return now.isAfter(nextvote);
} else {
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
.plusHours((long) voteSite.getTimeOffSet());
LocalDateTime resetTime = lastVote.withHour(voteSite.getVoteDelayDailyHour()).withMinute(0)
.withSecond(0);
LocalDateTime resetTimeTomorrow = resetTime.plusHours(24);
if (!now.isBefore(offsetoclocktoday)) {
if (!lastVote.isBefore(offsetoclocktoday)) {
return false;
} else {
// if (ChronoUnit.HOURS.between(lastVote, resetTime) > 24) {
if (lastVote.isBefore(resetTime)) {
if (now.isAfter(resetTime)) {
return true;
}
} else {
if (!lastVote.isBefore(offsetoclockyesterday)) {
return false;
} else {
if (now.isAfter(resetTimeTomorrow)) {
return true;
}
}
}
} catch (Exception e) {
e.printStackTrace();
@@ -303,7 +301,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
public boolean checkAlmostAllVotes() {
if (getSitesNotVotedOn() == 1) {
if (getSitesNotVotedOn() <= 1) {
return true;
}
return false;
@@ -320,7 +318,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
ArrayList<Integer> months = new ArrayList<Integer>();
ArrayList<Integer> days = new ArrayList<Integer>();
for (VoteSite voteSite : plugin.getVoteSites()) {
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (voteSite.isEnabled() && !voteSite.isHidden()) {
long time = user.getTime(voteSite);
if (time != 0) {
@@ -353,6 +351,10 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
if (!voteStreakUpdatedToday(LocalDateTime.now())) {
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage() || hasPercentageTotal(
TopVoter.Daily, plugin.getSpecialRewardsConfig().getVoteStreakRequirementDay(), null)) {
plugin.extraDebug("Adding day vote streak to " + getUUID() + " "
+ plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage() + " "
+ hasPercentageTotal(TopVoter.Daily,
plugin.getSpecialRewardsConfig().getVoteStreakRequirementDay(), null));
addDayVoteStreak();
plugin.getSpecialRewards().checkVoteStreak(this, "Day", forceBungee);
setDayVoteStreakLastUpdate(System.currentTimeMillis());
@@ -451,8 +453,8 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
return getData().getInt("LastMonthTotal", isCacheData(), isWaitForCache());
}
public HashMap<VoteSite, Boolean> getCoolDownCheckSiteList() {
HashMap<VoteSite, Boolean> coolDownChecks = new HashMap<VoteSite, Boolean>();
public HashMap<String, Boolean> getCoolDownCheckSiteList() {
HashMap<String, Boolean> coolDownChecks = new HashMap<String, Boolean>();
ArrayList<String> coolDownCheck = getData().getStringList(getCoolDownCheckSitePath(), isCacheData(),
isWaitForCache());
for (String str : coolDownCheck) {
@@ -461,7 +463,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
VoteSite site = plugin.getVoteSite(data[0], true);
if (site != null) {
Boolean b = Boolean.valueOf(data[1]);
coolDownChecks.put(site, b);
coolDownChecks.put(site.getKey(), b);
}
}
}
@@ -469,9 +471,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
public boolean getCoolDownCheckSite(VoteSite site) {
HashMap<VoteSite, Boolean> coolDownChecks = getCoolDownCheckSiteList();
if (coolDownChecks.containsKey(site)) {
return coolDownChecks.get(site).booleanValue();
HashMap<String, Boolean> coolDownChecks = getCoolDownCheckSiteList();
if (coolDownChecks.containsKey(site.getKey())) {
return coolDownChecks.get(site.getKey()).booleanValue();
}
return false;
}
@@ -516,7 +518,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
public HashMap<VoteSite, Long> getLastVoteTimesSorted() {
LinkedHashMap<VoteSite, Long> times = new LinkedHashMap<VoteSite, Long>();
for (VoteSite voteSite : plugin.getVoteSites()) {
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
times.put(voteSite, getTime(voteSite));
}
LinkedHashMap<VoteSite, Long> sorted = new LinkedHashMap<>(
@@ -569,7 +571,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
public int getSitesVotedOn() {
int amount = 0;
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
if (!canVoteSite(site)) {
amount++;
}
@@ -684,11 +686,12 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
int total = getTotal(top);
switch (top) {
case Daily:
return total / plugin.getVoteSites().size() * 100 > percentage;
return (double) total / (double) plugin.getVoteSitesEnabled().size() * 100 > percentage;
case Monthly:
return total / (plugin.getVoteSites().size() * time.getMonth().length(false)) * 100 > percentage;
return (double) total / ((double) plugin.getVoteSitesEnabled().size() * time.getMonth().length(false))
* 100 > percentage;
case Weekly:
return total / (plugin.getVoteSites().size() * 7) * 100 > percentage;
return (double) total / ((double) plugin.getVoteSitesEnabled().size() * 7) * 100 > percentage;
default:
return false;
}
@@ -710,7 +713,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
* Login message.
*/
public void loginMessage() {
if (plugin.getConfigFile().getVoteRemindingRemindOnLogin()) {
if (plugin.getConfigFile().isVoteRemindingRemindOnLogin()) {
plugin.getVoteReminding().runRemindLogin(this);
}
}
@@ -816,7 +819,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
public void playerVote(VoteSite voteSite, boolean online, boolean broadcast, boolean bungee) {
if (plugin.getConfigFile().getFormatBroadcastWhenOnline() && plugin.getConfigFile().isBroadcastVotesEnabled()
if (plugin.getConfigFile().isFormatBroadcastWhenOnline() && plugin.getConfigFile().isBroadcastVotesEnabled()
&& broadcast && !plugin.getBungeeSettings().isDisableBroadcast()) {
voteSite.broadcastVote(this);
}
@@ -951,18 +954,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
getUserData().setStringList("LastVotes", data);
}
public void setCoolDownCheckSite(HashMap<VoteSite, Boolean> coolDownChecks) {
public void setCoolDownCheckSite(HashMap<String, Boolean> coolDownChecks) {
ArrayList<String> data = new ArrayList<String>();
for (Entry<VoteSite, Boolean> entry : coolDownChecks.entrySet()) {
String str = entry.getKey().getKey() + "//" + entry.getValue().toString();
for (Entry<String, Boolean> entry : coolDownChecks.entrySet()) {
String str = entry.getKey() + "//" + entry.getValue().toString();
data.add(str);
}
getUserData().setStringList(getCoolDownCheckSitePath(), data);
}
public void setCoolDownCheckSite(VoteSite site, boolean value) {
HashMap<VoteSite, Boolean> coolDownChecks = getCoolDownCheckSiteList();
coolDownChecks.put(site, Boolean.valueOf(value));
HashMap<String, Boolean> coolDownChecks = getCoolDownCheckSiteList();
coolDownChecks.put(site.getKey(), Boolean.valueOf(value));
setCoolDownCheckSite(coolDownChecks);
}
@@ -1094,9 +1097,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
case Monthly:
if (plugin.getConfigFile().isLimitMonthlyVotes()) {
LocalDateTime time = plugin.getTimeChecker().getTime();
int days = YearMonth.of(time.getYear(), time.getMonth()).lengthOfMonth();
if (value >= days * plugin.getVoteSites().size()) {
value = days * plugin.getVoteSites().size();
int days = time.getDayOfMonth();
if (value >= days * plugin.getVoteSitesEnabled().size()) {
value = days * plugin.getVoteSitesEnabled().size();
}
}
getData().setInt("MonthTotal", value);
@@ -1209,14 +1212,16 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
info += " ";
}
if (diffSeconds == 1) {
info += StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsSecond()), "amount", "" + diffSeconds);
} else {
info += StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsSeconds()), "amount", "" + diffSeconds);
if (plugin.getConfigFile().isFormatCommandsVoteLastIncludeSeconds()) {
if (diffSeconds == 1) {
info += StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsSecond()), "amount", "" + diffSeconds);
} else {
info += StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
plugin.getConfigFile().getFormatTimeFormatsSeconds()), "amount", "" + diffSeconds);
}
}
info = StringParser.getInstance()
@@ -1255,107 +1260,41 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
public String voteCommandNextInfo(VoteSite voteSite) {
return voteCommandNextInfo(voteSite, getTime(voteSite));
}
public String voteCommandNextInfo(VoteSite voteSite, long time) {
String info = new String();
LocalDateTime now = plugin.getTimeChecker().getTime();
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
.plusHours(plugin.getOptions().getTimeHourOffSet());
if (!voteSite.isVoteDelayDaily()) {
double votedelay = voteSite.getVoteDelay();
if (votedelay == 0 && voteSite.getVoteDelayMin() == 0) {
String errorMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoError();
info = errorMsg;
} else {
LocalDateTime nextvote = lastVote.plusHours((long) votedelay)
.plusMinutes((long) voteSite.getVoteDelayMin());
if (time == 0 || now.isAfter(nextvote)) {
info = plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
} else {
Duration dur = Duration.between(now, nextvote);
long diffHours = dur.getSeconds() / (60 * 60);
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
String timeMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoTime();
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%",
Long.toString(diffHours));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
Long.toString(diffMinutes));
info = timeMsg;
}
}
long nextTime = voteNextDurationTime(voteSite, time);
if (nextTime == 0) {
info = plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
} else {
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
.plusHours((long) voteSite.getTimeOffSet());
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0).withMinute(0)
.plusHours((long) voteSite.getTimeOffSet());
int diffHours = (int) (nextTime / (60 * 60));
long diffMinutes = nextTime / 60 - diffHours * 60;
if (!now.isBefore(offsetoclocktoday)) {
if (!lastVote.isBefore(offsetoclocktoday)) {
Duration dur = Duration.between(now, offsetoclocktomorrow);
int diffHours = (int) (dur.getSeconds() / (60 * 60));
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
if (diffHours < 0) {
diffHours = diffHours * -1;
}
if (diffHours >= 24) {
diffHours = diffHours - 24;
}
if (diffMinutes < 0) {
diffMinutes = diffMinutes * -1;
}
String timeMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoVoteDelayDaily();
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%",
Integer.toString(diffHours));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
Long.toString(diffMinutes));
info = timeMsg;
} else {
info = plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
}
} else {
if (!lastVote.isBefore(offsetoclockyesterday)) {
Duration dur = Duration.between(now, offsetoclocktoday);
int diffHours = (int) (dur.getSeconds() / (60 * 60));
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
if (diffHours < 0) {
diffHours = diffHours * -1;
}
if (diffHours >= 24) {
diffHours = diffHours - 24;
}
if (diffMinutes < 0) {
diffMinutes = diffMinutes * -1;
}
String timeMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoVoteDelayDaily();
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%",
Integer.toString(diffHours));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
Long.toString(diffMinutes));
info = timeMsg;
} else {
info = plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
}
if (diffHours < 0) {
diffHours = diffHours * -1;
}
if (diffHours >= 24) {
diffHours = diffHours - 24;
}
if (diffMinutes < 0) {
diffMinutes = diffMinutes * -1;
}
String timeMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoVoteDelayDaily();
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%", Long.toString(diffMinutes));
info = timeMsg;
}
return info;
}
public long voteNextDurationTime(VoteSite voteSite) {
long time = getTime(voteSite);
return voteNextDurationTime(voteSite, getTime(voteSite));
}
public long voteNextDurationTime(VoteSite voteSite, long time) {
LocalDateTime now = plugin.getTimeChecker().getTime();
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
@@ -1377,28 +1316,21 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
}
} else {
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
.plusHours((long) voteSite.getTimeOffSet());
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0).withMinute(0)
.plusHours((long) voteSite.getTimeOffSet());
if (!now.isBefore(offsetoclocktoday)) {
if (!lastVote.isBefore(offsetoclocktoday)) {
Duration dur = Duration.between(now, offsetoclocktomorrow);
LocalDateTime resetTime = lastVote.withHour(voteSite.getVoteDelayDailyHour()).withMinute(0).withSecond(0);
LocalDateTime resetTimeTomorrow = resetTime.plusHours(24);
if (lastVote.isBefore(resetTime)) {
if (now.isBefore(resetTime)) {
Duration dur = Duration.between(now, resetTime);
return dur.getSeconds();
} else {
return 0;
}
} else {
if (!lastVote.isBefore(offsetoclockyesterday)) {
Duration dur = Duration.between(now, offsetoclocktoday);
if (now.isBefore(resetTimeTomorrow)) {
Duration dur = Duration.between(now, resetTimeTomorrow);
return dur.getSeconds();
} else {
return 0;
}
}
return 0;
}
}
@@ -1408,7 +1340,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
public int getSitesNotVotedOn() {
int amount = 0;
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
if (!site.isHidden()) {
if (canVoteSite(site)) {
amount++;
@@ -1424,7 +1356,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
public long getNextTimeAllSitesAvailable() {
long longest = 0;
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
long seconds = voteNextDurationTime(site);
if (seconds > longest) {
longest = seconds;
@@ -1436,7 +1368,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
public long getNextTimeFirstSiteAvailable() {
long shortest = 0;
for (VoteSite site : plugin.getVoteSites()) {
for (VoteSite site : plugin.getVoteSitesEnabled()) {
if (!canVoteSite(site)) {
long seconds = voteNextDurationTime(site);
if (shortest == 0 || seconds < shortest) {
@@ -1462,4 +1394,40 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
setLastVotes(map);
}
public int getNumberOfOfflineVotes(VoteSite site) {
ArrayList<String> offlineVotes = getOfflineVotes();
int num = 0;
for (String str : offlineVotes) {
if (str.equals(site.getKey())) {
num++;
}
}
return num;
}
public long getLastVoteTimer(VoteSite voteSite) {
HashMap<VoteSite, Long> times = getLastVotes();
if (times.containsKey(voteSite)) {
return times.get(voteSite).longValue();
}
return 0;
}
public void mergeData(HashMap<String, DataValue> toAdd) {
HashMap<String, DataValue> currentData = getData().getValues();
HashMap<String, DataValue> newData = new HashMap<String, DataValue>();
for (TopVoter top : TopVoter.values()) {
if (toAdd.containsKey(top.getColumnName()) && currentData.containsKey(top.getColumnName())) {
newData.put(top.getColumnName(), new DataValueInt(
currentData.get(top.getColumnName()).getInt() + toAdd.get(top.getColumnName()).getInt()));
}
}
if (newData.size() > 0) {
getData().setValues(newData);
}
}
}
@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@@ -20,7 +21,6 @@ import com.bencodez.advancedcore.api.time.events.DayChangeEvent;
import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.VotePartyEvent;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -64,11 +64,11 @@ public class VoteParty implements Listener {
if (getTotalVotes() < getVotesRequired()) {
return;
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerDay()
&& plugin.getServerData().isLastVotePartySameDay()) {
return;
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerWeek()
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerWeek()
&& plugin.getServerData().isLastVotePartySameWeek()) {
return;
}
@@ -84,16 +84,16 @@ public class VoteParty implements Listener {
giveRewards(user, forceBungee);
if (plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired() > 0) {
if (plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRequired() > 0) {
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRequired());
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerDay()) {
plugin.getServerData().updateLastVoteParty();
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerWeek()) {
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerWeek()) {
plugin.getServerData().updateLastVotePartyWeek();
}
@@ -105,7 +105,7 @@ public class VoteParty implements Listener {
* @param sender the sender
*/
public void commandVoteParty(CommandSender sender) {
if (plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
if (plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
ArrayList<String> msg = plugin.getConfigFile().getFormatCommandsVoteParty();
int votesRequired = getVotesRequired();
int votes = getTotalVotes();
@@ -204,7 +204,7 @@ public class VoteParty implements Listener {
String player = getRandomPlayerName();
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
BukkitScheduler.runTask(plugin, new Runnable() {
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -215,7 +215,22 @@ public class VoteParty implements Listener {
});
}
if (plugin.getSpecialRewardsConfig().getVotePartyGiveAllPlayers()) {
final ArrayList<String> list = plugin.getSpecialRewardsConfig().getVotePartyGlobalRandomCommand();
if (list.size() > 0) {
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
StringParser.getInstance().replacePlaceHolder(
list.get(ThreadLocalRandom.current().nextInt(list.size())), "randomonlineplayer",
player));
}
});
}
if (plugin.getSpecialRewardsConfig().isVotePartyGiveAllPlayers()) {
plugin.debug("Trying to give all players vote party");
ArrayList<String> alreadyGotten = new ArrayList<String>();
for (Player p : Bukkit.getOnlinePlayers()) {
@@ -269,14 +284,14 @@ public class VoteParty implements Listener {
@EventHandler
public void onDayChange(DayChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {
if (plugin.getSpecialRewardsConfig().isVotePartyResetEachDay()) {
reset(true);
}
}
@EventHandler
public void onMonthChange(MonthChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetMontly()) {
if (plugin.getSpecialRewardsConfig().isVotePartyResetMonthly()) {
reset(true);
}
@@ -287,9 +302,13 @@ public class VoteParty implements Listener {
@EventHandler
public void onWeekChange(WeekChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetWeekly()) {
if (plugin.getSpecialRewardsConfig().isVotePartyResetWeekly()) {
reset(true);
}
if (plugin.getSpecialRewardsConfig().isVotePartyResetExtraVotesWeekly()) {
plugin.getServerData().setVotePartyExtraRequired(0);
}
}
public void register() {
@@ -329,13 +348,32 @@ public class VoteParty implements Listener {
plugin.getServerData().saveData();
}
public void checkVoteReminder(VotingPluginUser user) {
int neededVotes = getNeededVotes();
for (String str : plugin.getSpecialRewardsConfig().getVotePartyVoteReminderAtVotes()) {
if (StringParser.getInstance().isInt(str)) {
int num = Integer.parseInt(str);
if (neededVotes == num) {
String broadcastMessage = plugin.getSpecialRewardsConfig().getVotePartyVoteReminderBroadcast();
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("player", user.getPlayerName());
placeholders.put("votesrequired", "" + neededVotes);
MiscUtils.getInstance()
.broadcast(StringParser.getInstance().replacePlaceHolder(broadcastMessage, placeholders));
}
}
}
}
public synchronized void vote(VotingPluginUser user, boolean realVote, boolean forceBungee) {
if (plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
if (plugin.getSpecialRewardsConfig().getVotePartyCountFakeVotes() || realVote) {
if (plugin.getSpecialRewardsConfig().getVotePartyCountOfflineVotes() || user.isOnline()) {
if (plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
if (plugin.getSpecialRewardsConfig().isVotePartyCountFakeVotes() || realVote) {
if (plugin.getSpecialRewardsConfig().isVotePartyCountOfflineVotes() || user.isOnline()) {
addTotal(user);
addVotePlayer(user);
check(user, forceBungee);
checkVoteReminder(user);
}
}
}
@@ -1,5 +1,8 @@
package com.bencodez.votingplugin.votereminding;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
@@ -33,6 +36,35 @@ public class VoteReminding {
this.plugin = plugin;
}
public void loadReminds() {
List<String> uuidsStr = plugin.getServerData().getDisabledReminders();
for (String str : uuidsStr) {
remindersEnabled.put(UUID.fromString(str), Boolean.FALSE);
}
plugin.getTimer().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
saveReminds();
}
}, 24, 24, TimeUnit.HOURS);
}
public void saveReminds() {
ArrayList<UUID> remindersDisabled = new ArrayList<UUID>();
for (Entry<UUID, Boolean> entry : remindersEnabled.entrySet()) {
if (remindersEnabled.containsKey(entry.getKey())) {
if (!remindersEnabled.get(entry.getKey()).booleanValue()) {
remindersDisabled.add(entry.getKey());
}
}
}
plugin.getServerData().saveDisabledReminders(remindersDisabled);
}
/**
* Check remind.
*
@@ -41,7 +73,7 @@ public class VoteReminding {
public void checkRemind(VotingPluginUser user) {
if (user.hasPermission("VotingPlugin.Login.RemindVotes") || user.hasPermission("VotingPlugin.Player")) {
if (shouldRemind(user)) {
if (!plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
if (!plugin.getConfigFile().isVoteRemindingRemindOnlyOnce()) {
runRemind(user);
} else if (!user.isReminded()) {
runRemind(user);
@@ -53,7 +85,8 @@ public class VoteReminding {
private void giveReward(VotingPluginUser user) {
new RewardBuilder(plugin.getConfigFile().getData(), plugin.getConfigFile().getVoteRemindingRewardsPath())
.withPlaceHolder("sitesavailable", "" + user.getSitesNotVotedOn()).setGiveOffline(false).send(user);
.withPlaceHolder("sitesavailable", "" + user.getSitesNotVotedOn()).setGiveOffline(false)
.disableDefaultWorlds().send(user);
}
/**
@@ -90,12 +123,12 @@ public class VoteReminding {
* @param user the user
*/
public void runRemind(VotingPluginUser user) {
if (plugin.getConfigFile().getVoteRemindingEnabled()) {
if (plugin.getConfigFile().isVoteRemindingEnabled()) {
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
}
giveReward(user);
if (user.getData().hasData() && plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
if (user.getData().hasData() && plugin.getConfigFile().isVoteRemindingRemindOnlyOnce()) {
user.setReminded(true);
}
@@ -118,18 +151,19 @@ public class VoteReminding {
return user.canVoteAny();
}
} else {
plugin.debug(user.getUUID() + " no need to remind because plaeyr has VotingPlugin.NoRemind");
plugin.debug(user.getUUID() + " no need to remind because player has VotingPlugin.NoRemind");
return false;
}
}
public void runRemindLogin(VotingPluginUser user) {
if (plugin.getConfigFile().getVoteRemindingEnabled()) {
if (plugin.getConfigFile().isVoteRemindingEnabled()) {
if (user.hasPermission("VotingPlugin.Login.RemindVotes") || user.hasPermission("VotingPlugin.Player")) {
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
}
if ((!plugin.getVotingPluginUserManager().getAllUUIDs().contains(user.getUUID()) || shouldRemind(user))) {
if ((!plugin.getVotingPluginUserManager().getAllUUIDs().contains(user.getUUID())
|| shouldRemind(user))) {
giveReward(user);
if (user.getData().hasData()) {
user.setReminded(true);