Compare commits

..
293 Commits
Author SHA1 Message Date
BenCodez caa7058363 Update version number to 6.18.7 2025-06-30 18:41:45 -06:00
BenCodez b67f6a509c Fix waituntilvotedelay on proxy with better handling 2025-06-30 16:53:00 -06:00
BenCodez 0edc09dc80 Update to 1.21.7 2025-06-30 16:14:27 -06:00
BenCodez 19e597e094 Remove version check on startup 2025-06-30 15:53:54 -06:00
BenCodez bfc838bfaa Add wait until vote delay feature on proxy
- Implemented vote delay checks in `VotingPluginProxy`.
- Added methods to handle vote delay logic in `Config` classes.
- Updated `VotingPluginProxyConfig` with new vote delay methods.
- Extended `bungeeconfig.yml` with `WaitUntilVoteDelay` settings.
- Improved vote handling to skip votes if delay conditions are unmet.
- Enhanced logging for skipped votes due to delay.
2025-06-29 15:57:32 -06:00
BenCodez 9cda17e89e Update version number to 6.18.7-SNAPSHOT 2025-06-22 15:50:59 -06:00
BenCodez 54a573a445 Update version number to 6.18.6 2025-06-22 15:32:45 -06:00
BenCodez 5432b2a0d3 Update to 1.21.6 2025-06-22 13:03:30 -06:00
Ben 13d3a614ed Merge pull request #1441 from Kawi16/master
Update AdvancedCore version
2025-06-20 15:49:55 -06:00
Alessandro f9641e158d Update plugin.yml to include NLogin 2025-06-20 06:24:14 +00:00
Alessandro a0c1f64aac Update config to include NLogin 2025-06-20 06:23:44 +00:00
BenCodez 1f88cb0261 Improve vote site generation by replacing spaces with underscores. 2025-06-19 16:03:05 -06:00
BenCodez 47a42d2bc8 Add configuration option to enable /av javascript command
- Introduced `EnableJavascriptCommand` in `Config.yml`
- Default value for `EnableJavascriptCommand` set to `false`
2025-06-03 20:04:12 -06:00
BenCodez ac41787c1e Simplify internal api for mysql on proxy 2025-05-26 20:05:35 -06:00
BenCodez ed4e3968da Add requiresPlayerOnline check to improve vote caching logic.
- Added `requiresPlayerOnline` method to `BungeeMethod` enum.
- Updated vote caching logic to use `requiresPlayerOnline` check.
- Ensured caching occurs only when required by the method.
- Improved clarity of conditions in `VotingPluginProxy`.
- Enhanced flexibility for different `BungeeMethod` implementations.
2025-05-26 18:31:54 -06:00
BenCodez 09da81cc4e Add MQTT proxy method, internal rewrites to cross server communication 2025-05-25 17:06:23 -06:00
BenCodez fd35c43c16 Update version to 6.18.6-SNAPSHOT 2025-05-23 20:54:02 -06:00
BenCodez 8060f594c3 Add filters to exclude specific META-INF files in Maven shade plugin 2025-05-23 20:37:19 -06:00
BenCodez 39aa7062a5 Update version number to 6.18.5 2025-05-23 20:18:56 -06:00
BenCodez 7ff7fbb7cb Update to AdvancedCore changes 2025-05-17 21:29:49 -06:00
BenCodez 231817314b Modify handling of nonvoted players to not cache in offline mode
- change package name of multi-proxy
2025-05-13 17:59:07 -06:00
BenCodez a20f10d978 Use mysql/sqlite from simpleapi 2025-05-13 12:58:55 -06:00
BenCodez 997beaae28 Modify handling of offline reward checking in offline mode 2025-05-11 21:07:55 -06:00
BenCodez 9acc5861b7 Modified handling of placeholder cache for offline mode 2025-05-02 11:30:17 -06:00
BenCodez f299847d46 Modify handling of caching for offline mode 2025-05-02 08:23:45 -06:00
BenCodez 87ff48366c Modofy handling of getting VotingPluginUser to account for offline mode 2025-04-26 12:26:14 -06:00
BenCodez 3dde76dcde Fix voteparty velocity broadcast 2025-04-22 14:08:42 -06:00
BenCodez 237713a799 Fix velocity voteparty broadcast not being colorized 2025-04-22 13:35:16 -06:00
BenCodez 23141d4ec1 Fix handling of allowunjoined on backend servers 2025-04-21 09:48:48 -06:00
Ben 2cfbaf4de8 Merge pull request #1434 from BenCodez/dependabot/maven/VotingPlugin/org.junit.jupiter-junit-jupiter-engine-5.12.2
Bump org.junit.jupiter:junit-jupiter-engine from 5.12.1 to 5.12.2 in /VotingPlugin
2025-04-14 12:30:47 -06:00
dependabot[bot] c31b83fcd3 Bump org.junit.jupiter:junit-jupiter-engine in /VotingPlugin
Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.12.1 to 5.12.2.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.12.1...r5.12.2)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter-engine
  dependency-version: 5.12.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-14 06:07:25 +00:00
BenCodez 4cfd887c33 Update version number to 6.18.5-SNAPSHOT 2025-04-13 15:52:53 -06:00
BenCodez f04930e437 Update version number to 6.18.4 2025-04-13 15:47:38 -06:00
Ben c45e8356bb Merge pull request #1432 from BenCodez/dependabot/maven/VotingPlugin/org.projectlombok-lombok-1.18.38
Bump org.projectlombok:lombok from 1.18.36 to 1.18.38 in /VotingPlugin
2025-04-07 07:44:46 -06:00
dependabot[bot] 2f78b7784a Bump org.projectlombok:lombok from 1.18.36 to 1.18.38 in /VotingPlugin
Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.36 to 1.18.38.
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.36...v1.18.38)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-07 07:15:37 +00:00
BenCodez 911642f57f Update placeholder descriptions to specify "username" instead of "user" 2025-04-03 17:28:54 -06:00
Ben 5e63c04f6c Merge pull request #1430 from BenCodez/dependabot/maven/VotingPlugin/net.md-5-bungeecord-api-1.21-R0.2
Bump net.md-5:bungeecord-api from 1.20-R0.3-SNAPSHOT to 1.21-R0.2 in /VotingPlugin
2025-03-31 07:43:01 -06:00
dependabot[bot] e368f30dd9 Bump net.md-5:bungeecord-api in /VotingPlugin
Bumps [net.md-5:bungeecord-api](https://github.com/SpigotMC/BungeeCord) from 1.20-R0.3-SNAPSHOT to 1.21-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>
2025-03-31 06:53:42 +00:00
BenCodez 5d5e8b0d55 Modify unit tests, add more tests 2025-03-30 22:08:06 -06:00
BenCodez 16e52a4fd7 Revert placeholder change 2025-03-30 16:58:46 -06:00
BenCodez 331c8fedf5 Adjust next vote placeholder 2025-03-30 14:59:12 -06:00
BenCodez c085d6823e Improve vote cache time checks and add unit tests for VotingPluginProxy
- Add `@Setter` to `cachedOnlineVotes` and `cachedVotes`
- Update vote cache time check logic in `VotingPluginProxy`
- Create `VotingPluginProxyTest` class
- Add tests for removing expired votes from `cachedOnlineVotes`
- Add tests for not removing non-expired votes from `cachedOnlineVotes`
- Add tests for removing expired votes from `cachedVotes`
2025-03-30 14:35:23 -06:00
BenCodez 47680b2646 Slight adjustment to vote cache time handling 2025-03-30 10:35:41 -06:00
BenCodez 60ed0ce73d Force update player heads from signs 2025-03-29 08:11:36 -06:00
BenCodez e5ae3184e0 Fix velocity config not reloading 2025-03-28 07:49:03 -06:00
BenCodez dca9c6fe18 Adjust handling of skulls for signs to use item skull cache 2025-03-27 20:29:38 -06:00
Ben 083e90706f Merge pull request #1429 from tonyjamesstark/patch-1
Update SignHandler.java
2025-03-27 09:04:33 -06:00
tonyjamesstark fed96bcda1 Update SignHandler.java
fix skull displays showing default skins
2025-03-27 07:57:07 -07:00
BenCodez 5bad8c8f98 Update to 1.21.5 2025-03-25 21:36:58 -06:00
BenCodez e31326395c Fix bungee voteparty not working on backend servers 2025-03-18 21:30:37 -06:00
Ben f5b2d27b9e Merge pull request #1425 from BenCodez/dependabot/maven/VotingPlugin/org.junit.jupiter-junit-jupiter-engine-5.12.1
Bump org.junit.jupiter:junit-jupiter-engine from 5.12.0 to 5.12.1 in /VotingPlugin
2025-03-17 07:56:15 -06:00
dependabot[bot] 42626e3789 Bump org.junit.jupiter:junit-jupiter-engine in /VotingPlugin
Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.12.0 to 5.12.1.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.12.0...r5.12.1)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter-engine
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-17 06:27:11 +00:00
BenCodez b35ff9454d Fix color codes on velocity commands 2025-03-12 19:24:27 -06:00
BenCodez 9ee1547691 Add sitesavailabletotal placeholder - return number of votesites 2025-03-11 10:07:41 -06:00
BenCodez cb1599fe56 Fix double vote points on online proxy votes 2025-03-08 20:18:57 -06:00
BenCodez 59a206617c Adjustments to handling bedrock players 2025-03-07 10:32:58 -06:00
BenCodez 699d74ca3f Change vote party processing order 2025-03-04 08:07:34 -06:00
BenCodez ad6d411e64 Change order of voteparty processing 2025-03-03 12:21:23 -06:00
Ben 1b430dc4b8 Merge pull request #1422 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-deploy-plugin-3.1.4
Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.3 to 3.1.4 in /VotingPlugin
2025-03-03 07:50:47 -06:00
dependabot[bot] 526dcc830e Bump org.apache.maven.plugins:maven-deploy-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/apache/maven-deploy-plugin/releases)
- [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.1.3...maven-deploy-plugin-3.1.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-03 07:02:14 +00:00
BenCodez 75aaae7016 Change layout of packages for proxy files 2025-03-02 19:23:56 -06:00
BenCodez 89d3372701 Make attempt to get bedrock player if votes comes with no prefix 2025-03-02 19:18:02 -06:00
BenCodez 209f1dbc25 Add extra check before checking players current server on velocity 2025-02-25 17:17:40 -06:00
BenCodez bb67de8d0e Update version number to 6.18.4-SNAPSHOT 2025-02-24 15:15:06 -06:00
BenCodez b4d57c7eae Update version number to 6.18.3 2025-02-24 14:58:52 -06:00
Ben 2ac6609d8e Update README.md 2025-02-24 14:51:22 -06:00
Ben 9eec6525c0 Merge pull request #1421 from BenCodez/dependabot/maven/VotingPlugin/org.junit.jupiter-junit-jupiter-engine-5.12.0
Bump org.junit.jupiter:junit-jupiter-engine from 5.11.4 to 5.12.0 in /VotingPlugin
2025-02-24 08:17:06 -06:00
dependabot[bot] 858b8b7b3c Bump org.junit.jupiter:junit-jupiter-engine in /VotingPlugin
Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.11.4 to 5.12.0.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.11.4...r5.12.0)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter-engine
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-24 07:04:40 +00:00
BenCodez 0aaef50a82 Add extra checks for velocity 2025-02-22 07:58:36 -06:00
BenCodez 365f06d2ed Add extra checks for velocity 2025-02-22 07:58:36 -06:00
BenCodez a1b7370da0 Adjust login check to be a little more efficient 2025-02-18 21:23:38 -06:00
Ben 2f52576bc4 Merge pull request #1420 from BenCodez/dependabot/maven/VotingPlugin/org.junit.jupiter-junit-jupiter-engine-5.11.4
Bump org.junit.jupiter:junit-jupiter-engine from 5.8.1 to 5.11.4 in /VotingPlugin
2025-02-17 08:26:44 -06:00
dependabot[bot] bac19aecb9 Bump org.junit.jupiter:junit-jupiter-engine in /VotingPlugin
Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.8.1 to 5.11.4.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.8.1...r5.11.4)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter-engine
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-17 06:35:47 +00:00
BenCodez 3ad6ce247d Undo test change 2025-02-13 16:24:51 -06:00
BenCodez bb78792e27 Test change in pom.xml 2025-02-13 16:02:24 -06:00
BenCodez 726b116c20 Add voteparty test 2025-02-12 17:48:42 -06:00
BenCodez f731f82b01 Modify test package location 2025-02-12 08:36:08 -06:00
BenCodez 939c431bcf Fix lombok 2025-02-11 11:40:09 -06:00
BenCodez 87ed9dfe39 Change default source and resource folder, add first unit test 2025-02-11 11:35:59 -06:00
BenCodez eceacf607f Change handling of json files on bungee 2025-02-09 13:52:38 -06:00
BenCodez 8d6db5b94f Add extra null check on nonvotedplayerscache.json 2025-02-09 09:51:24 -06:00
BenCodez 700300a293 Adjust handling of non voted player cache on bungee 2025-02-08 08:32:28 -06:00
BenCodez 5e5e208de0 Adjust plugin messaging handling slightly 2025-02-05 10:37:48 -06:00
BenCodez b48662acfe Add AdminVoteTopPoints command and GUI for viewing top points 2025-02-05 08:45:05 -06:00
BenCodez 0aed3068db Adjust multi-proxy loading 2025-02-04 17:25:24 -06:00
BenCodez 25a3ff904d Add more debug to vote party check 2025-02-04 10:54:04 -06:00
BenCodez bb7adc409a Small change for bungee 2025-01-31 12:34:57 -06:00
BenCodez 1b28966798 Fixed an error that can happen on bungee 2025-01-26 18:42:36 -06:00
BenCodez f5d34ad84a Update version number to 6.18.3-SNAPSHOT 2025-01-26 13:35:26 -06:00
BenCodez abd86834a6 Update version number to 6.18.2 2025-01-26 13:29:33 -06:00
BenCodez c6647d7cc3 Slight change to plugin messaging 2025-01-26 09:54:46 -06:00
BenCodez a3851f9bf2 Update version number to 6.18.2-SNAPSHOT 2025-01-25 20:37:57 -06:00
BenCodez a951aae0de Update version number to 6.18.1 2025-01-25 20:15:31 -06:00
BenCodez 826fc95131 Adjust encryption 2025-01-25 19:22:14 -06:00
BenCodez dea13f6ff1 Add log warning for disabled plugin message encryption on proxy 2025-01-25 18:24:39 -06:00
BenCodez bab55de93b Add warning when PluginMessageEncryption is disabled 2025-01-25 17:51:53 -06:00
BenCodez 1c112688b1 Add restart requirement notes for PluginMessageChannel and
PluginMessageEncryption

- Added note for PluginMessageChannel restart requirement
- Added note for PluginMessageEncryption restart requirement
- Instructed to copy secretkey.key file to all servers
- Ensured settings must match on all servers
- Updated `BungeeSettings.yml` and `bungeeconfig.yml` files
2025-01-25 16:59:27 -06:00
BenCodez bc0e82f68f Fix null check and correct config path
- Add null check for playerName in isPlayerOnline method
- Correct path for PluginMessageChannel in BungeeSettings
- Ensure playerName is not null before checking online status
- Update config annotation path in BungeeSettings
- Improve code robustness and prevent potential null pointer exceptions
2025-01-25 16:50:10 -06:00
BenCodez a82397a67f Update channel identifier creation to use lowercase values
- Split plugin message channel by colon
- Convert channel parts to lowercase
- Create MinecraftChannelIdentifier with lowercase values
- Register the new channel identifier
- Ensure compatibility with case-insensitive channels
- Improve robustness of channel handling
2025-01-25 16:12:33 -06:00
BenCodez b1ffce516c Add plugin message encryption support
- Add `PluginMessageEncryption` to config files
- Update `BungeeHandler` to handle encryption
- Modify `VotingPluginProxy` to support encrypted messages
- Implement encryption checks in `Config` classes
- Update `BungeeSettings` with encryption setting
- Ensure message encryption in `sendPluginMessage` method
2025-01-25 16:09:53 -06:00
BenCodez f48a008040 Add ability to change pluginmessage channel 2025-01-25 15:35:42 -06:00
BenCodez 90c8255894 Fix isSomeoneOnlineServer method to correctly check for online
players.
2025-01-25 12:36:14 -06:00
BenCodez 4001e865f5 Refactor plugin message handling in VotingPluginProxy
- Combine if-else statements for subchannel checks
- Add comment for unused "TimeChangeFinished" subchannel
- Add handling for "VoteUpdate" subchannel
- Add debug message for ignored plugin messages
- Improve code readability and maintainability
- Ensure proper message forwarding and logging
2025-01-24 17:32:55 -06:00
BenCodez 77b7659cb6 Fix for velocity 2025-01-24 16:24:26 -06:00
BenCodez bc073857f6 Test change for velocity 2025-01-24 16:21:02 -06:00
BenCodez 9c2a41c9b5 Fix reward path in AdminVoteVoteShopItem.java 2025-01-24 10:40:16 -06:00
BenCodez 972f5350a1 Change default second votesite 2025-01-22 08:09:46 -06:00
BenCodez 66df9d85da Improve javadoc commments for VotingPluginUser 2025-01-20 09:55:45 -06:00
Ben 4046dd9d7f Merge pull request #1412 from BlvckBytes/master
Added variable %sitename% to placeholders of Commands.Vote.Today.Line
2025-01-18 19:58:16 -06:00
Philip Hell d89aa6ccb2 Added variable %sitename% to placeholders of Commands.Vote.Today.Line 2025-01-19 02:50:28 +01:00
Ben 813ffed723 Merge pull request #1404 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.11.2
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.11.1 to 3.11.2 in /VotingPlugin
2025-01-12 15:59:02 -06:00
BenCodez c0bc1b2730 Adjust when dev build warning is given 2025-01-10 19:25:37 -06:00
BenCodez 1217e63583 Changes to proxy handling 2025-01-09 08:46:45 -06:00
BenCodez cd6ed92e4f Rewrite backend on velocity to make it more universal with bungee 2025-01-09 08:12:29 -06:00
BenCodez 07c9eda769 Code cleanup 2024-12-31 15:39:51 -06:00
BenCodez ef0f73ba32 Fix a few issues on bungee related to internal changes 2024-12-31 15:29:53 -06:00
BenCodez 10b0fd3b11 Internal rewrites of bungee for universal proxy backend 2024-12-31 11:19:07 -06:00
BenCodez a4aa209aa7 Fix handling of previous months votes on certain dates 2024-12-31 11:17:45 -06:00
BenCodez 70af742083 Code cleanup 2024-12-29 21:42:00 -06:00
BenCodez 0463700037 Add permission check to sites not voted on 2024-12-27 11:08:30 -06:00
BenCodez 69d9c09b06 Increase default skull cache timing 2024-12-20 07:54:11 -06:00
BenCodez 4455cc96b9 Fix issue with no vote url set 2024-12-17 09:11:59 -06:00
BenCodez 0ee7c1f2e8 Adjustment to maven profile 2024-12-16 20:44:49 -06:00
BenCodez 4b3cc8c8e0 Update version number to 6.18.1-SNAPSHOT 2024-12-16 20:36:49 -06:00
BenCodez c2fe26aaea Update version number to 6.18 2024-12-16 20:21:37 -06:00
BenCodez 2aa84c90e8 Adjustments to how previous months top voters are loaded 2024-12-16 17:34:47 -06:00
BenCodez c8cace388e Change command from previousmonthsvoters to previousmonthstotals 2024-12-16 16:29:38 -06:00
BenCodez 1da028476f Don't load command if month date isn't enabled 2024-12-14 16:50:05 -06:00
BenCodez c28bddd0ba Add previous month top voters GUI, uses Month totals with date 2024-12-13 12:43:15 -06:00
BenCodez 1afd8253a5 Add extra time change checks on login 2024-12-13 09:58:29 -06:00
BenCodez a3a1b4604f Add extra check for time queues on proxy 2024-12-13 09:46:28 -06:00
BenCodez 3bd41af200 Add extra checks on proxy time changes 2024-12-13 09:43:04 -06:00
BenCodez 0042045d9b Add bypass fail safe options for bungee time checking 2024-12-13 09:10:04 -06:00
BenCodez 76d7579c7d Update to 1.21.4 2024-12-09 21:24:43 -06:00
Ben f591b863f1 Merge pull request #1405 from BenCodez/dependabot/maven/VotingPlugin/com.coderplus.maven.plugins-copy-rename-maven-plugin-1.0.1
Bump com.coderplus.maven.plugins:copy-rename-maven-plugin from 1.0 to 1.0.1 in /VotingPlugin
2024-12-09 07:43:31 -06:00
dependabot[bot] b43c4b89a8 Bump com.coderplus.maven.plugins:copy-rename-maven-plugin
Bumps [com.coderplus.maven.plugins:copy-rename-maven-plugin](https://github.com/coderplus/copy-rename-maven-plugin) from 1.0 to 1.0.1.
- [Commits](https://github.com/coderplus/copy-rename-maven-plugin/commits)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-27 06:44:10 +00:00
BenCodez 050bfb3055 Update version number to 6.16.2 2024-05-26 16:31:33 -04:00
BenCodez 3ce40de5f6 Update utils classes 2024-05-20 15:19:00 -04:00
BenCodez 095cd2a422 Update imports 2024-05-20 14:45:26 -04:00
BenCodez 5e7cc2b7ad Add relocation to pom.xml 2024-05-20 14:02:55 -04:00
BenCodez 38c61ce669 Update imports 2024-05-20 13:50:11 -04:00
BenCodez 9de71167ec Update imports 2024-05-20 13:16:18 -04:00
BenCodez e8b9c9fbc2 Update imports 2024-05-20 12:46:40 -04:00
BenCodez 60ac9fcd46 Use newer classes 2024-05-20 10:37:14 -04:00
BenCodez a0d334c88b Fix minor spacing error 2024-05-07 19:14:30 -04:00
BenCodez b90b4964e4 Add relocation pattern to fix javadoc 2024-05-07 19:02:00 -04:00
BenCodez a0fbdaa2a0 Update version number to 6.16.1 2024-05-07 18:58:14 -04:00
BenCodez 17066cb679 Stop background timer on velocity on shutdown 2024-05-06 16:04:00 -04:00
Ben 9eb1ba82af Merge pull request #1352 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-deploy-plugin-3.1.2
Bump org.apache.maven.plugins:maven-deploy-plugin from 3.1.1 to 3.1.2 in /VotingPlugin
2024-05-06 15:48:27 -04:00
dependabot[bot] 06b12c9599 Bump org.apache.maven.plugins:maven-deploy-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/apache/maven-deploy-plugin/releases)
- [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-3.1.1...maven-deploy-plugin-3.1.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-06 06:19:25 +00:00
142 changed files with 10882 additions and 7637 deletions

No files matched your search

-4
View File
@@ -2,10 +2,6 @@
Plugin on SpigotMC
https://www.spigotmc.org/resources/votingplugin.15358/
## License
### Creative Commons Arttribution 3.0 Unported
https://github.com/BenCodez/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
### Maven:
<repository>
+1
View File
@@ -6,3 +6,4 @@
/.settings/
/.classpath
/.factorypath
/.apt_generated_tests/
+275 -185
View File
@@ -1,19 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>${version.art}</artifactId>
<version>6.16</version>
<artifactId>votingplugin</artifactId>
<version>6.18.7</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
<github.global.server>github</github.global.server>
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
<build.number>NOTSET</build.number>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
</properties>
<build>
<resources>
<resource>
<directory>Resources</directory>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>plugin.yml</include>
@@ -22,11 +27,12 @@
</includes>
</resource>
<resource>
<directory>Resources</directory>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<sourceDirectory>src</sourceDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
@@ -56,16 +62,6 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
@@ -80,7 +76,7 @@
<configuration>
<addOutputDirectory>false</addOutputDirectory>
<outputDirectory>${project.basedir}/target/delombok</outputDirectory>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
</configuration>
</execution>
</executions>
@@ -88,7 +84,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<version>3.6.0</version>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<minimizeJar>true</minimizeJar>
@@ -99,11 +95,30 @@
<include>**</include>
</includes>
</filter>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.tcoded.folialib</pattern>
<shadedPattern>
${project.groupId}.votingplugin.simpleapi.folialib</shadedPattern>
</relocation>
<relocation>
<pattern>com.bencodez.simpleapi</pattern>
<shadedPattern>
${project.groupId}.votingplugin.simpleapi</shadedPattern>
</relocation>
<relocation>
<pattern>com.bencodez.advancedcore</pattern>
<shadedPattern>${project.groupId}.votingplugin.advancedcore</shadedPattern>
<shadedPattern>
${project.groupId}.votingplugin.advancedcore</shadedPattern>
</relocation>
<relocation>
<pattern>net.pl3x.bukkit.chatapi</pattern>
@@ -111,24 +126,30 @@
</relocation>
<relocation>
<pattern>me.mrten.mysqlapi</pattern>
<shadedPattern>${project.groupId}.votingplugin.mysqlapi</shadedPattern>
<shadedPattern>
${project.groupId}.votingplugin.mysqlapi</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.HikariCP</pattern>
<shadedPattern>${project.groupId}.votingplugin.HikariCP</shadedPattern>
<shadedPattern>
${project.groupId}.votingplugin.HikariCP</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>${project.groupId}.votingplugin.hikari</shadedPattern>
<shadedPattern>
${project.groupId}.votingplugin.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>${project.groupId}.votingplugin.bstats</shadedPattern>
<shadedPattern>
${project.groupId}.votingplugin.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>xyz.upperlevel.spigot</pattern>
<shadedPattern>${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot</shadedPattern>
<shadedPattern>
${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
@@ -139,7 +160,8 @@
</goals>
<configuration>
<artifactSet>
<!-- Lets exclude google code, because the server already has this
<!-- Lets exclude google code, because the
server already has this
code in it (guava, etc) -->
<excludes>
<exclude>com.google.*:*</exclude>
@@ -160,31 +182,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${user.home}/Documents/Test Server/plugins</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target</directory>
<includes>
<include>VotingPlugin.jar</include>
</includes>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
@@ -214,26 +211,27 @@
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
<url>
https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<version>1.21.7-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<version>1.18.38</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.20-R0.2</version>
<version>1.21-R0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -251,91 +249,71 @@
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.1</version>
<version>3.1.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.5</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>3.7.18-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.12.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.15.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>normal</id>
<id>default</id>
<properties>
<build.profile.id>default</build.profile.id>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.profile.id>normal</build.profile.id>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>normal-folia</id>
<properties>
<build.profile.id>normal</build.profile.id>
<version.art>votingplugin-folia</version.art>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore-folia</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>prod2</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>prod2</build.profile.id>
</properties>
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deploy-snapshot</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>deploy-snapshot</build.profile.id>
<build.profile.id>dev-snapshot</build.profile.id>
</properties>
<distributionManagement>
<snapshotRepository>
@@ -344,23 +322,67 @@
</snapshotRepository>
<repository>
<id>nexus</id>
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>
${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-file</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>
${project.basedir}/target/${project.name}.jar</sourceFile>
<destinationFile>
${project.basedir}/target/${project.name}-${build.number}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<phase>deploy</phase>
<configuration>
<sourcepath>
${project.basedir}/target/delombok</sourcepath>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.4</version>
<configuration>
<skip>true</skip>
</configuration>
@@ -368,7 +390,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<version>1.7.0</version>
<executions>
<execution>
<id>default-deploy</id>
@@ -390,9 +412,6 @@
<profile>
<id>javadoc</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>javadoc</build.profile.id>
</properties>
<distributionManagement>
@@ -402,20 +421,25 @@
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<version>3.11.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -424,8 +448,79 @@
</goals>
<phase>deploy</phase>
<configuration>
<sourcepath>${project.basedir}/target/delombok</sourcepath>
<outputDirectory>${project.basedir}/target/apidocs</outputDirectory>
<sourcepath>
${project.basedir}/target/delombok</sourcepath>
<outputDirectory>
${project.basedir}/target/apidocs</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-file</id>
<phase>deploy</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>
${project.basedir}/target/${project.name}.jar</sourceFile>
<destinationFile>
${project.basedir}/target/${project.name}-${project.version}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>dev</id>
<properties>
<build.profile.id>dev</build.profile.id>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${user.home}/Documents/Test_Server/plugins</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target</directory>
<includes>
<include>VotingPlugin.jar</include>
</includes>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
@@ -436,20 +531,8 @@
<profile>
<id>deploy</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>deploy</build.profile.id>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>nexus</id>
@@ -462,10 +545,43 @@
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-file</id>
<phase>deploy</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>
${project.basedir}/target/${project.name}.jar</sourceFile>
<destinationFile>
${project.basedir}/target/${project.name}-${project.version}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<version>3.11.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -474,7 +590,8 @@
</goals>
<phase>deploy</phase>
<configuration>
<sourcepath>${project.basedir}/target/delombok</sourcepath>
<sourcepath>
${project.basedir}/target/delombok</sourcepath>
</configuration>
</execution>
</executions>
@@ -482,7 +599,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.4</version>
<configuration>
<skip>true</skip>
</configuration>
@@ -490,7 +607,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<version>1.7.0</version>
<executions>
<execution>
<id>default-deploy</id>
@@ -506,33 +623,6 @@
<skipStaging>true</skipStaging>
</configuration>
</plugin>
<!--<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<executions>
<execution>
<id>javadoc</id>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
<configuration>
<message>Maven javadoc for ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/apidocs
</outputDirectory>
<branch>refs/heads/gh-pages</branch>
<includes>
<include>**/*</include>
</includes>
<repositoryName>VotingPlugin</repositoryName>
<repositoryOwner>BenCodez</repositoryOwner>
<server>github</server>
</configuration>
</execution>
</executions>
</plugin>-->
</plugins>
</build>
</profile>
@@ -1,31 +0,0 @@
package com.Ben12345rocks.VotingPlugin.Objects;
import org.bukkit.entity.Player;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@Deprecated
public class User {
private VotingPluginUser user;
public User(Player p) {
user = VotingPluginMain.plugin.getVotingPluginUserManager().getVotingPluginUser(p);
}
public void addPoints(int points) {
user.addPoints(points);
}
public int getPoints() {
return user.getPoints();
}
public boolean removePoints(int points) {
return user.removePoints(points);
}
public void setPoints(int points) {
user.setPoints(points);
}
}
@@ -1,118 +0,0 @@
package com.bencodez.votingplugin.bungee;
import java.io.File;
import java.io.IOException;
import lombok.Getter;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.JsonConfiguration;
import net.md_5.bungee.config.YamlConfiguration;
public class NonVotedPlayersCache {
private VotingPluginBungee bungee;
@Getter
private Configuration data;
public NonVotedPlayersCache(VotingPluginBungee bungee) {
this.bungee = bungee;
}
public void addPlayer(ProxiedPlayer proxiedPlayer) {
if (!bungee.getMysql().containsKeyQuery(proxiedPlayer.getUniqueId().toString())) {
addPlayer(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
}
}
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() {
for (String player : getData().getSection("NonVotedPlayers").getKeys()) {
long time = getData().getLong("NonVotedPlayers." + player + ".LastTime", 0);
if ((System.currentTimeMillis() - time) > 1000 * 60 * 60 * 24 * 5) {
remove(player);
} else {
String uuid = getData().getString("NonVotedPlayers." + player + ".UUID", "");
if (!uuid.isEmpty()) {
if (bungee.getMysql().containsKeyQuery(uuid)) {
remove(player);
}
} else {
remove(player);
}
}
}
save();
}
public void load() {
if (!bungee.getDataFolder().exists()) {
bungee.getDataFolder().mkdir();
}
File yamlFile = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.json");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
if (yamlFile.exists()) {
try {
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
} catch (IOException e) {
e.printStackTrace();
}
save();
}
try {
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
} catch (IOException e) {
e.printStackTrace();
}
}
public String playerExists(String playerName) {
if (getData().getSection("NonVotedPlayers").getKeys().contains(playerName)) {
return getData().getString("NonVotedPlayers." + playerName + ".UUID", "");
}
return "";
}
private void remove(String player) {
bungee.debug("Removing nonvotedplayer: " + player);
getData().set("NonVotedPlayers." + player, null);
}
public void save() {
try {
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -1,160 +0,0 @@
package com.bencodez.votingplugin.bungee;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
import lombok.Getter;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.JsonConfiguration;
import net.md_5.bungee.config.YamlConfiguration;
public class VoteCache {
private VotingPluginBungee bungee;
@Getter
private Configuration data;
public VoteCache(VotingPluginBungee bungee) {
this.bungee = bungee;
}
public int getVotePartyCurrentVotes() {
return getData().getInt("VoteParty.CurrentVotes", 0);
}
public int getVotePartyInreaseVotesRequired() {
return getData().getInt("VoteParty.IncreaseVotes", 0);
}
public void setVotePartyCurrentVotes(int amount) {
getData().set("VoteParty.CurrentVotes", amount);
}
public void setVotePartyInreaseVotesRequired(int amount) {
getData().set("VoteParty.IncreaseVotes", amount);
}
public void setVotePartyCache(String server, int amount) {
getData().set("VoteParty.Cache." + server, amount);
}
public int getVotePartyCache(String server) {
return getData().getInt("VoteParty.Cache." + server, 0);
}
public void addVote(String server, int num, OfflineBungeeVote voteData) {
Configuration section = getData().getSection("VoteCache." + server + "." + num);
section.set("Name", voteData.getPlayerName());
section.set("Service", voteData.getService());
section.set("UUID", voteData.getUuid());
section.set("Time", voteData.getTime());
section.set("Real", voteData.isRealVote());
section.set("Text", voteData.getText());
}
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
Configuration section = getData().getSection("TimedVoteCache." + num);
section.set("Name", voteTimedQueue.getName());
section.set("Service", voteTimedQueue.getService());
section.set("Time", voteTimedQueue.getTime());
}
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
Configuration section = getData().getSection("OnlineCache." + player + "." + num);
section.set("Name", voteData.getPlayerName());
section.set("Service", voteData.getService());
section.set("UUID", voteData.getUuid());
section.set("Time", voteData.getTime());
section.set("Real", voteData.isRealVote());
section.set("Text", voteData.getText());
}
public void clearData() {
getData().set("VoteCache", null);
getData().set("OnlineCache", null);
save();
}
public Collection<String> getOnlineVotes(String name) {
return getData().getSection("OnlineCache." + name).getKeys();
}
public Configuration getOnlineVotes(String name, String num) {
return getData().getSection("OnlineCache." + name + "." + num);
}
public Collection<String> getPlayers() {
return getData().getSection("OnlineCache").getKeys();
}
public Collection<String> getServers() {
return getData().getSection("VoteCache").getKeys();
}
public Configuration getTimedVoteCache(String key) {
return getData().getSection("TimedVoteCache." + key);
}
public Collection<String> getTimedVoteCache() {
return getData().getSection("TimedVoteCache").getKeys();
}
public Collection<String> getServerVotes(String server) {
return getData().getSection("VoteCache." + server).getKeys();
}
public Configuration getServerVotes(String server, String num) {
return getData().getSection("VoteCache." + server + "." + num);
}
public void load() {
if (!bungee.getDataFolder().exists()) {
bungee.getDataFolder().mkdir();
}
File yamlFile = new File(bungee.getDataFolder(), "votecache.yml");
File file = new File(bungee.getDataFolder(), "votecache.json");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
if (yamlFile.exists()) {
try {
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
.load(new File(bungee.getDataFolder(), "votecache.yml"));
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldvotecache.yml"));
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
new File(bungee.getDataFolder(), "oldvotecache.yml"));
} catch (IOException e) {
e.printStackTrace();
}
save();
}
try {
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
.load(new File(bungee.getDataFolder(), "votecache.json"));
} catch (IOException e) {
e.printStackTrace();
}
}
public void save() {
try {
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
new File(bungee.getDataFolder(), "votecache.json"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
File diff suppressed because it is too large. Load diff
@@ -1,115 +0,0 @@
package com.bencodez.votingplugin.bungee;
import com.bencodez.advancedcore.api.time.TimeType;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
public class VotingPluginBungeeCommand extends Command {
private VotingPluginBungee bungee;
public VotingPluginBungeeCommand(VotingPluginBungee bungee) {
super("votingpluginbungee", "votingplugin.admin");
this.bungee = bungee;
}
@Override
public void execute(CommandSender sender, String[] args) {
if (sender.hasPermission("votingplugin.admin")) {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("reload")) {
bungee.reload(false);
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
}
if (args[0].equalsIgnoreCase("reloadmysql")) {
bungee.reload(true);
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee with MySQL"));
}
if (args[0].equalsIgnoreCase("vote")) {
if (args.length >= 2) {
String user = args[1];
String site = args[2];
bungee.vote(user, site, false, true, 0, null, null);
sender.sendMessage(new TextComponent("Sending vote"));
}
}
if (args[0].equalsIgnoreCase("forcetimechange")) {
if (args.length >= 2) {
bungee.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
sender.sendMessage(new TextComponent("Triggering time change: " + args[1]));
}
}
if (args[0].equalsIgnoreCase("status")) {
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
sender.sendMessage(new TextComponent(
"&aChecking status, waiting for response, check console, method: sockets"));
bungee.status(sender);
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
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/redis method, command unavailable"));
}
}
if (args[0].equalsIgnoreCase("multiproxystatus")) {
bungee.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
sender.sendMessage(new TextComponent("Sending status message"));
}
if (args[0].equalsIgnoreCase("help")) {
TextComponent[] msg = new TextComponent[7];
msg[0] = new TextComponent("&avotingpluginbungee reload - Reload plugin");
msg[1] = new TextComponent("&avotingpluginbungee reloadmysql - Reload plugin including mysql");
msg[2] = new TextComponent("&avotingpluginbungee vote (player) (servicesite) - Send bungee vote");
msg[3] = new TextComponent("&avotingpluginbungee status - Check socket connection status");
msg[4] = new TextComponent("&avotingpluginbungee forcetimechange (timetype) - Force a time change");
msg[5] = new TextComponent("&avotingpluginbungee voteparty force - Force a vote party");
msg[6] = new TextComponent(
"&avotingpluginbungee voteparty setvotecount (number) - Set current vote party votes");
sender.sendMessage(msg);
}
if (args[0].equalsIgnoreCase("voteparty")) {
if (args.length > 1) {
if (args[1].equalsIgnoreCase("Force")) {
bungee.setCurrentVotePartyVotes(bungee.getCurrentVotePartyVotesRequired());
bungee.checkVoteParty();
sender.sendMessage(new TextComponent("Vote party forced"));
}
if (args.length > 2) {
if (args[1].equalsIgnoreCase("SetVoteCount")) {
if (isInt(args[2])) {
bungee.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
sender.sendMessage(new TextComponent("Set current vote party votes to " + args[2]));
}
}
}
}
}
}
} else {
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!"));
}
}
public boolean isInt(String st) {
if (st == null) {
return false;
}
try {
@SuppressWarnings("unused")
int num = Integer.parseInt(st);
return true;
} catch (NumberFormatException ex) {
return false;
}
}
}
@@ -1,31 +0,0 @@
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;
}
}
@@ -1,127 +0,0 @@
package com.bencodez.votingplugin.bungee.velocity;
import com.bencodez.advancedcore.api.time.TimeType;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
public class VotingPluginVelocityCommand implements SimpleCommand {
private VotingPluginVelocity plugin;
public VotingPluginVelocityCommand(VotingPluginVelocity plugin) {
this.plugin = plugin;
}
@Override
public void execute(final Invocation invocation) {
CommandSource source = invocation.source();
// Get the arguments after the command alias
String[] args = invocation.arguments();
if (args.length > 0) {
if (args[0].equalsIgnoreCase("reload")) {
plugin.reload(false);
source.sendMessage(Component.text("Reloading VotingPluginBungee").color(NamedTextColor.AQUA));
}
if (args[0].equalsIgnoreCase("reloadmysql")) {
plugin.reload(true);
source.sendMessage(Component.text("Reloading VotingPluginBungee MySQL").color(NamedTextColor.AQUA));
}
if (args[0].equalsIgnoreCase("vote")) {
if (args.length >= 2) {
String user = args[1];
String site = args[2];
plugin.vote(user, site, false, true, 0, null, null);
source.sendMessage(Component.text("Sending vote").color(NamedTextColor.AQUA));
}
}
if (args[0].equalsIgnoreCase("forcetimechange")) {
if (args.length >= 2) {
plugin.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
source.sendMessage(Component.text("Triggering time change: " + args[1]).color(NamedTextColor.AQUA));
}
}
if (args[0].equalsIgnoreCase("status")) {
if (plugin.getMethod().equals(BungeeMethod.SOCKETS)) {
source.sendMessage(
Component.text("Checking status, waiting for response, check console, method: sockets")
.color(NamedTextColor.AQUA));
plugin.status();
} else if (plugin.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
source.sendMessage(Component
.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.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
source.sendMessage(Component.text("Sending status message").color(NamedTextColor.AQUA));
}
if (args[0].equalsIgnoreCase("help")) {
String[] msg = new String[7];
msg[0] = "votingpluginbungee reload - Reload plugin";
msg[1] = "votingpluginbungee reloadmysql - Reload plugin including mysql";
msg[2] = "votingpluginbungee vote (player) (servicesite) - Send bungee vote";
msg[3] = "votingpluginbungee status - Check socket connection status";
msg[4] = "&avotingpluginbungee forcetimechange (timetype) - Force a time change";
msg[5] = "&avotingpluginbungee voteparty force - Force a vote party";
msg[6] = "&avotingpluginbungee voteparty setvotecount (number) - Set current vote party votes";
for (String m : msg) {
source.sendMessage(Component.text(m).color(NamedTextColor.AQUA));
}
}
if (args[0].equalsIgnoreCase("voteparty")) {
if (args.length > 1) {
if (args[1].equalsIgnoreCase("Force")) {
plugin.setCurrentVotePartyVotes(plugin.getCurrentVotePartyVotesRequired());
plugin.checkVoteParty();
source.sendMessage(Component.text("Vote party forced").color(NamedTextColor.AQUA));
}
if (args.length > 2) {
if (args[1].equalsIgnoreCase("SetVoteCount")) {
if (isInt(args[2])) {
plugin.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
source.sendMessage(Component.text("Set current vote party votes to " + args[2])
.color(NamedTextColor.AQUA));
}
}
}
}
}
}
}
public boolean isInt(String st) {
if (st == null) {
return false;
}
try {
@SuppressWarnings("unused")
int num = Integer.parseInt(st);
return true;
} catch (NumberFormatException ex) {
return false;
}
}
@Override
public boolean hasPermission(final Invocation invocation) {
return invocation.source().hasPermission("votingpluginbungee.admin");
}
}
@@ -13,30 +13,34 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.eclipse.paho.client.mqttv3.MqttException;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.time.TimeType;
import com.bencodez.advancedcore.api.user.UserStorage;
import com.bencodez.advancedcore.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.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.bungee.BungeeVersion;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.encryption.EncryptionHandler;
import com.bencodez.simpleapi.servercomm.global.GlobalMessageHandler;
import com.bencodez.simpleapi.servercomm.global.GlobalMessageListener;
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler;
import com.bencodez.simpleapi.servercomm.mqtt.MqttServerComm;
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler.MessageHandler;
import com.bencodez.simpleapi.servercomm.pluginmessage.PluginMessageHandler;
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
import com.bencodez.simpleapi.sql.data.DataValue;
import com.bencodez.simpleapi.sql.data.DataValueBoolean;
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigSpigot;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.proxy.BungeeMessageData;
import com.bencodez.votingplugin.proxy.BungeeMethod;
import com.bencodez.votingplugin.proxy.BungeeVersion;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -78,29 +82,6 @@ public class BungeeHandler implements Listener {
this.plugin = plugin;
}
public void close() {
if (socketHandler != null) {
socketHandler.closeConnection();
}
if (clientHandler != null) {
clientHandler.stopConnection();
}
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
if (globalDataHandler != null) {
globalDataHandler.getGlobalMysql().close();
}
}
/*
* @EventHandler public void onDateChange(DateChangedEvent event) { if
* (method.equals(BungeeMethod.PLUGINMESSAGING)) {
* plugin.getPluginMessaging().sendPluginMessage("timeupdate",
* plugin.getServerDataFile().getPrevMonth() + "//" +
* plugin.getServerDataFile().getPrevDay() + "//" +
* plugin.getServerDataFile().getPrevWeekDay()); } }
*/
public void checkGlobalData() {
HashMap<String, DataValue> data = globalDataHandler.getExact(plugin.getBungeeSettings().getServer());
// plugin.debug(data.toString());
@@ -131,19 +112,21 @@ public class BungeeHandler implements Listener {
}
if (forceUpdate) {
HashMap<String, DataValue> dataToSet = new HashMap<String, DataValue>();
HashMap<String, DataValue> dataToSet = new HashMap<>();
dataToSet.put("FinishedProcessing", new DataValueBoolean(true));
dataToSet.put("Processing", new DataValueBoolean(false));
globalDataHandler.setData(plugin.getBungeeSettings().getServer(), dataToSet);
}
}
public boolean checkGlobalDataTimeValue(DataValue data) {
if (data.isBoolean()) {
return data.getBoolean();
}
return Boolean.valueOf(data.getString());
}
/*
* @EventHandler public void onDateChange(DateChangedEvent event) { if
* (method.equals(BungeeMethod.PLUGINMESSAGING)) {
* plugin.getPluginMessaging().sendPluginMessage("timeupdate",
* plugin.getServerDataFile().getPrevMonth() + "//" +
* plugin.getServerDataFile().getPrevDay() + "//" +
* plugin.getServerDataFile().getPrevWeekDay()); } }
*/
public boolean checkGlobalDataTime(TimeType type, HashMap<String, DataValue> data) {
boolean isProcessing = false;
@@ -167,101 +150,31 @@ public class BungeeHandler implements Listener {
plugin.debug("Detected time change from bungee: " + type.toString());
plugin.getTimeChecker().forceChanged(type, false, true, true);
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
getGlobalMessageHandler().sendMessage("TimeChangeFinished",
"" + plugin.getBungeeSettings().getServer());
}
}
return isProcessing;
}
public void loadGlobalMysql() {
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
if (timer != null) {
timer.shutdown();
try {
timer.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
timer.shutdownNow();
}
timer = Executors.newScheduledThreadPool(1);
timer.scheduleWithFixedDelay(new Runnable() {
public boolean checkGlobalDataTimeValue(DataValue data) {
if (data.isBoolean()) {
return data.getBoolean();
}
return Boolean.valueOf(data.getString());
}
@Override
public void run() {
checkGlobalData();
}
}, 60, 10, TimeUnit.SECONDS);
timer.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
globalDataHandler.setString(plugin.getBungeeSettings().getServer(), "LastOnline",
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli());
}
}, 1, 60, TimeUnit.MINUTES);
if (globalDataHandler != null) {
globalDataHandler.getGlobalMysql().close();
}
if (plugin.getBungeeSettings().isGloblalDataUseMainMySQL()
&& plugin.getStorageType().equals(UserStorage.MYSQL)) {
globalDataHandler = new GlobalDataHandler(
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
@Override
public void warning(String text) {
plugin.getLogger().warning(text);
}
@Override
public void severe(String text) {
plugin.getLogger().severe(text);
}
@Override
public void debug(Exception e) {
plugin.debug(e);
}
@Override
public void debug(String text) {
plugin.debug(text);
}
});
} else {
globalDataHandler = new GlobalDataHandler(
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
@Override
public void warning(String text) {
plugin.getLogger().warning(text);
}
@Override
public void severe(String text) {
plugin.getLogger().severe(text);
}
@Override
public void debug(Exception e) {
plugin.debug(e);
}
@Override
public void debug(String text) {
plugin.debug(text);
}
});
}
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
globalDataHandler.getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
plugin.getTimeChecker().setProcessingEnabled(false);
public void close() {
if (socketHandler != null) {
socketHandler.closeConnection();
}
if (clientHandler != null) {
clientHandler.stopConnection();
}
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
if (globalDataHandler != null) {
globalDataHandler.getGlobalMysql().close();
}
}
@@ -283,16 +196,27 @@ public class BungeeHandler implements Listener {
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
} else if (method.equals(BungeeMethod.SOCKETS)) {
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> list = new ArrayList<>();
list.add(subChannel);
list.addAll(ArrayUtils.getInstance().convert(messageData));
sendData(ArrayUtils.getInstance().convert(list));
list.addAll(ArrayUtils.convert(messageData));
sendData(ArrayUtils.convert(list));
} else if (method.equals(BungeeMethod.REDIS)) {
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> list = new ArrayList<>();
list.add(subChannel);
list.addAll(ArrayUtils.getInstance().convert(messageData));
list.addAll(ArrayUtils.convert(messageData));
redisHandler.sendMessage(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
ArrayUtils.getInstance().convert(list));
ArrayUtils.convert(list));
} else if (method.equals(BungeeMethod.MQTT)) {
ArrayList<String> list = new ArrayList<>();
list.add(subChannel);
list.addAll(ArrayUtils.convert(messageData));
try {
mqttHandler.publish(plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/proxy",
String.join(":", list));
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
@@ -415,10 +339,6 @@ public class BungeeHandler implements Listener {
.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));
@@ -596,29 +516,28 @@ public class BungeeHandler implements Listener {
});
if (method.equals(BungeeMethod.MYSQL)) {
plugin.registerBungeeChannels("vp:vp");
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
} 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);
public void debug(String message) {
if (plugin.getBungeeSettings().isBungeeDebug()) {
plugin.debug(message);
}
}
@Override
public void debug(String message) {
if (plugin.getBungeeSettings().isBungeeDebug()) {
plugin.debug(message);
protected void onMessage(String channel, String[] message) {
plugin.getLogger().info(channel + ArrayUtils.makeStringList(ArrayUtils.convert(message)));
if (message.length > 0) {
ArrayList<String> list = new ArrayList<>();
for (int i = 1; i < message.length; i++) {
list.add(message[i]);
}
globalMessageHandler.onMessage(message[0], list);
}
}
};
@@ -636,87 +555,30 @@ public class BungeeHandler implements Listener {
redisThread.start();
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
plugin.registerBungeeChannels("vp:vp");
if (plugin.getBungeeSettings().isPluginMessageEncryption()) {
encryptionHandler = new EncryptionHandler(plugin.getName(),
new File(plugin.getDataFolder(), "secretkey.key"));
plugin.getPluginMessaging().setEncryptionHandler(encryptionHandler);
}
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
bungeeVotePartyRequired = plugin.getServerData().getBungeeVotePartyRequired();
plugin.getPluginMessaging().setDebug(plugin.getBungeeSettings().isBungeeDebug());
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
plugin.getPluginMessaging().add(new PluginMessageHandler() {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
globalMessageHandler.onMessage("Vote", args);
}
});
globalMessageHandler.onMessage(subChannel, args);
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteOnline") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
globalMessageHandler.onMessage("VoteOnline", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteUpdate") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
globalMessageHandler.onMessage("VoteUpdate", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("BungeeTimeChange") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
globalMessageHandler.onMessage("BungeeTimeChange", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
globalMessageHandler.onMessage("VoteBroadcast", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcastOffline") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
globalMessageHandler.onMessage("VoteBroadcastOffline", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
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) {
globalMessageHandler.onMessage("VotePartyBungee", args);
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBroadcast") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
globalMessageHandler.onMessage("VotePartyBroadcast", args);
}
});
} else if (method.equals(BungeeMethod.SOCKETS)) {
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
encryptionHandler = new EncryptionHandler(plugin.getName(),
new File(plugin.getDataFolder(), "secretkey.key"));
clientHandler = new ClientHandler(plugin.getBungeeSettings().getBungeeServerHost(),
plugin.getBungeeSettings().getBungeeServerPort(), encryptionHandler,
@@ -732,156 +594,153 @@ public class BungeeHandler implements Listener {
}
};
socketHandler.add(new SocketReceiver("bungeevote") {
socketHandler.add(new SocketReceiver() {
@Override
public void onReceive(String[] data) {
if (data.length > 5) {
plugin.extraDebug("BungeeVote from " + data[2] + ", processing");
String uuid = data[1];
VotingPluginUser user = null;
if (!uuid.isEmpty()) {
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
} else {
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
}
user.cache();
if (plugin.getBungeeSettings().isPerServerPoints()) {
user.addPoints(plugin.getConfigFile().getPointsOnVote());
}
user.bungeeVote(data[3], new BungeeMessageData(data[4]), !Boolean.valueOf(data[5]));
}
globalMessageHandler.onMessage(data[0], ArrayUtils.convertAndRemoveFirst(data));
}
});
socketHandler.add(new SocketReceiver("BungeeTimeChange") {
@Override
public void onReceive(String[] data) {
checkGlobalData();
} else if (method.equals(BungeeMethod.MQTT)) {
try {
String id = plugin.getBungeeSettings().getMqttClientID();
if (id.isEmpty()) {
id = plugin.getOptions().getServer();
}
});
mqttHandler = new MqttHandler(new MqttServerComm(plugin.getBungeeSettings().getMqttClientID(),
plugin.getBungeeSettings().getMqttBrokerURL(), plugin.getBungeeSettings().getMqttUsername(),
plugin.getBungeeSettings().getMqttPassword()), 2);
mqttHandler.subscribe(plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/"
+ plugin.getOptions().getServer(), new MessageHandler() {
socketHandler.add(new SocketReceiver("bungeevoteonline") {
@Override
public void onMessage(String topic, String payload) {
String[] message = payload.split(":");
@Override
public void onReceive(String[] data) {
if (data.length > 5) {
plugin.extraDebug("BungeeVoteOnline from " + data[2] + ", processing");
String uuid = data[1];
VotingPluginUser user = null;
if (!uuid.isEmpty()) {
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
} else {
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
}
user.cache();
if (plugin.getBungeeSettings().isPerServerPoints()) {
user.addPoints(plugin.getConfigFile().getPointsOnVote());
}
user.bungeeVoteOnline(data[3], new BungeeMessageData(data[4]), !Boolean.valueOf(data[5]));
}
}
});
socketHandler.add(new SocketReceiver("BroadcastOffline") {
@Override
public void onReceive(String[] data) {
if (data.length > 2) {
String votes = data[0];
String p = data[1];
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
}
});
socketHandler.add(new SocketReceiver("BungeeBroadcast") {
@Override
public void onReceive(String[] data) {
if (data.length > 2) {
VoteSite site = plugin.getVoteSite(data[1], true);
String p = data[3];
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
if (site != null) {
site.broadcastVote(user, false);
} else {
plugin.getLogger().warning("No votesite for " + data[1]);
}
}
}
});
socketHandler.add(new SocketReceiver("Broadcast") {
@Override
public void onReceive(String[] data) {
if (data.length > 2) {
VoteSite site = plugin.getVoteSite(data[1], true);
String p = data[2];
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
if (site != null) {
site.broadcastVote(user, false);
} else {
plugin.getLogger().warning("No votesite for " + data[1]);
}
}
}
});
socketHandler.add(new SocketReceiver("Status") {
@Override
public void onReceive(String[] data) {
if (data.length > 0) {
plugin.getLogger().info("Received status command, sending status back");
sendData("StatusOkay", plugin.getOptions().getServer());
}
}
});
socketHandler.add(new SocketReceiver("BungeeUpdate") {
@Override
public void onReceive(String[] data) {
plugin.setUpdate(true);
}
});
socketHandler.add(new SocketReceiver("VotePartyBungee") {
@Override
public void onReceive(String[] data) {
for (Player p : Bukkit.getOnlinePlayers()) {
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
}
}
});
socketHandler.add(new SocketReceiver("VotePartyBroadcast") {
@Override
public void onReceive(String[] data) {
String broadcast = data[0];
MiscUtils.getInstance().broadcast(broadcast);
}
});
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
if (message.length > 0) {
globalMessageHandler.onMessage(message[0],
ArrayUtils.convertAndRemoveFirst(message));
}
}
});
} catch (MqttException e) {
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
}
}
@Getter
private MqttHandler mqttHandler;
public void loadGlobalMysql() {
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
if (timer != null) {
timer.shutdown();
try {
timer.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
timer.shutdownNow();
}
timer = Executors.newScheduledThreadPool(1);
timer.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
checkGlobalData();
}
}, 60, 10, TimeUnit.SECONDS);
timer.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
globalDataHandler.setString(plugin.getBungeeSettings().getServer(), "LastOnline",
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli());
}
}, 1, 60, TimeUnit.MINUTES);
if (globalDataHandler != null) {
globalDataHandler.getGlobalMysql().close();
}
if (plugin.getBungeeSettings().isGloblalDataUseMainMySQL()
&& plugin.getStorageType().equals(UserStorage.MYSQL)) {
globalDataHandler = new GlobalDataHandler(
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
@Override
public void debugEx(Exception e) {
plugin.debug(e);
}
@Override
public void debugLog(String text) {
plugin.debug(text);
}
@Override
public void info(String text) {
plugin.getLogger().info(text);
}
@Override
public void logSevere(String text) {
plugin.getLogger().severe(text);
}
@Override
public void warning(String text) {
plugin.getLogger().warning(text);
}
});
} else {
globalDataHandler = new GlobalDataHandler(
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
@Override
public void debugEx(Exception e) {
plugin.debug(e);
}
@Override
public void debugLog(String text) {
plugin.debug(text);
}
@Override
public void info(String text) {
plugin.getLogger().info(text);
}
@Override
public void logSevere(String text) {
plugin.getLogger().severe(text);
}
@Override
public void warning(String text) {
plugin.getLogger().warning(text);
}
});
}
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
globalDataHandler.getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
globalDataHandler.getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
plugin.getTimeChecker().setProcessingEnabled(false);
}
}
public void sendData(String... strings) {
@@ -7,6 +7,7 @@ import java.net.URL;
import java.security.CodeSource;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -41,22 +42,25 @@ import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.javascript.JavascriptPlaceholderRequest;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
import com.bencodez.advancedcore.api.rewards.Reward;
import com.bencodez.advancedcore.api.rewards.RewardEditData;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.rewards.RewardPlaceholderHandle;
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection;
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectInt;
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator;
import com.bencodez.advancedcore.api.skull.SkullHandler;
import com.bencodez.advancedcore.api.updater.Updater;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.api.yml.YMLConfig;
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInjectConfigurationSection;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
import com.bencodez.advancedcore.logger.Logger;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.simpleapi.file.YMLConfig;
import com.bencodez.simpleapi.nms.NMSManager;
import com.bencodez.simpleapi.skull.SkullCache;
import com.bencodez.simpleapi.sql.Column;
import com.bencodez.simpleapi.updater.Updater;
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
import com.bencodez.votingplugin.commands.CommandLoader;
import com.bencodez.votingplugin.commands.executers.CommandAdminVote;
@@ -68,6 +72,7 @@ import com.bencodez.votingplugin.config.BungeeSettings;
import com.bencodez.votingplugin.config.Config;
import com.bencodez.votingplugin.config.ConfigVoteSites;
import com.bencodez.votingplugin.config.GUI;
import com.bencodez.votingplugin.config.ShopFile;
import com.bencodez.votingplugin.config.SpecialRewardsConfig;
import com.bencodez.votingplugin.cooldown.CoolDownCheck;
import com.bencodez.votingplugin.data.ServerData;
@@ -112,7 +117,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
private ArrayList<CommandHandler> adminVoteCommand;
@Getter
private LinkedHashMap<java.util.UUID, ArrayList<String>> advancedTab = new LinkedHashMap<java.util.UUID, ArrayList<String>>();
private LinkedHashMap<java.util.UUID, ArrayList<String>> advancedTab = new LinkedHashMap<>();
@Getter
private BroadcastHandler broadcastHandler;
@@ -141,9 +146,16 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private GUI gui;
@Getter
private ShopFile shopFile;
@Getter
private LinkedHashMap<TopVoterPlayer, Integer> lastMonthTopVoter;
@Getter
@Setter
private LinkedHashMap<YearMonth, LinkedHashMap<TopVoterPlayer, Integer>> previousMonthsTopVoters;
@Getter
private MVdWPlaceholders mvdwPlaceholders;
@@ -224,6 +236,17 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private UserManager votingPluginUserManager;
@Getter
private TimeQueueHandler timeQueueHandler;
@Getter
private ServiceSiteHandler serviceSiteHandler;
@Getter
private long lastBackgroundTaskTimeTaken = -1;
private boolean firstTimeLoaded = false;
public void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
getRewardHandler().addDirectlyDefined(directlyDefinedReward);
}
@@ -237,6 +260,26 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
}
public void checkFirstTimeLoaded() {
if (!firstTimeLoaded) {
if (getGui().isChestVoteTopUseSkull()) {
int maxToLoad = 200;
for (TopVoter top : topVoter.keySet()) {
int num = 1;
Set<TopVoterPlayer> players = topVoter.get(top).keySet();
for (TopVoterPlayer p : players) {
if (num <= maxToLoad) {
getSkullCacheHandler().addToCache(p.getUuid(), p.getPlayerName());
}
num++;
}
}
}
}
firstTimeLoaded = true;
}
/**
* Check votifier.
*/
@@ -274,7 +317,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
public ArrayList<TopVoterPlayer> convertSet(Set<TopVoterPlayer> set) {
return new ArrayList<TopVoterPlayer>(set);
return new ArrayList<>(set);
}
@Override
@@ -285,7 +328,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
public LinkedHashMap<TopVoterPlayer, Integer> getTopVoter(TopVoter top) {
LinkedHashMap<TopVoterPlayer, Integer> top1 = topVoter.get(top);
if (top1 == null) {
top1 = new LinkedHashMap<TopVoterPlayer, Integer>();
top1 = new LinkedHashMap<>();
}
return top1;
}
@@ -296,6 +339,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
* @param uuid the uuid
* @return the user
*/
@Deprecated
public VotingPluginUser getUser(UUID uuid) {
return getVotingPluginUserManager().getVotingPluginUser(uuid);
}
@@ -343,16 +387,6 @@ 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);
@@ -385,6 +419,16 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
public ArrayList<VoteSite> getVoteSitesEnabled() {
ArrayList<VoteSite> sites = new ArrayList<>();
for (VoteSite site : getVoteSites()) {
if (site.isEnabled()) {
sites.add(site);
}
}
return sites;
}
public String getVoteSiteServiceSite(String name) {
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames(true);
if (name == null) {
@@ -394,10 +438,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
for (String siteName : sites) {
String URL = getConfigVoteSites().getServiceSite(siteName);
if (URL != null) {
if (URL.equalsIgnoreCase(name)) {
return URL;
}
if (name.equalsIgnoreCase(siteName)) {
if (URL.equalsIgnoreCase(name) || name.equalsIgnoreCase(siteName)) {
return URL;
}
}
@@ -426,6 +467,15 @@ public class VotingPluginMain extends AdvancedCorePlugin {
return false;
}
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");
}
}
public void loadDirectlyDefined() {
getRewardHandler().getDirectlyDefinedRewards().clear();
// AllSites reward
@@ -896,27 +946,27 @@ public class VotingPluginMain extends AdvancedCorePlugin {
});
}
for (String identifier : plugin.getGui().getChestShopIdentifiers()) {
addDirectlyDefinedRewards(new DirectlyDefinedReward("CHEST.Shop." + identifier + ".Rewards") {
for (String identifier : plugin.getShopFile().getShopIdentifiers()) {
addDirectlyDefinedRewards(new DirectlyDefinedReward("Shop." + identifier + ".Rewards") {
@Override
public void createSection(String key) {
getGui().createSection(key);
getShopFile().createSection(key);
}
@Override
public ConfigurationSection getFileData() {
return getGui().getData();
return getShopFile().getData();
}
@Override
public void save() {
getGui().saveData();
getShopFile().saveData();
}
@Override
public void setData(String path, Object value) {
getGui().setValue(path, value);
getShopFile().setValue(path, value);
}
});
}
@@ -1003,6 +1053,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
private void loadVoteTimer() {
voteTimer = Executors.newSingleThreadScheduledExecutor();
}
/**
* Log vote.
*
@@ -1025,27 +1079,25 @@ public class VotingPluginMain extends AdvancedCorePlugin {
new VotingPluginMetrics().load(plugin);
}
private void loadVoteTimer() {
voteTimer = Executors.newSingleThreadScheduledExecutor();
}
@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() {
// auto conversion for Shop.yml
if (plugin.getShopFile().isJustCreated()) {
if (!plugin.getGui().isJustCreated() && !getServerData().isVoteShopConverted()) {
plugin.getLogger().warning("Converting VoteShop configuration to Shop.yml from GUI.yml");
plugin.getShopFile().convertFromGUIFile();
}
getServerData().setShopConverted(true);
} else if (!getServerData().isVoteShopConverted()) {
getServerData().setShopConverted(true);
}
loadVersionFile();
getOptions().setServer(bungeeSettings.getServer());
// only purges if enabled in config
getVotingPluginUserManager().purgeOldPlayersNoData();
voteTester = new VoteTester(plugin);
loadVoteTimer();
@@ -1059,8 +1111,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new VotingPluginExpansion(this).register();
getLogger().info("Loading PlaceholderAPI expansion");
if (getConfigFile().isLoadInteralExpansion()) {
new VotingPluginExpansion(this).register();
getLogger().info("Loading PlaceholderAPI expansion");
}
}
registerCommands();
@@ -1087,20 +1141,23 @@ public class VotingPluginMain extends AdvancedCorePlugin {
});
topVoterHandler = new TopVoterHandler(this);
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
lastMonthTopVoter = new LinkedHashMap<>();
previousMonthsTopVoters = new LinkedHashMap<>();
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
topVoterHandler.loadLastMonth();
debug("Loaded last month top voters");
topVoterHandler.loadPreviousMonthTopVoters();
}
});
topVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
topVoter = new LinkedHashMap<>();
for (TopVoter top : TopVoter.values()) {
topVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
topVoter.put(top, new LinkedHashMap<>());
}
voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
voteToday = new LinkedHashMap<>();
voteLog = new Logger(plugin, new File(plugin.getDataFolder() + File.separator + "Log", "votelog.txt"));
new AdminGUI(this).loadHook();
@@ -1178,8 +1235,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
ConfigurationSection section, HashMap<String, String> placeholders) {
if (section.getBoolean("Enabled")) {
user.sendBossBar(
StringParser.getInstance().replacePlaceHolder(section.getString("Message", ""),
placeholders),
PlaceholderUtils.replacePlaceHolder(section.getString("Message", ""), placeholders),
section.getString("Color", "BLUE"), section.getString("Style", "SOLID"),
(double) getVotingPluginUserManager().getVotingPluginUser(user).getSitesVotedOn()
/ plugin.getVoteSites().size(),
@@ -1189,6 +1245,69 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
});
getRewardHandler().addInjectedRequirements(new RequirementInjectConfigurationSection("VoteTotal") {
@Override
public boolean onRequirementsRequested(Reward reward, AdvancedCoreUser acUser, ConfigurationSection section,
RewardOptions rewardOptions) {
boolean atleast = section.getBoolean("AtleastMode", false);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(acUser);
for (TopVoter top : TopVoter.values()) {
int required = section.getInt(top.toString(), -1);
if (required >= 0) {
int total = user.getTotal(top);
if (atleast) {
if (total < required) {
debug("Failed requirement " + top.toString() + " " + total + "/" + required);
return false;
}
} else {
if (total != required) {
debug("Failed requirement " + top.toString() + " " + total + "!=" + required);
return false;
}
}
}
}
int milestoneCountRequired = section.getInt("MilestoneCount", -1);
if (milestoneCountRequired >= 0) {
int milestoneCount = user.getMilestoneCount();
if (atleast) {
if (milestoneCount < milestoneCountRequired) {
debug("Failed requirement milestonecount " + milestoneCount + "/" + milestoneCountRequired);
return false;
}
} else {
if (milestoneCount != milestoneCountRequired) {
debug("Failed requirement milestonecount " + milestoneCount + "!="
+ milestoneCountRequired);
return false;
}
}
}
int pointsRequired = section.getInt("Points", -1);
if (pointsRequired >= 0) {
int points = user.getPoints();
if (atleast) {
if (points < pointsRequired) {
debug("Failed requirement points " + points + "/" + pointsRequired);
return false;
}
} else {
if (points != pointsRequired) {
debug("Failed requirement points " + points + "!=" + pointsRequired);
return false;
}
}
}
return true;
}
});
for (final TopVoter top : TopVoter.values()) {
getRewardHandler().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
@@ -1206,7 +1325,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
if (getProfile().contains("dev")) {
if (plugin.getDescription().getVersion().contains("SNAPSHOT")) {
plugin.getLogger().info(
"Using dev build, this is not a stable build, use at your own risk. Build number: " + buildNumber);
}
@@ -1257,9 +1376,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
@Getter
private ServiceSiteHandler serviceSiteHandler;
/*
* (non-Javadoc)
*
@@ -1269,19 +1385,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
public void onPreLoad() {
plugin = this;
// disable plugin for older versions below 1.12
if (NMSManager.getInstance().isVersion("1.7", "1.8", "1.9", "1.10", "1.11")) {
plugin.getLogger().severe("Detected running " + Bukkit.getVersion()
+ ", this version is not supported on this build, read the plugin page. Disabling...");
if (!configFile.isOverrideVersionDisable()) {
Bukkit.getPluginManager().disablePlugin(this);
return;
} else {
plugin.getLogger().warning("Overriding version disable, beware of using this! This may cause issues!");
}
}
setupFiles();
loadVoteSites();
@@ -1413,8 +1516,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
specialRewardsConfig.reloadData();
gui.reloadData();
shopFile.reloadData();
bungeeSettings.reloadData();
updateAdvancedCoreHook();
reloadAdvancedCore(userStorage);
if (bungeeSettings.isUseBungeecoord()) {
if (getBungeeHandler() == null) {
@@ -1430,10 +1537,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
broadcastHandler.schedule(getConfigFile().getFormatAlternateBroadcastDelay());
}
updateAdvancedCoreHook();
plugin.loadVoteSites();
reloadAdvancedCore(userStorage);
getOptions().setServer(bungeeSettings.getServer());
if (userStorage) {
placeholders.load();
@@ -1472,19 +1577,19 @@ public class VotingPluginMain extends AdvancedCorePlugin {
bungeeSettings = new BungeeSettings(this);
bungeeSettings.setup();
serverData = new ServerData(this);
gui = new GUI(this);
gui.setup();
serverData = new ServerData(this);
shopFile = new ShopFile(this);
shopFile.setup();
checkYMLError();
plugin.debug("Loaded Files");
}
@Getter
private long lastBackgroundTaskTimeTaken = -1;
public void update() {
if (update || configFile.isAlwaysUpdate()) {
if (!updateStarted && plugin != null) {
@@ -1495,6 +1600,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
synchronized (plugin) {
if (plugin != null && plugin.isEnabled()) {
getUserManager().getDataManager().clearCacheBasic();
SkullCache.flushWeek();
plugin.debug("Starting background task, current cached users: "
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
@@ -1503,17 +1609,17 @@ public class VotingPluginMain extends AdvancedCorePlugin {
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
long startTime = System.currentTimeMillis();
LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>> voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>> voteToday = new LinkedHashMap<>();
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter = new LinkedHashMap<>();
ArrayList<TopVoter> topVotersToCheck = new ArrayList<TopVoter>();
ArrayList<TopVoter> topVotersToCheck = new ArrayList<>();
for (TopVoter top : TopVoter.values()) {
if (plugin == null) {
return;
}
if (plugin.getConfigFile().getLoadTopVoter(top)) {
topVotersToCheck.add(top);
tempTopVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
tempTopVoter.put(top, new LinkedHashMap<>());
}
}
boolean topVoterIgnorePermissionUse = plugin.getConfigFile()
@@ -1530,61 +1636,59 @@ public class VotingPluginMain extends AdvancedCorePlugin {
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 = getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
for (TopVoter top : topVotersToCheck) {
int total = user.getTotal(top);
if (total > 0) {
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
}
}
}
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
long time = entry.getValue();
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
&& (LocalDateTime.now().getMonthValue() == MiscUtils
.getInstance().getMonthFromMili(time))
&& (LocalDateTime.now().getYear() == MiscUtils
.getInstance().getYearFromMili(time))) {
times.put(entry.getKey(),
LocalDateTime.ofInstant(Instant.ofEpochMilli(time),
ZoneId.systemDefault()));
}
}
}
if (times.keySet().size() > 0) {
voteToday.put(user.getTopVoterPlayer(), times);
}
}
if (extraBackgroundUpdate) {
if (user.isOnline()) {
user.offVote();
}
}
if (plugin != null) {
if (!plugin.getPlaceholders().getCacheLevel().onlineOnly()
|| user.isOnline()) {
plugin.getPlaceholders().onUpdate(user, false);
}
}
user.clearTempCache();
user = null;
}
} else {
if ((plugin == null) || !plugin.isEnabled()) {
return;
}
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
for (TopVoter top : topVotersToCheck) {
int total = user.getTotal(top);
if (total > 0) {
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
}
}
}
HashMap<VoteSite, LocalDateTime> times = new HashMap<>();
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
long time = entry.getValue();
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
&& (LocalDateTime.now().getMonthValue() == MiscUtils
.getInstance().getMonthFromMili(time))
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance()
.getYearFromMili(time))) {
times.put(entry.getKey(), LocalDateTime.ofInstant(
Instant.ofEpochMilli(time), ZoneId.systemDefault()));
}
}
}
if (times.keySet().size() > 0) {
voteToday.put(user.getTopVoterPlayer(), times);
}
}
if (extraBackgroundUpdate) {
if (user.isOnline()) {
user.offVote();
}
}
if (plugin != null) {
if (!plugin.getPlaceholders().getCacheLevel().onlineOnly()
|| user.isOnline()) {
plugin.getPlaceholders().onUpdate(user, false);
}
}
user.clearTempCache();
user = null;
}
}
cols.clear();
cols = null;
@@ -1626,36 +1730,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
}
private boolean firstTimeLoaded = false;
public void checkFirstTimeLoaded() {
if (!firstTimeLoaded) {
if (getGui().isChestVoteTopUseSkull()) {
int maxToLoad = 200;
for (TopVoter top : topVoter.keySet()) {
int num = 1;
Set<TopVoterPlayer> players = topVoter.get(top).keySet();
for (TopVoterPlayer p : players) {
if (num <= maxToLoad) {
SkullHandler.getInstance().loadSkull(p.getPlayerName());
}
num++;
}
}
}
}
firstTimeLoaded = true;
}
public void updateAdvancedCoreHook() {
getJavascriptEngine().put("VotingPlugin", this);
allowDownloadingFromSpigot(15358);
setConfigData(new YMLConfig(this, configFile.getData()) {
@Override
public void setValue(String path, Object value) {
configFile.setValue(path, value);
public void createSection(String key) {
configFile.createSection(key);
}
@Override
@@ -1664,8 +1746,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
@Override
public void createSection(String key) {
configFile.createSection(key);
public void setValue(String path, Object value) {
configFile.setValue(path, value);
}
});
if (bungeeSettings.isUseBungeecoord()) {
@@ -2,7 +2,7 @@ package com.bencodez.votingplugin;
import java.util.concurrent.Callable;
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
import com.bencodez.simpleapi.metrics.BStatsMetrics;
public class VotingPluginMetrics {
@@ -16,9 +16,8 @@ public class VotingPluginMetrics {
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
return "True";
} else {
return "False";
}
return "False";
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite", new Callable<String>() {
@@ -28,9 +27,8 @@ public class VotingPluginMetrics {
if (plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
return "True";
} else {
return "False";
}
return "False";
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_allsites", new Callable<String>() {
@@ -40,9 +38,8 @@ public class VotingPluginMetrics {
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
return "True";
} else {
return "False";
}
return "False";
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_cumulative", new Callable<String>() {
@@ -51,14 +48,13 @@ public class VotingPluginMetrics {
public String call() throws Exception {
if (plugin.getSpecialRewardsConfig().getCumulativeVotes().size() == 0) {
return "False";
} else {
for (String cum : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(Integer.parseInt(cum))) {
return "True";
}
}
return "False";
}
for (String cum : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(Integer.parseInt(cum))) {
return "True";
}
}
return "False";
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_voteparty", new Callable<String>() {
@@ -67,9 +63,8 @@ public class VotingPluginMetrics {
public String call() throws Exception {
if (!plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
return "False";
} else {
return "True";
}
return "True";
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("placeholder_cache_level", new Callable<String>() {
@@ -85,14 +80,13 @@ public class VotingPluginMetrics {
public String call() throws Exception {
if (plugin.getSpecialRewardsConfig().getMilestoneVotes().size() == 0) {
return "False";
} else {
for (String milestone : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(Integer.parseInt(milestone))) {
return "True";
}
}
return "False";
}
for (String milestone : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(Integer.parseInt(milestone))) {
return "True";
}
}
return "False";
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward", new Callable<String>() {
@@ -102,9 +96,8 @@ public class VotingPluginMetrics {
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
return "True";
} else {
return "False";
}
return "False";
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakday", new Callable<String>() {
@@ -186,9 +179,11 @@ public class VotingPluginMetrics {
int total = plugin.getUserManager().getAllUUIDs().size();
if (total > 800000) {
return ">800000";
} else if (total > 700000) {
}
if (total > 700000) {
return "700000-800000";
} else if (total > 600000) {
}
if (total > 600000) {
return "600000-700000";
} else if (total > 500000) {
return "500000-600000";
@@ -255,9 +250,8 @@ public class VotingPluginMetrics {
public String call() throws Exception {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
return "" + plugin.getBungeeHandler().getMethod().toString();
} else {
return "Disabled";
}
return "Disabled";
}
}));
if (plugin.getBungeeSettings().isUseBungeecoord()) {
@@ -10,14 +10,15 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
public class BroadcastHandler {
private VotingPluginMain plugin;
private ScheduledExecutorService timer;
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<String>();
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<>();
public BroadcastHandler(VotingPluginMain plugin, int delay) {
this.plugin = plugin;
@@ -30,8 +31,7 @@ public class BroadcastHandler {
for (int i = 0; i < size; i++) {
votedPlayers.poll();
}
String bc = StringParser.getInstance()
.colorize(plugin.getConfigFile().getFormatAlternateBroadcastBroadcast());
String bc = MessageAPI.colorize(plugin.getConfigFile().getFormatAlternateBroadcastBroadcast());
String playersText = "";
while (!votedPlayers.isEmpty()) {
playersText += votedPlayers.remove();
@@ -39,11 +39,11 @@ public class BroadcastHandler {
playersText += ", ";
}
}
HashMap<String, String> placeholders = new HashMap<String, String>();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("numberofplayers", "" + size);
placeholders.put("players", playersText);
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
ArrayList<Player> players = new ArrayList<Player>();
bc = PlaceholderUtils.replacePlaceHolder(bc, placeholders);
ArrayList<Player> players = new ArrayList<>();
for (Player p : Bukkit.getOnlinePlayers()) {
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
players.add(p);
@@ -5,7 +5,7 @@ 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.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -36,7 +36,7 @@ public class CommandAdminVote implements CommandExecutor {
}
// invalid command
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
return true;
}
@@ -7,8 +7,8 @@ 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.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -40,15 +40,15 @@ public class CommandAliases implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
ArrayList<String> argsNew = new ArrayList<String>();
ArrayList<String> argsNew = new ArrayList<>();
argsNew.add(cmdHandle.getArgs()[0]);
for (String arg : args) {
argsNew.add(arg);
}
plugin.debug("Attempting cmd...");
plugin.debug("Inputed args: " + ArrayUtils.getInstance().makeStringList(argsNew));
plugin.debug("Inputed args: " + ArrayUtils.makeStringList(argsNew));
ArrayList<CommandHandler> handles = new ArrayList<CommandHandler>();
ArrayList<CommandHandler> handles = new ArrayList<>();
if (adminCommand) {
handles.addAll(plugin.getAdminVoteCommand());
} else {
@@ -73,7 +73,7 @@ public class CommandAliases implements CommandExecutor {
}
if (argsMatch) {
if (cmdHandle.runCommand(sender, ArrayUtils.getInstance().convert(argsNew))) {
if (cmdHandle.runCommand(sender, ArrayUtils.convert(argsNew))) {
plugin.debug("cmd found, ran cmd");
return true;
}
@@ -91,11 +91,9 @@ public class CommandAliases implements CommandExecutor {
// invalid command
if (adminCommand) {
sender.sendMessage(
StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
} else {
sender.sendMessage(
StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
}
return true;
}
@@ -5,7 +5,7 @@ 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.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -61,7 +61,7 @@ public class CommandVote implements CommandExecutor {
}
// invalid command
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
return true;
}
@@ -19,14 +19,14 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueLi
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
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.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.player.PlayerUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty;
import com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative;
@@ -49,7 +49,7 @@ public class AdminGUI {
* @return ArrayList of buttons
*/
public ArrayList<BInventoryButton> adminGUIButtons() {
ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
ArrayList<BInventoryButton> buttons = new ArrayList<>();
buttons.add(new BInventoryButton("&cVoteSites",
new String[] { "&cOnly enabled sites are listed in this section", "&cMiddle Click to create" },
new ItemStack(Material.STONE)) {
@@ -241,7 +241,7 @@ public class AdminGUI {
BInventory inv = new BInventory("VoteSites");
int count = 0;
for (VoteSite voteSite : plugin.getVoteSites()) {
ArrayList<String> lore = new ArrayList<String>();
ArrayList<String> lore = new ArrayList<>();
lore.add("Enabled: " + voteSite.isEnabled());
lore.add("Priority: " + voteSite.getPriority());
@@ -251,17 +251,17 @@ public class AdminGUI {
lore.add("VoteDelay: " + voteSite.getVoteDelay());
lore.add("VoteDelayMin: " + voteSite.getVoteDelayMin());
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore),
new ItemStack(Material.STONE)) {
inv.addButton(count,
new BInventoryButton(voteSite.getKey(), ArrayUtils.convert(lore), new ItemStack(Material.STONE)) {
@Override
public void onClick(ClickEvent event) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getWhoClicked();
openAdminGUIVoteSiteSite(player, voteSite);
Player player = event.getWhoClicked();
openAdminGUIVoteSiteSite(player, voteSite);
}
});
}
});
count++;
}
inv.openInventory(player);
@@ -281,7 +281,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent event) {
ArrayList<String> playerNames = new ArrayList<String>();
ArrayList<String> playerNames = new ArrayList<>();
for (Player p : Bukkit.getOnlinePlayers()) {
playerNames.add(p.getName());
}
@@ -289,7 +289,7 @@ public class AdminGUI {
@Override
public void onInput(Player player, String value) {
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
Object ob = PlayerUtils.getPlayerMeta(plugin, player, "VoteSite");
if (ob != null) {
VoteSite site = (VoteSite) ob;
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
@@ -302,8 +302,8 @@ public class AdminGUI {
});
}
}
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY)
.allowCustomOption(true).request(event.getWhoClicked());
}, ArrayUtils.convert(playerNames)).usingMethod(InputMethod.INVENTORY).allowCustomOption(true)
.request(event.getWhoClicked());
}
});
@@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import net.md_5.bungee.api.chat.TextComponent;
@@ -35,7 +35,7 @@ public class AdminVoteHelp extends GUIHandler {
*/
public ArrayList<TextComponent> adminHelp(CommandSender sender, int page) {
int pagesize = plugin.getConfigFile().getFormatPageSize();
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
ArrayList<TextComponent> msg = new ArrayList<>();
ArrayList<TextComponent> text = adminHelpText(sender);
int maxPage = text.size() / pagesize;
@@ -43,9 +43,9 @@ public class AdminVoteHelp extends GUIHandler {
maxPage++;
}
msg.add(StringParser.getInstance().stringToComp("&6&lVotingPlugin Admin Help " + (page) + "/" + maxPage));
msg.add(StringParser.getInstance().stringToComp("&6&l() = Needed"));
msg.add(StringParser.getInstance().stringToComp("&6&lAliases: adminvote, av"));
msg.add(MessageAPI.stringToComp("&6&lVotingPlugin Admin Help " + (page) + "/" + maxPage));
msg.add(MessageAPI.stringToComp("&6&l() = Needed"));
msg.add(MessageAPI.stringToComp("&6&lAliases: adminvote, av"));
for (int i = pagesize * (page - 1); (i < text.size()) && (i < ((page) * pagesize)); i++) {
msg.add(text.get(i));
@@ -61,8 +61,8 @@ public class AdminVoteHelp extends GUIHandler {
* @return the array list
*/
public ArrayList<TextComponent> adminHelpText(CommandSender sender) {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
ArrayList<TextComponent> msg = new ArrayList<>();
HashMap<String, TextComponent> unsorted = new HashMap<>();
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
@@ -71,7 +71,7 @@ public class AdminVoteHelp extends GUIHandler {
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
}
}
ArrayList<String> unsortedList = new ArrayList<String>();
ArrayList<String> unsortedList = new ArrayList<>();
unsortedList.addAll(unsorted.keySet());
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
for (String cmd : unsortedList) {
@@ -12,7 +12,7 @@ import org.bukkit.permissions.Permission;
import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
public class AdminVotePerms extends GUIHandler {
@@ -40,7 +40,7 @@ public class AdminVotePerms extends GUIHandler {
}
public String[] listPerms(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
for (CommandHandler handle : plugin.getVoteCommand()) {
if (sender instanceof Player) {
@@ -100,7 +100,7 @@ public class AdminVotePerms extends GUIHandler {
maxPage++;
}
ArrayList<String> text = new ArrayList<String>();
ArrayList<String> text = new ArrayList<>();
text.add("&c&lCommand : Permissions " + page + "/" + maxPage);
@@ -108,17 +108,17 @@ public class AdminVotePerms extends GUIHandler {
text.add(msg.get(i));
}
text = ArrayUtils.getInstance().colorize(text);
text = ArrayUtils.colorize(text);
return ArrayUtils.getInstance().convert(text);
return ArrayUtils.convert(text);
}
public ArrayList<String> listPerms(CommandSender sender, String player, int page) {
Player p = Bukkit.getPlayer(player);
ArrayList<String> text = new ArrayList<String>();
ArrayList<String> text = new ArrayList<>();
if (p != null) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
for (CommandHandler handle : plugin.getVoteCommand()) {
if (handle.hasPerm(p)) {
@@ -158,7 +158,7 @@ public class AdminVotePerms extends GUIHandler {
}
}
msg = ArrayUtils.getInstance().colorize(msg);
msg = ArrayUtils.colorize(msg);
int pagesize = plugin.getConfigFile().getFormatPageSize();
@@ -175,12 +175,12 @@ public class AdminVotePerms extends GUIHandler {
} else {
text.add("&cPlayer not online: " + player);
}
return ArrayUtils.getInstance().colorize(text);
return ArrayUtils.colorize(text);
}
public String[] listPermsDev(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
msg.add("Command");
msg.add(" Permissions (seperated by |");
msg.add(" Help messasge");
@@ -202,9 +202,9 @@ public class AdminVotePerms extends GUIHandler {
msg.add(perm.getName() + " : " + perm.getDescription());
}
msg = ArrayUtils.getInstance().colorize(msg);
msg = ArrayUtils.colorize(msg);
return ArrayUtils.getInstance().convert(msg);
return ArrayUtils.convert(msg);
}
@Override
@@ -48,7 +48,7 @@ public class AdminVotePlaceholders extends GUIHandler {
msg = "votingplugin_" + identifier + "";
}
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
.onHover(BookUtil.HoverAction.showText(msg)).build());
book.addLayout(layout);
@@ -66,7 +66,7 @@ public class AdminVotePlaceholders extends GUIHandler {
msg = "votingplugin_" + identifier + "";
}
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
.onHover(BookUtil.HoverAction.showText(msg)).build());
book.addLayout(layout);
@@ -79,7 +79,7 @@ public class AdminVotePlaceholders extends GUIHandler {
@Override
public void onChat(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
msg.add("&cPlaceholders:");
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
String identifier = placeholder.getIdentifier().toLowerCase();
@@ -45,7 +45,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
}
String value = placeholder.placeholderRequest(user, identifier);
String msg = identifier + " = " + value;
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
.onHover(BookUtil.HoverAction.showText(value)).build());
book.addLayout(layout);
@@ -60,7 +60,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
String value = placeholder.placeholderRequest(identifier);
String msg = identifier + " = " + value;
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
.onHover(BookUtil.HoverAction.showText(value)).build());
book.addLayout(layout);
@@ -70,7 +70,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
@Override
public void onChat(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
msg.add("&cPlaceholders:");
VotingPluginUser placeholderUser = user;
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
@@ -0,0 +1,172 @@
package com.bencodez.votingplugin.commands.gui.admin;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.commands.gui.player.VoteGUI;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
import com.bencodez.votingplugin.user.VotingPluginUser;
public class AdminVoteTopPoints extends GUIHandler {
@SuppressWarnings("unused")
private int page;
private VotingPluginMain plugin;
private VotingPluginUser user;
public AdminVoteTopPoints(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int page) {
super(plugin, player);
this.plugin = plugin;
this.user = user;
this.page = page;
}
@Override
public ArrayList<String> getChat(CommandSender sender) {
return null;
}
@Override
public void onBook(Player player) {
}
@Override
public void onChat(CommandSender sender) {
}
@Override
public void onChest(Player player) {
try {
Set<Entry<TopVoterPlayer, Integer>> users = null;
LinkedHashMap<TopVoterPlayer, Integer> topPoints1 = new LinkedHashMap<TopVoterPlayer, Integer>();
for (String uuid : plugin.getVotingPluginUserManager().getAllUUIDs()) {
VotingPluginUser vpUser = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid));
vpUser.dontCache();
int points = vpUser.getPoints();
if (points > 0) {
topPoints1.put(vpUser.getTopVoterPlayer(), points);
}
}
LinkedHashMap<TopVoterPlayer, Integer> topPoints = plugin.getTopVoterHandler().sortByValues(topPoints1,
false);
users = topPoints.entrySet();
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
boolean customzationEnabled = false;
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<>();
if (customization != null) {
customzationEnabled = customization.getBoolean("Enabled");
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
playerSlots.addAll(customizationPlayerSlots);
}
BInventory inv = new BInventory("Top Points");
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
inv.dontClose();
}
int pos = 1;
for (Entry<TopVoterPlayer, Integer> entry : users) {
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
} else {
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
}
playerItem.setLore(new ArrayList<>());
BInventoryButton button = new BInventoryButton(playerItem
.setName(plugin.getGui().getChestVoteTopItemName())
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
.addPlaceholder("player", entry.getKey().getPlayerName())
.addPlaceholder("votes", "" + entry.getValue())) {
@Override
public void onClick(ClickEvent clickEvent) {
if (plugin.getGui().isChestVoteTopOpenMainGUIOnClick()) {
TopVoterPlayer user = (TopVoterPlayer) getData("User");
new VoteGUI(plugin, player, user.getUser())
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
}
}
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey());
if (customzationEnabled && !playerSlots.isEmpty()) {
button.setSlot(playerSlots.remove());
}
inv.setCloseInv(plugin.getGui().isChestVoteTopCloseGUIOnClick());
inv.addButton(button);
pos++;
}
if (plugin.getGui().isChestVoteTopBackButton()) {
if (customzationEnabled) {
inv.addButton(plugin.getCommandLoader().getBackButton(user)
.setSlot(customization.getInt("BackButtonSlot", 0)));
} else {
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
}
}
String guiPath = "VoteTop.Customization";
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
inv.addButton(
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
@Override
public void onClick(ClickEvent clickEvent) {
plugin.getCommandLoader().processSlotClick(player, user, str);
new RewardBuilder(plugin.getGui().getData(),
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
.send(clickEvent.getPlayer());
}
});
}
if (customization == null || !customzationEnabled || !customization.getBoolean("RemoveBottomBar")) {
inv.setPages(true);
}
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
inv.openInventory(player);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void open() {
open(GUIMethod.CHEST);
}
}
@@ -12,12 +12,12 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
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.NumberListener;
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
public class AdminVoteCumulative extends GUIHandler {
@@ -52,9 +52,9 @@ public class AdminVoteCumulative extends GUIHandler {
@Override
public void onClick(ClickEvent clickEvent) {
ArrayList<Integer> nums = new ArrayList<Integer>();
ArrayList<Integer> nums = new ArrayList<>();
for (String num : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
if (StringParser.getInstance().isInt(num)) {
if (MessageAPI.isInt(num)) {
nums.add(Integer.parseInt(num));
}
}
@@ -12,12 +12,12 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
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.NumberListener;
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
public class AdminVoteMilestones extends GUIHandler {
@@ -52,9 +52,9 @@ public class AdminVoteMilestones extends GUIHandler {
@Override
public void onClick(ClickEvent clickEvent) {
ArrayList<Integer> nums = new ArrayList<Integer>();
ArrayList<Integer> nums = new ArrayList<>();
for (String num : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
if (StringParser.getInstance().isInt(num)) {
if (MessageAPI.isInt(num)) {
nums.add(Integer.parseInt(num));
}
}
@@ -59,7 +59,7 @@ public class AdminVoteVoteShop extends GUIHandler {
@Override
public void onInput(Player player, String value) {
plugin.getGui().createShop(value);
plugin.getShopFile().createShop(value);
plugin.reload();
}
});
@@ -53,7 +53,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
// to add
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Identifier_Name",
plugin.getGui().getChestShopIdentifierIdentifierName(identifier)) {
plugin.getShopFile().getShopIdentifierIdentifierName(identifier)) {
@Override
public void setValue(Player player, String name) {
@@ -61,7 +61,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.OAK_DOOR, 1),
new EditGUIValueString("Permission", plugin.getGui().getChestVoteShopPermission(identifier)) {
new EditGUIValueString("Permission", plugin.getShopFile().getVoteShopPermission(identifier)) {
@Override
public void setValue(Player player, String name) {
@@ -69,7 +69,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1),
new EditGUIValueNumber("Cost", plugin.getGui().getChestShopIdentifierCost(identifier)) {
new EditGUIValueNumber("Cost", plugin.getShopFile().getShopIdentifierCost(identifier)) {
@Override
public void setValue(Player player, Number num) {
@@ -77,7 +77,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}
}));
inv.addButton(new EditGUIButton(new ItemBuilder(Material.BARRIER, 1),
new EditGUIValueNumber("Limit", plugin.getGui().getChestShopIdentifierLimit(identifier)) {
new EditGUIValueNumber("Limit", plugin.getShopFile().getShopIdentifierLimit(identifier)) {
@Override
public void setValue(Player player, Number num) {
@@ -86,7 +86,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}));
// display item
ConfigurationSection displayItemData = plugin.getGui().getChestShopIdentifierSection(identifier);
ConfigurationSection displayItemData = plugin.getShopFile().getShopIdentifierSection(identifier);
inv.addButton(new EditGUIButton(new ItemBuilder(displayItemData.getString("Material")).setAmount(1),
new EditGUIValueString("Material", displayItemData.getString("Material")) {
@@ -141,7 +141,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
plugin.getRewardHandler().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
plugin.getRewardHandler().getDirectlyDefined("Shop." + identifier + ".Rewards"));
}
});
@@ -156,8 +156,8 @@ public class AdminVoteVoteShopItem extends GUIHandler {
}
private void setPathData(String path, Object value) {
plugin.getGui().getData().set("CHEST.Shop." + identifier + "." + path, value);
plugin.getGui().saveData();
plugin.getShopFile().getData().set("Shop." + identifier + "." + path, value);
plugin.getShopFile().saveData();
plugin.reload();
}
@@ -42,9 +42,9 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
BInventory inv = new BInventory("Edit VoteShop Remove Item");
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
inv.addButton(
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier))
new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier))
.addLoreLine("&c&lClick to remove")) {
@Override
@@ -54,7 +54,7 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
@Override
public void onConfirm(Player p) {
plugin.getGui().removeShop(identifier);
plugin.getShopFile().removeShop(identifier);
p.sendMessage("Removed " + identifier);
plugin.reload();
}
@@ -65,7 +65,6 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
}
}.open();
}
}.addData("ident", identifier));
}
@@ -41,9 +41,9 @@ public class AdminVoteVoteShopItems extends GUIHandler {
BInventory inv = new BInventory("Edit VoteShop Items");
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
for (String identifier : plugin.getGui().getChestShopIdentifiers()) {
for (String identifier : plugin.getShopFile().getShopIdentifiers()) {
inv.addButton(
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier))) {
new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier))) {
@Override
public void onClick(ClickEvent clickEvent) {
@@ -12,8 +12,9 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -30,20 +31,20 @@ public class VoteBest extends GUIHandler {
@Override
public ArrayList<String> getChat(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
msg.add(plugin.getConfigFile().getFormatCommandsVoteBestTitle());
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteBestLines());
HashMap<String, String> placeholders = new HashMap<String, String>();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("HighestDailyTotal", "" + user.getHighestDailyTotal());
placeholders.put("HighestWeeklyTotal", "" + user.getHighestWeeklyTotal());
placeholders.put("HighestMonthlyTotal", "" + user.getHighestMonthlyTotal());
placeholders.put("player", user.getPlayerName());
msg = ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders);
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
return ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.colorize(msg);
}
@Override
@@ -12,10 +12,10 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -39,19 +39,19 @@ public class VoteGUI extends GUIHandler {
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteGUISlotSection(slot));
String[] lore = new String[1];
lore = ArrayUtils.getInstance().convert(plugin.getGui().getChestVoteGUISlotLore(slot));
lore = ArrayUtils.convert(plugin.getGui().getChestVoteGUISlotLore(slot));
String str = plugin.getConfigFile().getVoteTopDefault();
if (lore.length == 0) {
if (StringParser.getInstance().startsWithIgnoreCase(slot, "url")) {
if (MessageAPI.startsWithIgnoreCase(slot, "url")) {
lore = new String[] { "&aClick me" };
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "next")) {
lore = ArrayUtils.getInstance().convert(new VoteNext(plugin, player, user).getChat(player));
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "last")) {
lore = ArrayUtils.getInstance().convert(new VoteLast(plugin, player, user).getChat(player));
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "total")) {
lore = ArrayUtils.getInstance().convert(new VoteTotal(plugin, player, user).getChat(player));
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "top")) {
} else if (MessageAPI.startsWithIgnoreCase(slot, "next")) {
lore = ArrayUtils.convert(new VoteNext(plugin, player, user).getChat(player));
} else if (MessageAPI.startsWithIgnoreCase(slot, "last")) {
lore = ArrayUtils.convert(new VoteLast(plugin, player, user).getChat(player));
} else if (MessageAPI.startsWithIgnoreCase(slot, "total")) {
lore = ArrayUtils.convert(new VoteTotal(plugin, player, user).getChat(player));
} else if (MessageAPI.startsWithIgnoreCase(slot, "top")) {
if (str.equalsIgnoreCase("monthly")) {
lore = plugin.getTopVoterHandler().topVoterMonthly(1);
@@ -64,18 +64,18 @@ public class VoteGUI extends GUIHandler {
}
} else if (slot.equalsIgnoreCase("today")) {
String[] today = new VoteToday(plugin, player, user, 1).voteTodayGUI();
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> list = new ArrayList<>();
if (today.length > 0) {
for (int i = today.length - 1; i < today.length && list.size() < 10 && i >= 0; i--) {
list.add(today[i]);
}
}
lore = ArrayUtils.getInstance().convert(list);
lore = ArrayUtils.convert(list);
} else if (slot.equalsIgnoreCase("help")) {
lore = new String[] { "Click to view help" };
}
}
builder.setLore(ArrayUtils.getInstance().convert(lore));
builder.setLore(ArrayUtils.convert(lore));
return builder;
}
@@ -151,7 +151,8 @@ public class VoteGUI extends GUIHandler {
String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
if (cmd.equalsIgnoreCase("none")) {
return;
} else if (!cmd.equals("")) {
}
if (!cmd.equals("")) {
event.runSync(new Runnable() {
@Override
@@ -10,8 +10,8 @@ import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.simpleapi.nms.NMSManager;
import com.bencodez.votingplugin.VotingPluginMain;
import net.md_5.bungee.api.ChatColor;
@@ -34,8 +34,8 @@ public class VoteHelp extends GUIHandler {
}
public ArrayList<TextComponent> helpText(CommandSender sender) {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
ArrayList<TextComponent> msg = new ArrayList<>();
HashMap<String, TextComponent> unsorted = new HashMap<>();
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
@@ -54,7 +54,7 @@ public class VoteHelp extends GUIHandler {
plugin.getConfigFile().getFormatCommandsVoteHelpLine(), hoverColor));
}
}
ArrayList<String> unsortedList = new ArrayList<String>();
ArrayList<String> unsortedList = new ArrayList<>();
unsortedList.addAll(unsorted.keySet());
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
for (String cmd : unsortedList) {
@@ -65,8 +65,8 @@ public class VoteHelp extends GUIHandler {
}
public ArrayList<TextComponent> helpTextLegacy(CommandSender sender) {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
ArrayList<TextComponent> msg = new ArrayList<>();
HashMap<String, TextComponent> unsorted = new HashMap<>();
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
@@ -76,7 +76,7 @@ public class VoteHelp extends GUIHandler {
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
}
}
ArrayList<String> unsortedList = new ArrayList<String>();
ArrayList<String> unsortedList = new ArrayList<>();
unsortedList.addAll(unsorted.keySet());
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
for (String cmd : unsortedList) {
@@ -108,8 +108,8 @@ public class VoteHelp extends GUIHandler {
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
int pagesize = plugin.getConfigFile().getFormatPageSize();
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
ArrayList<TextComponent> text = new ArrayList<TextComponent>();
ArrayList<TextComponent> msg = new ArrayList<>();
ArrayList<TextComponent> text = new ArrayList<>();
if (NMSManager.getInstance().isVersion("1.12")) {
text = helpTextLegacy(sender);
} else {
@@ -121,7 +121,7 @@ public class VoteHelp extends GUIHandler {
maxPage++;
}
msg.add(StringParser.getInstance()
msg.add(MessageAPI
.stringToComp(plugin.getConfigFile().getFormatCommandsVoteHelpTitle() + " " + page + "/" + maxPage));
for (int i = pagesize * (page - 1); (i < text.size()) && (i < ((page) * pagesize)); i++) {
@@ -12,9 +12,10 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -32,12 +33,12 @@ public class VoteLast extends GUIHandler {
@Override
public ArrayList<String> getChat(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
String playerName = user.getPlayerName();
msg.add(StringParser.getInstance().replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(),
"%player%", playerName));
msg.add(MessageAPI.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(), "%player%",
playerName));
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
@@ -45,7 +46,7 @@ public class VoteLast extends GUIHandler {
}
}
return ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.colorize(msg);
}
@Override
@@ -73,15 +74,16 @@ public class VoteLast extends GUIHandler {
if (plugin.getGui().isChestVoteLastClickableLinks()) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(player);
user.sendMessage(
StringParser.getInstance()
PlaceholderUtils
.replacePlaceHolder(
StringParser.getInstance().replacePlaceHolder(
StringParser.getInstance()
.replacePlaceHolder(plugin.getGui()
PlaceholderUtils.replacePlaceHolder(
PlaceholderUtils.replacePlaceHolder(
plugin.getGui()
.getChestVoteURLURLText(),
"voteurl", site.getVoteURL()),
"voteurl", site.getVoteURL()),
"sitename", site.getDisplayName()),
"player", player.getName()));
@@ -11,12 +11,13 @@ import com.bencodez.advancedcore.api.bookgui.Layout;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -36,23 +37,21 @@ public class VoteNext extends GUIHandler {
@Override
public ArrayList<String> getChat(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
String playerName = user.getPlayerName();
msg.add(StringParser.getInstance().colorize(StringParser.getInstance()
msg.add(MessageAPI.colorize(MessageAPI
.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteNextTitle(), "%player%", playerName)));
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
msgLine = StringParser.getInstance().replaceIgnoreCase(msgLine, "%info%",
user.voteCommandNextInfo(voteSite));
msgLine = MessageAPI.replaceIgnoreCase(msgLine, "%info%", user.voteCommandNextInfo(voteSite));
msgLine = StringParser.getInstance().replaceIgnoreCase(msgLine, "%SiteName%",
voteSite.getDisplayName());
msg.add(StringParser.getInstance().colorize(msgLine));
msgLine = MessageAPI.replaceIgnoreCase(msgLine, "%SiteName%", voteSite.getDisplayName());
msg.add(MessageAPI.colorize(msgLine));
}
}
return msg;
@@ -65,7 +64,7 @@ public class VoteNext extends GUIHandler {
// add colors/config options
for (VoteSite site : plugin.getVoteSitesEnabled()) {
if (!site.isHidden()) {
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
Layout nextLayout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
nextLayout.replaceTextComponent("[Json]",
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
@@ -94,10 +93,13 @@ public class VoteNext extends GUIHandler {
siteNameDisplay = site.getDisplayName();
}
inv.addButton(inv.getNextSlot(),
new UpdatingBInventoryButton(plugin, site.getItem().setName(siteNameDisplay)
.setLore(StringParser.getInstance().replacePlaceHolder(
plugin.getGui().getChestVoteNextLine(), "time", user.voteCommandNextInfo(site)))
.setAmountNone(1), 1000, 1000) {
new UpdatingBInventoryButton(plugin,
site.getItem().setName(siteNameDisplay)
.setLore(PlaceholderUtils.replacePlaceHolder(
plugin.getGui().getChestVoteNextLine(), "time",
user.voteCommandNextInfo(site)))
.setAmountNone(1),
1000, 1000) {
@Override
public void onClick(ClickEvent clickEvent) {
@@ -12,9 +12,10 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -45,8 +46,8 @@ public class VoteShop extends GUIHandler {
@Override
public void onChest(Player player) {
if (!plugin.getGui().isChestVoteShopEnabled()) {
player.sendMessage(StringParser.getInstance().colorize(plugin.getGui().getChestVoteShopDisabled()));
if (!plugin.getShopFile().isVoteShopEnabled()) {
player.sendMessage(MessageAPI.colorize(plugin.getShopFile().getVoteShopDisabled()));
return;
}
@@ -57,26 +58,33 @@ public class VoteShop extends GUIHandler {
/*
* if (!plugin.getConfigFile().isExtraVoteShopCheck()) { user.cacheAsync(); }
*/
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
BInventory inv = new BInventory(plugin.getShopFile().getVoteShopName());
inv.addPlaceholder("points", "" + user.getPoints());
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
inv.dontClose();
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
String perm = plugin.getGui().getChestVoteShopPermission(identifier);
String perm = plugin.getShopFile().getVoteShopPermission(identifier);
boolean hasPerm = false;
if (perm.isEmpty()) {
hasPerm = true;
} else {
String p = "";
if (perm.startsWith("!")) {
hasPerm = !player.hasPermission(perm.substring(1));
p = PlaceholderUtils.replacePlaceHolders(player, perm.substring(1));
hasPerm = !player.hasPermission(p);
} else {
hasPerm = player.hasPermission(perm);
p = PlaceholderUtils.replacePlaceHolders(player, perm);
hasPerm = player.hasPermission(p);
}
if (!hasPerm) {
plugin.extraDebug("VoteShop: " + player.getName() + "/" + player.getUniqueId()
+ " does not have permission `" + p + "` for " + identifier);
}
}
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
int limit = plugin.getShopFile().getShopIdentifierLimit(identifier);
boolean limitPass = true;
if (limit > 0) {
@@ -85,10 +93,10 @@ public class VoteShop extends GUIHandler {
}
}
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
if ((hasPerm || !plugin.getGui().getChestVoteShopHideOnNoPermission(identifier))
&& (limitPass || !plugin.getGui().isChestVoteShopHideLimitedReached())) {
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
if (!plugin.getShopFile().getVoteShopNotBuyable(identifier)) {
if ((hasPerm || !plugin.getShopFile().getVoteShopHideOnNoPermission(identifier))
&& (limitPass || !plugin.getShopFile().isVoteShopHideLimitedReached())) {
ItemBuilder builder = new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier));
inv.addButton(new BInventoryButton(builder) {
@@ -103,7 +111,7 @@ public class VoteShop extends GUIHandler {
String identifier = (String) getData("identifier");
int limit = (int) getData("Limit");
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
int points = plugin.getShopFile().getShopIdentifierCost(identifier);
if (identifier != null) {
// if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
// event.closeInventory();
@@ -118,10 +126,10 @@ public class VoteShop extends GUIHandler {
}
if (limitPass) {
if (!plugin.getGui().isChestVoteShopRequireConfirmation(identifier)) {
HashMap<String, String> placeholders = new HashMap<String, String>();
if (!plugin.getShopFile().isVoteShopRequireConfirmation(identifier)) {
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("identifier",
plugin.getGui().getChestShopIdentifierIdentifierName(identifier));
plugin.getShopFile().getShopIdentifierIdentifierName(identifier));
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
if (user.removePoints(points, true)) {
@@ -131,19 +139,19 @@ public class VoteShop extends GUIHandler {
plugin.getServerData().addVoteShopPurchase(identifier);
}
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
plugin.getRewardHandler().giveReward(user, plugin.getShopFile().getData(),
plugin.getShopFile().getShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
plugin.getGui().getCHESTVoteShopPurchase(identifier),
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
plugin.getShopFile().getVoteShopPurchase(identifier),
placeholders));
if (limit > 0) {
user.setVoteShopIdentifierLimit(identifier,
user.getVoteShopIdentifierLimit(identifier) + 1);
}
} else {
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
}
} else {
@@ -158,10 +166,10 @@ public class VoteShop extends GUIHandler {
}
} else {
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
user.sendMessage(plugin.getShopFile().getVoteShopLimitReached());
}
plugin.getCommandLoader().processSlotClick(player, user, identifier);
if (plugin.getGui().isChestVoteShopReopenGUIOnPurchase()) {
if (plugin.getShopFile().isVoteShopReopenGUIOnPurchase()) {
plugin.getCommandLoader().processSlotClick(player, user, "shop");
}
}
@@ -171,7 +179,7 @@ public class VoteShop extends GUIHandler {
}
} else {
if (hasPerm) {
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
ItemBuilder builder = new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier));
inv.addButton(new BInventoryButton(builder) {
@Override
@@ -184,20 +192,20 @@ public class VoteShop extends GUIHandler {
}
}
for (final String str : plugin.getGui().getChestGUIVoteShopExtraItems()) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIVoteShopExtraItems(str))) {
for (final String str : plugin.getShopFile().getVoteShopExtraItems()) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getGUIVoteShopExtraItems(str))) {
@Override
public void onClick(ClickEvent clickEvent) {
plugin.getCommandLoader().processSlotClick(player, user, str);
new RewardBuilder(plugin.getGui().getData(),
"CHEST.VoteShopExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
new RewardBuilder(plugin.getShopFile().getData(),
"ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
.setGiveOffline(false).send(clickEvent.getPlayer());
}
});
}
if (plugin.getGui().isChestVoteShopBackButton()) {
if (plugin.getShopFile().isVoteShopBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
@@ -12,9 +12,9 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.simpleapi.player.PlayerUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -46,17 +46,17 @@ public class VoteShopConfirm extends GUIHandler {
@Override
public void onChest(Player player) {
PlayerUtils.getInstance().setPlayerMeta(player, "ident", identifier);
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
PlayerUtils.setPlayerMeta(plugin, player, "ident", identifier);
BInventory inv = new BInventory(plugin.getShopFile().getShopConfirmPurchaseTitle());
inv.dontClose();
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseYesItem())) {
@Override
public void onClick(ClickEvent event) {
user.cache();
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
HashMap<String, String> placeholders = new HashMap<String, String>();
int points = plugin.getShopFile().getShopIdentifierCost(identifier);
int limit = plugin.getShopFile().getShopIdentifierLimit(identifier);
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("identifier", identifier);
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
@@ -67,20 +67,20 @@ public class VoteShopConfirm extends GUIHandler {
plugin.getServerData().addVoteShopPurchase(identifier);
}
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
plugin.getRewardHandler().giveReward(user, plugin.getShopFile().getData(),
plugin.getShopFile().getShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
user.sendMessage(StringParser.getInstance()
.replacePlaceHolder(plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
user.sendMessage(PlaceholderUtils
.replacePlaceHolder(plugin.getShopFile().getVoteShopPurchase(identifier), placeholders));
if (limit > 0) {
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
}
} else {
user.sendMessage(StringParser.getInstance()
user.sendMessage(PlaceholderUtils
.replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
}
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
if (plugin.getShopFile().getVoteShopCloseGUI(identifier)) {
event.getButton().getInv().closeInv(player, null);
} else {
new VoteShop(plugin, event.getPlayer(), user).open();
@@ -88,11 +88,11 @@ public class VoteShopConfirm extends GUIHandler {
}
});
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseNoItem())) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseNoItem())) {
@Override
public void onClick(ClickEvent event) {
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
if (plugin.getShopFile().getVoteShopCloseGUI(identifier)) {
event.getButton().getInv().closeInv(player, null);
} else {
new VoteShop(plugin, event.getPlayer(), user).open();
@@ -12,8 +12,9 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -31,11 +32,11 @@ public class VoteStreak extends GUIHandler {
@Override
public ArrayList<String> getChat(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
msg.add(plugin.getConfigFile().getFormatCommandsVoteStreakTitle());
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteStreakLines());
HashMap<String, String> placeholders = new HashMap<String, String>();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("DailyStreak", "" + user.getDayVoteStreak());
placeholders.put("WeeklyStreak", "" + user.getWeekVoteStreak());
placeholders.put("MonthlyStreak", "" + user.getMonthVoteStreak());
@@ -46,9 +47,9 @@ public class VoteStreak extends GUIHandler {
placeholders.put("player", user.getPlayerName());
msg = ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders);
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
return ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.colorize(msg);
}
@Override
@@ -16,10 +16,10 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.nms.NMSManager;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
@@ -44,7 +44,7 @@ public class VoteToday extends GUIHandler {
if (page < 1) {
page = 1;
}
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
String[] voteToday = voteToday();
int maxPage = voteToday.length / pagesize;
@@ -52,7 +52,7 @@ public class VoteToday extends GUIHandler {
maxPage++;
}
HashMap<String, String> placeholders = new HashMap<String, String>();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("page", "" + page);
placeholders.put("maxpage", "" + maxPage);
@@ -66,7 +66,7 @@ public class VoteToday extends GUIHandler {
msg.add(voteToday[i]);
}
return ArrayUtils.getInstance().colorize(ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders));
return ArrayUtils.colorize(PlaceholderUtils.replacePlaceHolder(msg, placeholders));
}
@Override
@@ -91,18 +91,18 @@ public class VoteToday extends GUIHandler {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
String msg = plugin.getGui().getChestVoteTodayLine();
HashMap<String, String> placeholders = new HashMap<String, String>();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("VoteSite", voteSite.getDisplayName());
placeholders.put("Time", timeString);
msg = StringParser.getInstance().replacePlaceHolder(msg, placeholders);
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
ItemBuilder item = null;
if (plugin.getGui().isChestVoteTodayUseSkull() && !NMSManager.getInstance().isVersion("1.12")) {
item = new ItemBuilder(user.getPlayerHead());
} else {
item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
}
item.setName(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
"player", user.getPlayerName()));
item.setName(PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(), "player",
user.getPlayerName()));
item.setLore(msg);
final UUID uuid = user.getUuid();
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
@@ -116,7 +116,7 @@ public class VoteToday extends GUIHandler {
});
}
}
String guiPath = "VoteToday";
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
inv.addButton(
@@ -130,6 +130,7 @@ public class VoteToday extends GUIHandler {
.setGiveOffline(false).send(clickEvent.getPlayer());
}
});
}
@@ -145,28 +146,29 @@ public class VoteToday extends GUIHandler {
}
public String[] voteToday() {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
HashMap<String, String> placeholders = new HashMap<String, String>();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("player", user.getPlayerName());
placeholders.put("votesite", voteSite.getKey());
placeholders.put("sitename", voteSite.getDisplayName());
placeholders.put("time", timeString);
msg.add(StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
placeholders));
// msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
// timeString);
}
}
msg = ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.getInstance().convert(msg);
msg = ArrayUtils.colorize(msg);
return ArrayUtils.convert(msg);
}
public String[] voteTodayGUI() {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
LocalDateTime mostRecent = null;
@@ -180,16 +182,17 @@ public class VoteToday extends GUIHandler {
if (mostRecent != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
String timeString = mostRecent.format(formatter);
HashMap<String, String> placeholders = new HashMap<String, String>();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("player", user.getPlayerName());
placeholders.put("votesite", mostRecentSite.getKey());
placeholders.put("sitename", mostRecentSite.getDisplayName());
placeholders.put("time", timeString);
msg.add(StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
placeholders));
}
}
msg = ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.getInstance().convert(msg);
msg = ArrayUtils.colorize(msg);
return ArrayUtils.convert(msg);
}
}
@@ -20,8 +20,8 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
@@ -46,17 +46,17 @@ public class VoteTopVoter extends GUIHandler {
public ArrayList<String> getChat(CommandSender sender) {
switch (top) {
case AllTime:
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterAllTime(page));
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterAllTime(page));
case Daily:
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterDaily(page));
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterDaily(page));
case Monthly:
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterMonthly(page));
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterMonthly(page));
case Weekly:
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterWeekly(page));
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterWeekly(page));
default:
break;
}
return new ArrayList<String>();
return new ArrayList<>();
}
@Override
@@ -85,7 +85,7 @@ public class VoteTopVoter extends GUIHandler {
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
boolean customzationEnabled = false;
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<Integer>();
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<>();
if (customization != null) {
customzationEnabled = customization.getBoolean("Enabled");
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
@@ -109,7 +109,7 @@ public class VoteTopVoter extends GUIHandler {
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
}
playerItem.setLore(new ArrayList<String>());
playerItem.setLore(new ArrayList<>());
BInventoryButton button = new BInventoryButton(playerItem
.setName(plugin.getGui().getChestVoteTopItemName())
@@ -65,7 +65,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
}
playerItem.setLore(new ArrayList<String>());
playerItem.setLore(new ArrayList<>());
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
@@ -0,0 +1,147 @@
package com.bencodez.votingplugin.commands.gui.player;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
import com.bencodez.votingplugin.user.VotingPluginUser;
import net.md_5.bungee.api.ChatColor;
public class VoteTopVoterPreviousMonths extends GUIHandler {
private VotingPluginMain plugin;
private VotingPluginUser user;
private int index = -1;
public VoteTopVoterPreviousMonths(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int index) {
super(plugin, player);
this.plugin = plugin;
this.user = user;
this.index = index;
}
@Override
public ArrayList<String> getChat(CommandSender arg0) {
return null;
}
public void next(int index) {
}
@Override
public void onBook(Player player) {
// TODO
}
@Override
public void onChat(CommandSender sender) {
}
@Override
public void onChest(Player player) {
Set<YearMonth> months = plugin.getPreviousMonthsTopVoters().keySet();
List<YearMonth> yearMonthList = months.stream().sorted(Collections.reverseOrder()).collect(Collectors.toList());
YearMonth yearMonth = null;
if (index < 0) {
if (!yearMonthList.isEmpty()) {
yearMonth = yearMonthList.get(0);
}
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
return;
}
if (yearMonthList.size() <= index) {
player.sendMessage(ChatColor.RED + "Can't open previous months, no data for requested index");
return;
}
yearMonth = yearMonthList.get(index);
Set<Entry<TopVoterPlayer, Integer>> users = null;
if (!plugin.getPreviousMonthsTopVoters().containsKey(yearMonth)) {
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
return;
}
users = plugin.getPreviousMonthsTopVoters().get(yearMonth).entrySet();
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
inv.addPlaceholder("topvoter", yearMonth.toString());
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
inv.dontClose();
}
int pos = 1;
for (Entry<TopVoterPlayer, Integer> entry : users) {
ItemBuilder playerItem;
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
} else {
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
}
playerItem.setLore(new ArrayList<>());
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
.addPlaceholder("player", entry.getKey().getPlayerName())
.addPlaceholder("votes", "" + entry.getValue())) {
@Override
public void onClick(ClickEvent clickEvent) {
TopVoterPlayer user = (TopVoterPlayer) getData("User");
new VoteGUI(plugin, player, user.getUser())
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
}
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
pos++;
}
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem())
.addPlaceholder("Top", yearMonth.toString())) {
@Override
public void onClick(ClickEvent clickEvent) {
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
new VoteTopVoterPreviousMonths(plugin, player, user, index + 1).open(GUIMethod.CHEST);
} else {
new VoteTopVoterPreviousMonths(plugin, player, user, index - 1).open(GUIMethod.CHEST);
}
}
});
if (plugin.getGui().isChestVoteTopBackButton()) {
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
}
inv.setPages(true);
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
inv.openInventory(player);
}
@Override
public void open() {
open(GUIMethod.CHEST);
}
}
@@ -8,13 +8,13 @@ import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -32,7 +32,7 @@ public class VoteTotal extends GUIHandler {
@Override
public ArrayList<String> getChat(CommandSender arg0) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> msg = new ArrayList<>();
int daily = user.getTotal(TopVoter.Daily);
int weekly = user.getTotal(TopVoter.Weekly);
@@ -40,15 +40,15 @@ public class VoteTotal extends GUIHandler {
int all = user.getTotal(TopVoter.AllTime);
for (String s : plugin.getConfigFile().getFormatCommandsVoteTotal()) {
String str = StringParser.getInstance().replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
str = StringParser.getInstance().replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
str = StringParser.getInstance().replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
str = StringParser.getInstance().replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
str = StringParser.getInstance().replaceIgnoreCase(str, "%player%", user.getPlayerName());
String str = MessageAPI.replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
str = MessageAPI.replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
str = MessageAPI.replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
str = MessageAPI.replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
str = MessageAPI.replaceIgnoreCase(str, "%player%", user.getPlayerName());
msg.add(str);
}
return ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.colorize(msg);
}
@Override
@@ -7,6 +7,7 @@ import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import com.bencodez.advancedcore.api.bookgui.BookWrapper;
import com.bencodez.advancedcore.api.bookgui.Layout;
@@ -18,9 +19,9 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.MessageBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -50,8 +51,12 @@ public class VoteURL extends GUIHandler {
}
@Override
public ArrayList<String> getChat(CommandSender arg0) {
ArrayList<String> sites = new ArrayList<String>();
public ArrayList<String> getChat(CommandSender sender) {
return getChat(sender, false);
}
public ArrayList<String> getChat(CommandSender sender, boolean bypassCanVote) {
ArrayList<String> sites = new ArrayList<>();
List<String> title = plugin.getConfigFile().getFormatCommandsVoteText();
if (title != null) {
@@ -61,30 +66,39 @@ public class VoteURL extends GUIHandler {
int counter = 0;
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
counter++;
String voteURL = voteSite.getVoteURL(json);
MessageBuilder message = new MessageBuilder(plugin.getConfigFile().getFormatCommandsVoteURLS());
message.replacePlaceholder("num", Integer.toString(counter)).replacePlaceholder("url", voteURL)
.replacePlaceholder("SiteName", voteSite.getDisplayName());
if (user != null && user.getPlayerName() != null) {
message.replacePlaceholder("player", "" + user.getPlayerName()).replacePlaceholder("Next",
"" + user.voteCommandNextInfo(voteSite));
if (voteSite.getPermissionToView().isEmpty()
|| sender.hasPermission(voteSite.getPermissionToView())) {
if (!plugin.getConfigFile().isFormatCommandsVoteOnlyShowSitesToVote()
|| user.canVoteSite(voteSite) || bypassCanVote) {
counter++;
String voteURL = voteSite.getVoteURL(json);
MessageBuilder message = new MessageBuilder(
plugin.getConfigFile().getFormatCommandsVoteURLS());
message.replacePlaceholder("num", Integer.toString(counter))
.replacePlaceholder("url", voteURL)
.replacePlaceholder("SiteName", voteSite.getDisplayName());
if (user != null && user.getPlayerName() != null) {
message.replacePlaceholder("player", "" + user.getPlayerName())
.replacePlaceholder("Next", "" + user.voteCommandNextInfo(voteSite));
}
sites.add(message.colorize().getText());
}
}
sites.add(message.colorize().getText());
}
}
}
if (user != null) {
HashMap<String, String> phs = new HashMap<String, String>();
HashMap<String, String> phs = new HashMap<>();
phs.put("DailyTotal", "" + user.getTotal(TopVoter.Daily));
phs.put("WeekTotal", "" + user.getTotal(TopVoter.Weekly));
phs.put("MonthTotal", "" + user.getTotal(TopVoter.Monthly));
phs.put("Total", "" + user.getTotal(TopVoter.AllTime));
sites = ArrayUtils.getInstance().replacePlaceHolder(sites, phs);
sites = PlaceholderUtils.replacePlaceHolder(sites, phs);
}
return ArrayUtils.getInstance().colorize(sites);
return ArrayUtils.colorize(sites);
}
private ItemBuilder getItemAll() {
@@ -141,20 +155,25 @@ public class VoteURL extends GUIHandler {
}
int i = 1;
for (VoteSite site : plugin.getVoteSitesEnabled()) {
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename",
site.getDisplayName());
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
ChatColor color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUIAlreadyVotedColor());
if (user.canVoteSite(site)) {
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
if (!site.isHidden()) {
if (site.getPermissionToView().isEmpty() || player.hasPermission(site.getPermissionToView())) {
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout())
.addPlaceholder("sitename", site.getDisplayName()).addPlaceholder("num", "" + i);
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
ChatColor color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUIAlreadyVotedColor());
if (user.canVoteSite(site)) {
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
}
String url = PlaceholderUtils.replacePlaceHolder(PlaceholderUtils.replacePlaceHolder(
site.getVoteURLJsonStrip(), "player", user.getPlayerName()), "num", "" + i);
layout.replaceTextComponent("[UrlText]",
BookUtil.TextBuilder.of(text).color(color).onClick(BookUtil.ClickAction.openUrl(url))
.onHover(BookUtil.HoverAction.showText(url)).build());
book.addLayout(layout);
i++;
}
}
String url = 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);
@@ -178,7 +197,12 @@ public class VoteURL extends GUIHandler {
public void onClick(ClickEvent event) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(event.getPlayer());
json = true;
user.sendMessage(getChat(player));
if (event.getClick().equals(ClickType.SHIFT_LEFT)
|| event.getClick().equals(ClickType.SHIFT_RIGHT)) {
user.sendMessage(getChat(player, true));
} else {
user.sendMessage(getChat(player, false));
}
}
@Override
@@ -191,42 +215,46 @@ public class VoteURL extends GUIHandler {
int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
ItemBuilder builder = getItemVoteSite(voteSite);
if (startSlot >= 0) {
builder.setSlot(startSlot);
startSlot++;
}
if (voteSite.getPermissionToView().isEmpty() || player.hasPermission(voteSite.getPermissionToView())) {
ItemBuilder builder = getItemVoteSite(voteSite);
if (startSlot >= 0) {
builder.setSlot(startSlot);
startSlot++;
}
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
@Override
public void onClick(ClickEvent event) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("voteurl", voteSite.getVoteURL());
placeholders.put("sitename", voteSite.getDisplayName());
placeholders.put("player", player.getName());
placeholders.put("servicesite", voteSite.getServiceSite());
placeholders.put("VoteDelay", "" + voteSite.getVoteDelay());
placeholders.put("VoteHour", "" + voteSite.getVoteDelayDailyHour());
user.sendMessage(plugin.getGui().getChestVoteURLURLText(), placeholders);
@Override
public void onClick(ClickEvent event) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("voteurl", voteSite.getVoteURL());
placeholders.put("sitename", voteSite.getDisplayName());
placeholders.put("player", player.getName());
placeholders.put("servicesite", voteSite.getServiceSite());
placeholders.put("VoteDelay", "" + voteSite.getVoteDelay());
placeholders.put("VoteHour", "" + voteSite.getVoteDelayDailyHour());
user.sendMessage(plugin.getGui().getChestVoteURLURLText(), placeholders);
}
}
}
@Override
public ItemBuilder onUpdate(Player player) {
return getItemVoteSite(voteSite);
}
@Override
public ItemBuilder onUpdate(Player player) {
return getItemVoteSite(voteSite);
}
});
});
}
}
}
for (final String str : plugin.getGui().getChestVoteURLExtraItems()) {
for (
final String str : plugin.getGui().getChestVoteURLExtraItems()) {
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteURLExtraItemsItem(str))) {
@Override
@@ -10,8 +10,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.command.AdvancedCoreTabCompleteHandler;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
/**
@@ -32,15 +32,15 @@ public class AdminVoteTabCompleter implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
List<String> tab = new ArrayList<String>();
List<String> tab = new ArrayList<>();
Set<String> cmds = new HashSet<String>();
Set<String> cmds = new HashSet<>();
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(), sender, args,
args.length - 1));
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(),
sender, args, args.length - 1));
for (String str : cmds) {
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
tab.add(str);
}
}
@@ -12,9 +12,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.command.TabCompleteHandler;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
/**
@@ -39,19 +39,19 @@ public class AliasesTabCompleter implements TabCompleter {
*/
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] argsIn) {
ArrayList<String> msgArray = new ArrayList<String>();
ArrayList<String> msgArray = new ArrayList<>();
msgArray.add("");
for (String arg : argsIn) {
msgArray.add(arg);
}
String[] args = ArrayUtils.getInstance().convert(msgArray);
String[] args = ArrayUtils.convert(msgArray);
ArrayList<String> tab = new ArrayList<String>();
ArrayList<String> tab = new ArrayList<>();
Set<String> cmds = new HashSet<String>();
Set<String> cmds = new HashSet<>();
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
ArrayList<CommandHandler> cmdHandlers = new ArrayList<>();
if (adminCommand) {
cmdHandlers.addAll(plugin.getAdminVoteCommand());
@@ -88,7 +88,7 @@ public class AliasesTabCompleter implements TabCompleter {
}
for (String str : cmds) {
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
tab.add(str);
}
}
@@ -10,8 +10,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.command.AdvancedCoreTabCompleteHandler;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -33,15 +33,15 @@ public class VoteTabCompleter implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
ArrayList<String> tab = new ArrayList<String>();
ArrayList<String> tab = new ArrayList<>();
Set<String> cmds = new HashSet<String>();
Set<String> cmds = new HashSet<>();
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender, args,
args.length - 1));
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender,
args, args.length - 1));
for (String str : cmds) {
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
tab.add(str);
}
}
@@ -3,12 +3,12 @@ package com.bencodez.votingplugin.config;
import java.io.File;
import java.util.ArrayList;
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.ConfigDataListString;
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
import com.bencodez.simpleapi.file.YMLFile;
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
import com.bencodez.votingplugin.VotingPluginMain;
import lombok.Getter;
@@ -39,6 +39,14 @@ public class BungeeSettings extends YMLFile {
@Getter
private String RedisUsername = "";
@ConfigDataString(path = "PluginMessageChannel")
@Getter
private String pluginMessagingChannel = "vp:vp";
@ConfigDataBoolean(path = "PluginMessageEncryption")
@Getter
private boolean pluginMessageEncryption = false;
@ConfigDataString(path = "Redis.Prefix")
@Getter
private String RedisPrefix = "";
@@ -50,6 +58,26 @@ public class BungeeSettings extends YMLFile {
@ConfigDataInt(path = "Redis.Port")
@Getter
private int RedisPort = 6379;
@ConfigDataString(path = "MQTT.ClientID")
@Getter
private String mqttClientID = "";
@ConfigDataString(path = "MQTT.BrokerURL")
@Getter
private String mqttBrokerURL = "tcp://localhost:1883";
@ConfigDataString(path = "MQTT.Username")
@Getter
private String mqttUsername = "";
@ConfigDataString(path = "MQTT.Password")
@Getter
private String mqttPassword = "";
@ConfigDataString(path = "MQTT.Prefix")
@Getter
private String mqttPrefix = "";
@ConfigDataString(path = "BungeeServer.Host")
@Getter
@@ -117,7 +145,7 @@ public class BungeeSettings extends YMLFile {
@ConfigDataListString(path = "BungeeVotePartyGlobalCommands")
@Getter
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<String>();
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<>();
public BungeeSettings(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
@@ -7,14 +7,14 @@ import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
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.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.file.YMLFile;
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.placeholders.PlaceholderCacheLevel;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -39,10 +39,18 @@ public class Config extends YMLFile {
@Getter
private boolean addTotalsOffline = true;
@ConfigDataBoolean(path = "LoadInteralExpansion")
@Getter
private boolean loadInteralExpansion = true;
@ConfigDataBoolean(path = "PerSiteCoolDownEvents")
@Getter
private boolean perSiteCoolDownEvents = false;
@ConfigDataInt(path = "LimitVotePoints")
@Getter
private int limitVotePoints = -1;
@ConfigDataBoolean(path = "QueueVotesDuringTimeChange")
@Getter
private boolean queueVotesDuringTimeChange = false;
@@ -113,15 +121,15 @@ public class Config extends YMLFile {
@ConfigDataListString(path = "DisabledCommands")
@Getter
private ArrayList<String> disabledCommands = new ArrayList<String>();
private ArrayList<String> disabledCommands = new ArrayList<>();
@ConfigDataListString(path = "DisabledDefaultPermissions")
@Getter
private ArrayList<String> disabledDefaultPermissions = new ArrayList<String>();
private ArrayList<String> disabledDefaultPermissions = new ArrayList<>();
@ConfigDataListString(path = "CachedPlaceholders")
@Getter
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
private ArrayList<String> cachedPlaceholders = new ArrayList<>();
@ConfigDataBoolean(path = "DisableInteractEvent")
@Getter
@@ -217,7 +225,7 @@ public class Config extends YMLFile {
@ConfigDataListString(path = "Format.Commands.Vote.Today.Title")
@Getter
private ArrayList<String> formatCommandsVoteTodayTitle = ArrayUtils.getInstance()
private ArrayList<String> formatCommandsVoteTodayTitle = ArrayUtils
.convert(new String[] { "&cToday's Votes %page%/%maxpage%", "&cPlayerName : VoteSite : Time" });
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Disabled")
@@ -329,45 +337,15 @@ public class Config extends YMLFile {
@ConfigDataListString(path = "VotingBroadcastBlacklist")
@Getter
private ArrayList<String> votingBroadcastBlacklist = new ArrayList<String>();
public Config(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "Config.yml"));
}
/**
* Gets the black list.
*
* @return the black list
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getBlackList() {
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<String>());
}
private ArrayList<String> votingBroadcastBlacklist = new ArrayList<>();
@ConfigDataKeys(path = "CustomCommands")
@Getter
private Set<String> customCommands = new HashSet<String>();
private Set<String> customCommands = new HashSet<>();
@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);
if (str == null) {
str = new HashSet<String>();
}
return str;
}
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
}
public ConfigurationSection getCustomCommands(String ident) {
return getData().getConfigurationSection("CustomCommands." + ident);
}
private Set<String> customPlaceholderReturns = new HashSet<>();
@ConfigDataString(path = "Format.BroadcastMsg")
@Getter
@@ -381,9 +359,13 @@ public class Config extends YMLFile {
@Getter
private boolean formatCommandsVoteAutoInputSites = true;
@ConfigDataBoolean(path = "Format.Commands.Vote.OnlyShowSitesToVote")
@Getter
private boolean formatCommandsVoteOnlyShowSitesToVote = false;
@ConfigDataListString(path = "Format.Commands.Vote.Best.Lines")
@Getter
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<String>();
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<>();
@ConfigDataString(path = "Format.Commands.Vote.Best.Title")
@Getter
@@ -429,10 +411,6 @@ public class Config extends YMLFile {
@Getter
private String placeholderCacheLevelString = "AUTO";
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
}
@ConfigDataString(path = "Format.Commands.Vote.Next.Layout")
@Getter
private String formatCommandsVoteNextLayout = "&3%SiteName%: &6%info%";
@@ -441,69 +419,10 @@ public class Config extends YMLFile {
@Getter
private String formatCommandsVoteNextTitle = "&3&l%player% Next Votes:";
/**
* Gets the commands vote party.
*
* @return the commands vote party
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteParty() {
ArrayList<String> msg = new ArrayList<String>();
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Party", msg);
}
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteStreakLines() {
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<String>());
}
@ConfigDataString(path = "Format.Commands.Vote.Streak.Title")
@Getter
private String formatCommandsVoteStreakTitle = "&3&l%player% Vote Streak";
/**
* Gets the commands vote text.
*
* @return the commands vote text
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteText() {
ArrayList<String> str = new ArrayList<String>();
str.add("&4&lVote for our server!");
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Text", str);
}
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteTotal() {
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.Total",
new ArrayList<String>());
if (list.isEmpty()) {
list.add("&3&l%player% Total Votes:");
list.add("&3&lDaily Total: &6&l%DailyTotal%");
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
}
return list;
}
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteTotalAll() {
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.TotalAll",
new ArrayList<String>());
if (list.isEmpty()) {
list.add("&3&lServer Total Votes:");
list.add("&3&lDaily Total: &6&l%DailyTotal%");
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
}
return list;
}
@ConfigDataString(path = "Format.Commands.Vote.Sites")
@Getter
private String formatCommandsVoteURLS = "&4%num%: &c&l%SiteName% - &c%url%";
@@ -555,9 +474,11 @@ public class Config extends YMLFile {
@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";
@@ -597,40 +518,13 @@ public class Config extends YMLFile {
@ConfigDataString(path = "Format.InvalidCommand.Vote")
@Getter
private String formatInvalidCommandVote = "&4No valid arguments, see /vote help!";
@ConfigDataString(path = "Format.InvalidCommand.AdminVote")
@Getter
private String formatInvalidCommandAdminVote = "&4No valid arguments, see /adminvote help!";
/**
* Gets the vote help.
*
* @return the vote help
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatVoteHelp() {
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<String>());
}
@ConfigDataBoolean(path = "GiveDefaultPermission")
@Getter
private boolean giveDefaultPermission = true;
public boolean getLoadTopVoter(TopVoter top) {
switch (top) {
case AllTime:
return isLoadTopVoterAllTime();
case Daily:
return isLoadTopVoterDaily();
case Monthly:
return isLoadTopVoterMonthly();
case Weekly:
return isLoadTopVoterWeekly();
default:
return false;
}
}
@ConfigDataBoolean(path = "LoadTopVoter.AllTime")
@Getter
private boolean loadTopVoterAllTime = true;
@@ -651,13 +545,17 @@ public class Config extends YMLFile {
@Getter
private int pointsOnVote = 1;
@ConfigDataInt(path = "PurgeMin")
@ConfigDataBoolean(path = "PurgeNoDataOnStartup")
@Getter
private int purgeMin = 90;
private boolean purgeNoDataOnStartup = false;
@ConfigDataBoolean(path = "PurgeOldData")
@ConfigDataBoolean(path = "StoreMonthTotalsWithDate")
@Getter
private boolean purgeOldData = false;
private boolean storeMonthTotalsWithDate = false;
@ConfigDataBoolean(path = "UseMonthDateTotalsAsPrimaryTotal")
@Getter
private boolean useMonthDateTotalsAsPrimaryTotal = false;
@ConfigDataString(path = "RequestAPI.DefaultMethod")
@Getter
@@ -665,7 +563,7 @@ public class Config extends YMLFile {
@ConfigDataListString(path = "RequestAPI.DisabledMethods")
@Getter
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<String>();
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<>();
@ConfigDataBoolean(path = "StoreTopVoters.Daily")
@Getter
@@ -699,6 +597,127 @@ public class Config extends YMLFile {
@Getter
private boolean voteRemindingRemindOnlyOnce = false;
@ConfigDataString(path = "VoteTopDefault")
@Getter
private String voteTopDefault = "Monthly";
public Config(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "Config.yml"));
}
/**
* Gets the black list.
*
* @return the black list
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getBlackList() {
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<>());
}
public ConfigurationSection getCustomCommands(String ident) {
return getData().getConfigurationSection("CustomCommands." + ident);
}
public Set<String> getCustomPlaceholderReturns(String placeholder) {
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
if (str == null) {
str = new HashSet<>();
}
return str;
}
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
}
/**
* Gets the commands vote party.
*
* @return the commands vote party
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteParty() {
ArrayList<String> msg = new ArrayList<>();
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Party", msg);
}
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteStreakLines() {
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<>());
}
/**
* Gets the commands vote text.
*
* @return the commands vote text
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteText() {
ArrayList<String> str = new ArrayList<>();
str.add("&4&lVote for our server!");
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Text", str);
}
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteTotal() {
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.Total", new ArrayList<>());
if (list.isEmpty()) {
list.add("&3&l%player% Total Votes:");
list.add("&3&lDaily Total: &6&l%DailyTotal%");
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
}
return list;
}
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatCommandsVoteTotalAll() {
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.TotalAll",
new ArrayList<>());
if (list.isEmpty()) {
list.add("&3&lServer Total Votes:");
list.add("&3&lDaily Total: &6&l%DailyTotal%");
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
}
return list;
}
/**
* Gets the vote help.
*
* @return the vote help
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getFormatVoteHelp() {
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<>());
}
public boolean getLoadTopVoter(TopVoter top) {
switch (top) {
case AllTime:
return isLoadTopVoterAllTime();
case Daily:
return isLoadTopVoterDaily();
case Monthly:
return isLoadTopVoterMonthly();
case Weekly:
return isLoadTopVoterWeekly();
default:
return false;
}
}
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
}
/**
* Gets the rewards.
*
@@ -708,10 +727,6 @@ public class Config extends YMLFile {
return "VoteReminding.Rewards";
}
@ConfigDataString(path = "VoteTopDefault")
@Getter
private String voteTopDefault = "Monthly";
@Override
public void loadValues() {
new AnnotationHandler().load(getData(), this);
@@ -13,10 +13,10 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
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.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.file.YMLFile;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
@@ -41,7 +41,7 @@ public class ConfigVoteSites extends YMLFile {
public void generateVoteSite(String siteName) {
if (plugin.getConfigFile().isAutoCreateVoteSites()) {
String org = siteName;
siteName = siteName.replace(".", "_");
siteName = siteName.replace(".", "_").replace(" ", "_");
plugin.getLogger().warning("VoteSite " + siteName + " does not exist with the servicesite '" + org
+ "', creating one, set AutoCreateVoteSites to false to prevent this");
setEnabled(siteName, true);
@@ -103,8 +103,8 @@ public class ConfigVoteSites extends YMLFile {
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.hasPermission("VotingPlugin.Admin.GenerateServiceSite") || p.isOp()) {
p.sendMessage(StringParser.getInstance().colorize("&cGenerating votesite for service site "
+ siteName + ", please check console for details"));
p.sendMessage(MessageAPI.colorize("&cGenerating votesite for service site " + siteName
+ ", please check console for details"));
}
}
}
@@ -138,6 +138,10 @@ public class ConfigVoteSites extends YMLFile {
return getData(site).getConfigurationSection("Item");
}
public String getPermissionToView(String siteName) {
return getData(siteName).getString("PermissionToView", "");
}
/**
* Gets the priority.
*
@@ -168,10 +172,6 @@ public class ConfigVoteSites extends YMLFile {
return getData(siteName).getString("ServiceSite");
}
public int getVoteDelayDailyHour(String siteName) {
return getData(siteName).getInt("VoteDelayDailyHour", 0);
}
/**
* Gets the vote delay.
*
@@ -182,6 +182,10 @@ public class ConfigVoteSites extends YMLFile {
return getData(siteName).getDouble("VoteDelay", 24);
}
public int getVoteDelayDailyHour(String siteName) {
return getData(siteName).getInt("VoteDelayDailyHour", 0);
}
public double getVoteDelayMin(String siteName) {
return getData(siteName).getDouble("VoteDelayMin", 0);
}
@@ -239,7 +243,7 @@ public class ConfigVoteSites extends YMLFile {
* @return the vote sites load
*/
public ArrayList<VoteSite> getVoteSitesLoad() {
ArrayList<VoteSite> voteSites = new ArrayList<VoteSite>();
ArrayList<VoteSite> voteSites = new ArrayList<>();
ArrayList<String> voteSiteNames = getVoteSitesNames(true);
if (voteSiteNames != null) {
for (String site : voteSiteNames) {
@@ -276,9 +280,9 @@ public class ConfigVoteSites extends YMLFile {
}
public ArrayList<String> getVoteSitesNames(boolean checkEnabled) {
ArrayList<String> siteNames = new ArrayList<String>();
ArrayList<String> siteNames = new ArrayList<>();
if (getData().isConfigurationSection("VoteSites")) {
siteNames = ArrayUtils.getInstance().convert(getData().getConfigurationSection("VoteSites").getKeys(false));
siteNames = ArrayUtils.convert(getData().getConfigurationSection("VoteSites").getKeys(false));
}
for (int i = siteNames.size() - 1; i >= 0; i--) {
@@ -305,7 +309,7 @@ public class ConfigVoteSites extends YMLFile {
* @return the vote URL
*/
public String getVoteURL(String siteName) {
return getData(siteName).getString("VoteURL");
return getData(siteName).getString("VoteURL", "");
}
public boolean getWaitUntilVoteDelay(String siteName) {
@@ -7,15 +7,15 @@ import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
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.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.file.YMLFile;
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
import com.bencodez.simpleapi.file.annotation.ConfigDataConfigurationSection;
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -45,45 +45,17 @@ public class GUI extends YMLFile {
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.Layout")
@Getter
private ArrayList<String> bookVoteURLBookGUILayout = ArrayUtils.getInstance()
private ArrayList<String> bookVoteURLBookGUILayout = ArrayUtils
.convert(new String[] { "&c%Sitename%", "[UrlText]" });
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.TopLayout")
@Getter
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<String>();
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<>();
@ConfigDataString(path = "BOOK.VoteURLBookGUI.Title")
@Getter
private String bookVoteURLBookGUITitle = "&cVoteURL";
@Getter
@ConfigDataConfigurationSection(path = "CHEST.ShopConfirmPurchase.NoItem")
private ConfigurationSection chestShopConfirmPurchaseNoItem;
@Getter
@ConfigDataString(path = "CHEST.ShopConfirmPurchase.Title")
private String chestShopConfirmPurchaseTitle = "Confirm Purchase?";
@Getter
@ConfigDataConfigurationSection(path = "CHEST.ShopConfirmPurchase.YesItem")
private ConfigurationSection chestShopConfirmPurchaseYesItem;
@Getter
@ConfigDataString(path = "CHEST.VoteShopDisabled")
private String chestVoteShopDisabled = "&cVote shop disabled";
@ConfigDataBoolean(path = "CHEST.VoteShopHideLimitedReached")
@Getter
private boolean chestVoteShopHideLimitedReached = true;
@ConfigDataString(path = "CHEST.VoteShopLimitReached")
@Getter
private String chestVoteShopLimitReached = "&aYou reached your limit";
@ConfigDataBoolean(path = "CHEST.VoteShopRequireConfirmation")
@Getter
private boolean chestVoteShopRequireConfirmation = false;
@ConfigDataBoolean(path = "CHEST.VoteBest.BackButton")
@Getter
private boolean chestVoteBestBackButton = true;
@@ -162,59 +134,10 @@ public class GUI extends YMLFile {
private VotingPluginMain plugin;
public GUI(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
this.plugin = plugin;
}
public void createShop(String value) {
ConfigurationSection shopData = getData().createSection("CHEST.Shop." + value);
shopData.set("Identifier_Name", value);
shopData.set("Material", "STONE");
shopData.set("Amount", 1);
shopData.set("Name", "&cPlaceholder item");
shopData.set("Cost", 1);
shopData.set("Permission", "");
shopData.set("CloseGUI", true);
shopData.set("RequireConfirmation", false);
shopData.set("Rewards.Items.Item1.Material", "STONE");
shopData.set("Rewards.Items.Item1.Amount", 1);
saveData();
}
@ConfigDataConfigurationSection(path = "CHEST.BackButton")
@Getter
private ConfigurationSection CHESTBackButton;
public int getChestShopIdentifierCost(String identifier) {
return getData().getInt("CHEST.Shop." + identifier + ".Cost");
}
public String getChestShopIdentifierIdentifierName(String identifier) {
return getData().getString("CHEST.Shop." + identifier + ".Identifier_Name", identifier);
}
public int getChestShopIdentifierLimit(String identifier) {
return getData().getInt("CHEST.Shop." + identifier + ".Limit", -1);
}
public String getChestShopIdentifierRewardsPath(String identifier) {
return "CHEST.Shop." + identifier + ".Rewards";
}
public Set<String> getChestShopIdentifiers() {
ConfigurationSection shop = getData().getConfigurationSection("CHEST.Shop");
if (shop != null) {
return shop.getKeys(false);
}
return new HashSet<String>();
}
public ConfigurationSection getChestShopIdentifierSection(String identifier) {
return getData().getConfigurationSection("CHEST.Shop." + identifier);
}
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.DayBest.Item")
@Getter
private ConfigurationSection chestVoteBestDayBestItem;
@@ -235,54 +158,14 @@ public class GUI extends YMLFile {
@Getter
private String chestVoteGUIName = "&cVoteGUI: &c&l%player%";
/**
* Gets the vote GUI slot command.
*
* @param slot the slot
* @return the vote GUI slot command
*/
public String getChestVoteGUISlotCommand(String slot) {
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
}
/**
* Gets the vote GUI slot lore.
*
* @param slot the slot
* @return the vote GUI slot lore
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getChestVoteGUISlotLore(String slot) {
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
}
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
return "CHEST.VoteGUI." + slot + "." + lastPath;
}
@ConfigDataKeys(path = "CHEST.VoteGUI")
@Getter
private Set<String> chestVoteGUISlots = new HashSet<String>();
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
}
private Set<String> chestVoteGUISlots = new HashSet<>();
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.Customization")
@Getter
private ConfigurationSection chestVoteTopCustomization;
/**
* Gets the vote GUI slot slot.
*
* @param slot the slot
* @return the vote GUI slot slot
*/
public int getChestVoteGUISlotSlot(String slot) {
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
}
@ConfigDataBoolean(path = "CHEST.VoteLast.BackButton")
@Getter
private boolean chestVoteLastBackButton = false;
@@ -307,63 +190,10 @@ public class GUI extends YMLFile {
@Getter
private String chestVoteNextLine = "%time%";
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
}
@ConfigDataString(path = "CHEST.VoteRewardName")
@Getter
private String chestVoteRewardName = "VoteReward";
@ConfigDataBoolean(path = "CHEST.VoteShopBackButton")
@Getter
private boolean chestVoteShopBackButton = true;
@ConfigDataBoolean(path = "CHEST.VoteShopReopenGUIOnPurchase")
@Getter
private boolean chestVoteShopReopenGUIOnPurchase = true;
public boolean getChestVoteShopCloseGUI(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".CloseGUI", true);
}
public boolean getChestVoteShopHideOnNoPermission(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".HideOnNoPermission", true);
}
@ConfigDataBoolean(path = "CHEST.VoteShopEnabled")
@Getter
private boolean chestVoteShopEnabled = true;
@ConfigDataString(path = "CHEST.VoteShopName")
@Getter
private String chestVoteShopName = "VoteShop";
public boolean getChestVoteShopNotBuyable(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".NotBuyable", false);
}
public String getChestVoteShopPermission(String ident) {
return getData().getString("CHEST.Shop." + ident + ".Permission", "");
}
public String getCHESTVoteShopPurchase(String identifier) {
return getData().getString("CHEST.Shop." + identifier + ".PurchaseMessage",
plugin.getConfigFile().getFormatShopPurchaseMsg());
}
public boolean getChestVoteShopResetDaily(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Daily", false);
}
public boolean getChestVoteShopResetMonthly(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Monthly", false);
}
public boolean getChestVoteShopResetWeekly(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Weekly", false);
}
@ConfigDataBoolean(path = "CHEST.VoteStreak.BackButton")
@Getter
private boolean chestVoteStreakBackButton = false;
@@ -438,7 +268,7 @@ public class GUI extends YMLFile {
@ConfigDataListString(path = "CHEST.VoteTop.SwitchItem.TopVoters")
@Getter
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<String>();
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<>();
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.AllTimeTotal.Item")
@Getter
@@ -452,22 +282,6 @@ public class GUI extends YMLFile {
@Getter
private ConfigurationSection chestVoteTotalDayTotalItem;
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
switch (top) {
case AllTime:
return getChestVoteTotalAllTimeTotalItem();
case Daily:
return getChestVoteTotalDayTotalItem();
case Monthly:
return getChestVoteTotalMonthTotalItem();
case Weekly:
return getChestVoteTotalWeekTotalItem();
default:
return getChestVoteTotalAllTimeTotalItem();
}
}
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.MonthTotal.Item")
@Getter
private ConfigurationSection chestVoteTotalMonthTotalItem;
@@ -510,30 +324,7 @@ public class GUI extends YMLFile {
@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);
}
public Set<String> getChestGUIExtraItems(String gui) {
if (getData().isConfigurationSection("CHEST." + gui + ".ExtraItems")) {
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems").getKeys(false);
}
return new HashSet<String>();
}
public ConfigurationSection getChestGUIVoteShopExtraItems(String item) {
return getData().getConfigurationSection("CHEST.VoteShopExtraItems." + item);
}
@ConfigDataKeys(path = "CHEST.VoteShopExtraItems")
@Getter
private Set<String> chestGUIVoteShopExtraItems = new HashSet<String>();
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
}
private Set<String> chestVoteURLExtraItems = new HashSet<>();
@ConfigDataString(path = "CHEST.VoteURL.SiteName")
@Getter
@@ -567,9 +358,84 @@ public class GUI extends YMLFile {
@Getter
private boolean chestVoteURLViewAllUrlsButtonEnabled = false;
public boolean isChestVoteShopRequireConfirmation(String identifier) {
return getData().getBoolean("CHEST.Shop." + identifier + ".RequireConfirmation",
isChestVoteShopRequireConfirmation());
public GUI(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
this.plugin = plugin;
}
public Set<String> getChestGUIExtraItems(String gui) {
if (getData().isConfigurationSection("CHEST." + gui + ".ExtraItems")) {
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems").getKeys(false);
}
return new HashSet<>();
}
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
}
/**
* Gets the vote GUI slot command.
*
* @param slot the slot
* @return the vote GUI slot command
*/
public String getChestVoteGUISlotCommand(String slot) {
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
}
/**
* Gets the vote GUI slot lore.
*
* @param slot the slot
* @return the vote GUI slot lore
*/
@SuppressWarnings("unchecked")
public ArrayList<String> getChestVoteGUISlotLore(String slot) {
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<>());
}
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
return "CHEST.VoteGUI." + slot + "." + lastPath;
}
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
}
/**
* Gets the vote GUI slot slot.
*
* @param slot the slot
* @return the vote GUI slot slot
*/
public int getChestVoteGUISlotSlot(String slot) {
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
}
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
}
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
switch (top) {
case AllTime:
return getChestVoteTotalAllTimeTotalItem();
case Daily:
return getChestVoteTotalDayTotalItem();
case Monthly:
return getChestVoteTotalMonthTotalItem();
case Weekly:
return getChestVoteTotalWeekTotalItem();
default:
return getChestVoteTotalAllTimeTotalItem();
}
}
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
}
@Override
@@ -581,9 +447,4 @@ public class GUI extends YMLFile {
public void onFileCreation() {
plugin.saveResource("GUI.yml", true);
}
public void removeShop(String value) {
getData().set("CHEST.Shop." + value, null);
saveData();
}
}
@@ -0,0 +1,198 @@
package com.bencodez.votingplugin.config;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.bencodez.simpleapi.file.YMLFile;
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
import com.bencodez.simpleapi.file.annotation.ConfigDataConfigurationSection;
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
import com.bencodez.votingplugin.VotingPluginMain;
import lombok.Getter;
public class ShopFile extends YMLFile {
@Getter
@ConfigDataConfigurationSection(path = "ShopConfirmPurchase.NoItem")
private ConfigurationSection shopConfirmPurchaseNoItem;
@Getter
@ConfigDataString(path = "ShopConfirmPurchase.Title")
private String shopConfirmPurchaseTitle = "Confirm Purchase?";
@Getter
@ConfigDataConfigurationSection(path = "ShopConfirmPurchase.YesItem")
private ConfigurationSection shopConfirmPurchaseYesItem;
@Getter
@ConfigDataString(path = "VoteShop.Disabled")
private String voteShopDisabled = "&cVote shop disabled";
@ConfigDataBoolean(path = "VoteShop.HideLimitedReached")
@Getter
private boolean voteShopHideLimitedReached = true;
@ConfigDataString(path = "VoteShop.LimitReached")
@Getter
private String voteShopLimitReached = "&aYou reached your limit";
@ConfigDataBoolean(path = "VoteShop.RequireConfirmation")
@Getter
private boolean voteShopRequireConfirmation = false;
private VotingPluginMain plugin;
@ConfigDataBoolean(path = "VoteShop.BackButton")
@Getter
private boolean voteShopBackButton = true;
@ConfigDataBoolean(path = "VoteShop.ReopenGUIOnPurchase")
@Getter
private boolean voteShopReopenGUIOnPurchase = true;
@ConfigDataBoolean(path = "VoteShop.Enabled")
@Getter
private boolean voteShopEnabled = true;
@ConfigDataString(path = "VoteShop.Name")
@Getter
private String voteShopName = "VoteShop";
@ConfigDataKeys(path = "ExtraItems")
@Getter
private Set<String> voteShopExtraItems = new HashSet<>();
public ShopFile(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "Shop.yml"));
this.plugin = plugin;
}
public void convertFromGUIFile() {
// booleans
setValue("VoteShop.Enabled", plugin.getGui().getData().getBoolean("CHEST.VoteShopEnabled"));
setValue("VoteShop.BackButton", plugin.getGui().getData().getBoolean("CHEST.VoteShopBackButton"));
setValue("VoteShop.HideLimitReached", plugin.getGui().getData().getBoolean("CHEST.VoteShopHideLimitedReached"));
setValue("VoteShop.RequireConfirmation",
plugin.getGui().getData().getBoolean("CHEST.VoteShopRequireConfirmation"));
setValue("VoteShop.ReopenGUIOnPurchase",
plugin.getGui().getData().getBoolean("CHEST.VoteShopReopenGUIOnPurchase"));
// strings
setValue("VoteShop.Name", plugin.getGui().getData().getString("CHEST.VoteShopName"));
setValue("VoteShop.LimitReached", plugin.getGui().getData().getString("CHEST.VoteShopLimitReached"));
setValue("VoteShop.Disabled", plugin.getGui().getData().getString("CHEST.VoteShopDisabled"));
// sections
setValue("Shop", plugin.getGui().getData().getConfigurationSection("CHEST.Shop"));
setValue("ExtraItems", plugin.getGui().getData().getConfigurationSection("CHEST.VoteShopExtraItems"));
setValue("ShopConfirmPurchase", plugin.getGui().getData().getConfigurationSection("CHEST.ShopConfirmPurchase"));
saveData();
}
public void createShop(String value) {
ConfigurationSection shopData = getData().createSection("Shop." + value);
shopData.set("Identifier_Name", value);
shopData.set("Material", "STONE");
shopData.set("Amount", 1);
shopData.set("Name", "&cPlaceholder item");
shopData.set("Cost", 1);
shopData.set("Permission", "");
shopData.set("CloseGUI", true);
shopData.set("RequireConfirmation", false);
shopData.set("Rewards.Items.Item1.Material", "STONE");
shopData.set("Rewards.Items.Item1.Amount", 1);
saveData();
}
public ConfigurationSection getGUIVoteShopExtraItems(String item) {
return getData().getConfigurationSection("ExtraItems." + item);
}
public int getShopIdentifierCost(String identifier) {
return getData().getInt("Shop." + identifier + ".Cost");
}
public String getShopIdentifierIdentifierName(String identifier) {
return getData().getString("Shop." + identifier + ".Identifier_Name", identifier);
}
public int getShopIdentifierLimit(String identifier) {
return getData().getInt("Shop." + identifier + ".Limit", -1);
}
public String getShopIdentifierRewardsPath(String identifier) {
return "Shop." + identifier + ".Rewards";
}
public Set<String> getShopIdentifiers() {
ConfigurationSection shop = getData().getConfigurationSection("Shop");
if (shop != null) {
return shop.getKeys(false);
}
return new HashSet<>();
}
public ConfigurationSection getShopIdentifierSection(String identifier) {
return getData().getConfigurationSection("Shop." + identifier);
}
public boolean getVoteShopCloseGUI(String shop) {
return getData().getBoolean("Shop." + shop + ".CloseGUI", true);
}
public boolean getVoteShopHideOnNoPermission(String shop) {
return getData().getBoolean("Shop." + shop + ".HideOnNoPermission", true);
}
public boolean getVoteShopNotBuyable(String shop) {
return getData().getBoolean("Shop." + shop + ".NotBuyable", false);
}
public String getVoteShopPermission(String ident) {
return getData().getString("Shop." + ident + ".Permission", "");
}
public String getVoteShopPurchase(String identifier) {
return getData().getString("Shop." + identifier + ".PurchaseMessage",
plugin.getConfigFile().getFormatShopPurchaseMsg());
}
public boolean getVoteShopResetDaily(String shop) {
return getData().getBoolean("Shop." + shop + ".Reset.Daily", false);
}
public boolean getVoteShopResetMonthly(String shop) {
return getData().getBoolean("Shop." + shop + ".Reset.Monthly", false);
}
public boolean getVoteShopResetWeekly(String shop) {
return getData().getBoolean("Shop." + shop + ".Reset.Weekly", false);
}
public boolean isVoteShopRequireConfirmation(String identifier) {
return getData().getBoolean("Shop." + identifier + ".RequireConfirmation", isVoteShopRequireConfirmation());
}
@Override
public void loadValues() {
new AnnotationHandler().load(getData(), this);
}
@Override
public void onFileCreation() {
plugin.saveResource("Shop.yml", true);
}
public void removeShop(String value) {
getData().set("Shop." + value, null);
saveData();
}
}
@@ -6,14 +6,15 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
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.simpleapi.file.YMLFile;
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
import com.bencodez.simpleapi.file.annotation.ConfigDataDouble;
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
import com.bencodez.simpleapi.file.annotation.ConfigDataListInt;
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -66,7 +67,7 @@ public class SpecialRewardsConfig extends YMLFile {
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
@Getter
private boolean votePartyResetExtraVotesMonthly = false;
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesWeekly")
@Getter
private boolean votePartyResetExtraVotesWeekly = false;
@@ -75,13 +76,13 @@ public class SpecialRewardsConfig extends YMLFile {
@Getter
private String votePartyVoteReminderBroadcast = "%votesrequired% left to go, go vote!";
@ConfigDataListString(path = "VoteParty.VoteReminderAtVotes")
@ConfigDataListInt(path = "VoteParty.VoteReminderAtVotes")
@Getter
private ArrayList<String> votePartyVoteReminderAtVotes = new ArrayList<String>();
private ArrayList<Integer> votePartyVoteReminderAtVotes = new ArrayList<>();
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
@Getter
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<String>();
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<>();
@Getter
private String votePartyRewardsPath = "VoteParty.Rewards";
@@ -102,119 +103,29 @@ public class SpecialRewardsConfig extends YMLFile {
@Getter
private double voteStreakRequirementWeek = 50;
public SpecialRewardsConfig(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "SpecialRewards.yml"));
this.plugin = plugin;
}
public boolean getCumulativeRewardEnabled(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".Enabled");
}
public String getCumulativeRewardsPath(int cumulative) {
return "Cumulative." + cumulative + ".Rewards";
}
public List<Integer> getCumulativeBlackList(int cumulative) {
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
}
public boolean getCumulativeRecurring(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
}
@ConfigDataKeys(path = "Cumulative")
@Getter
private Set<String> cumulativeVotes = new HashSet<String>();
@Deprecated
public boolean getCumulativeVotesInSameDay(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
}
@Deprecated
public boolean getCumulativeVotesInSameMonth(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameMonth");
}
@Deprecated
public boolean getCumulativeVotesInSameWeek(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
}
public String getCumulativeVotesTotal(int cumulative) {
String str = getData().getString("Cumulative." + cumulative + ".TotalToUse", "");
if (str.isEmpty()) {
if (getCumulativeVotesInSameMonth(cumulative)) {
return TopVoter.Monthly.toString();
} else if (getCumulativeVotesInSameWeek(cumulative)) {
return TopVoter.Weekly.toString();
} else if (getCumulativeVotesInSameDay(cumulative)) {
return TopVoter.Daily.toString();
}
}
return str;
}
public String getDailyAwardRewardsPath(String path) {
return "DailyAwards." + path + ".Rewards";
}
private Set<String> cumulativeVotes = new HashSet<>();
@ConfigDataKeys(path = "DailyAwards")
@Getter
private Set<String> dailyPossibleRewardPlaces = new HashSet<String>();
/**
* Gets the milestone reward enabled.
*
* @param milestones the milestones
* @return the milestone reward enabled
*/
public boolean getMilestoneRewardEnabled(int milestones) {
return getData().getBoolean("MileStones." + milestones + ".Enabled");
}
/**
* Gets the milestone rewards.
*
* @param milestones the milestones
* @return the milestone rewards
*/
public String getMilestoneRewardsPath(int milestones) {
return "MileStones." + milestones + ".Rewards";
}
private Set<String> dailyPossibleRewardPlaces = new HashSet<>();
@ConfigDataKeys(path = "MileStones")
@Getter
private Set<String> milestoneVotes = new HashSet<String>();
public String getMonthlyAwardRewardsPath(String path) {
return "MonthlyAwards." + path + ".Rewards";
}
/**
* Gets the monthly possible reward places.
*
* @return the monthly possible reward places
*/
public Set<String> getMonthlyPossibleRewardPlaces() {
try {
return getData().getConfigurationSection("MonthlyAwards").getKeys(false);
} catch (Exception ex) {
return new HashSet<String>();
}
}
private Set<String> milestoneVotes = new HashSet<>();
@ConfigDataBoolean(path = "ResetMilestonesMonthly")
@Getter
private boolean resetMilestonesMonthly = false;
@ConfigDataString(path = "VoteParty.Broadcast")
@Getter
private String votePartyBroadcast = "";
@ConfigDataListString(path = "VoteParty.GlobalCommands", secondPath = "VoteParty.Commands")
@Getter
private ArrayList<String> votePartyGlobalCommands = new ArrayList<String>();
private ArrayList<String> votePartyGlobalCommands = new ArrayList<>();
@ConfigDataBoolean(path = "VoteParty.CountFakeVotes")
@Getter
@@ -232,8 +143,13 @@ public class SpecialRewardsConfig extends YMLFile {
@Getter
private boolean votePartyGiveAllPlayers = false;
@Deprecated
@ConfigDataInt(path = "VoteParty.IncreaseVotesRquired")
@Getter
private int votePartyIncreaseVotesRquired = 0;
@ConfigDataInt(path = "VoteParty.IncreaseVotesRequired")
@Getter
private int votePartyIncreaseVotesRequired = 0;
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerDay")
@@ -259,11 +175,115 @@ public class SpecialRewardsConfig extends YMLFile {
@ConfigDataInt(path = "VoteParty.UserVotesRequired")
@Getter
private int votePartyUserVotesRequired = 0;
@ConfigDataInt(path = "VoteParty.VotesRequired")
@Getter
private int votePartyVotesRequired = 0;
@ConfigDataKeys(path = "WeeklyAwards")
@Getter
private Set<String> weeklyPossibleRewardPlaces = new HashSet<>();
public SpecialRewardsConfig(VotingPluginMain plugin) {
super(plugin, new File(plugin.getDataFolder(), "SpecialRewards.yml"));
this.plugin = plugin;
}
public List<Integer> getCumulativeBlackList(int cumulative) {
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
}
public boolean getCumulativeRecurring(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
}
public boolean getCumulativeRewardEnabled(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".Enabled");
}
public String getCumulativeRewardsPath(int cumulative) {
return "Cumulative." + cumulative + ".Rewards";
}
@Deprecated
public boolean getCumulativeVotesInSameDay(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
}
@Deprecated
public boolean getCumulativeVotesInSameMonth(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameMonth");
}
@Deprecated
public boolean getCumulativeVotesInSameWeek(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
}
public String getCumulativeVotesTotal(int cumulative) {
String str = getData().getString("Cumulative." + cumulative + ".TotalToUse", "");
if (str.isEmpty()) {
if (getCumulativeVotesInSameMonth(cumulative)) {
return TopVoter.Monthly.toString();
}
if (getCumulativeVotesInSameWeek(cumulative)) {
return TopVoter.Weekly.toString();
}
if (getCumulativeVotesInSameDay(cumulative)) {
return TopVoter.Daily.toString();
}
}
return str;
}
public String getDailyAwardRewardsPath(String path) {
return "DailyAwards." + path + ".Rewards";
}
/**
* Gets the milestone reward enabled.
*
* @param milestones the milestones
* @return the milestone reward enabled
*/
public boolean getMilestoneRewardEnabled(int milestones) {
return getData().getBoolean("MileStones." + milestones + ".Enabled");
}
/**
* Gets the milestone rewards.
*
* @param milestones the milestones
* @return the milestone rewards
*/
public String getMilestoneRewardsPath(int milestones) {
return "MileStones." + milestones + ".Rewards";
}
public String getMonthlyAwardRewardsPath(String path) {
return "MonthlyAwards." + path + ".Rewards";
}
/**
* Gets the monthly possible reward places.
*
* @return the monthly possible reward places
*/
public Set<String> getMonthlyPossibleRewardPlaces() {
try {
return getData().getConfigurationSection("MonthlyAwards").getKeys(false);
} catch (Exception ex) {
return new HashSet<>();
}
}
public int getVotePartyIncreaseVotesRequiredWithTypo() {
int increase = getVotePartyIncreaseVotesRequired();
if (increase > 0) {
return increase;
}
return getVotePartyIncreaseVotesRquired();
}
public boolean getVoteStreakRewardEnabled(String type, String s) {
return getData().getBoolean("VoteStreak." + type + "." + s + ".Enabled");
}
@@ -278,9 +298,9 @@ public class SpecialRewardsConfig extends YMLFile {
if (set != null) {
return set;
}
return new HashSet<String>();
return new HashSet<>();
} catch (Exception ex) {
return new HashSet<String>();
return new HashSet<>();
}
}
@@ -288,10 +308,6 @@ public class SpecialRewardsConfig extends YMLFile {
return "WeeklyAwards." + path + ".Rewards";
}
@ConfigDataKeys(path = "WeeklyAwards")
@Getter
private Set<String> weeklyPossibleRewardPlaces = new HashSet<String>();
@Override
public void loadValues() {
new AnnotationHandler().load(getData(), this);
@@ -16,7 +16,7 @@ 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.simpleapi.sql.Column;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
@@ -29,27 +29,18 @@ public class CoolDownCheck implements Listener {
private VotingPluginMain plugin;
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<>();
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
public CoolDownCheck(VotingPluginMain plugin) {
this.plugin = plugin;
this.timer = Executors.newScheduledThreadPool(1);
}
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<>();
@Getter
private ScheduledExecutorService timer;
private boolean cooldownCheckEnabled = false;
public void checkEnabled() {
if (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
cooldownCheckEnabled = true;
} else {
cooldownCheckEnabled = false;
}
public CoolDownCheck(VotingPluginMain plugin) {
this.plugin = plugin;
this.timer = Executors.newScheduledThreadPool(1);
}
public void check(UUID uuid) {
@@ -60,25 +51,6 @@ public class CoolDownCheck implements Listener {
check(user);
}
public void checkPerSite(UUID 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, true);
}
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
user.setCoolDownCheckSite(site, Boolean.FALSE);
schedulePerSite(user, true);
}
}
public synchronized void check(VotingPluginUser user) {
boolean coolDownCheck = user.getCoolDownCheck();
if (coolDownCheck) {
@@ -93,6 +65,48 @@ 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());
}
public void checkEnabled() {
if (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
cooldownCheckEnabled = true;
} else {
cooldownCheckEnabled = false;
}
}
public void checkPerSite(UUID uuid) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
if (!user.isOnline()) {
user.dontCache();
}
checkPerSite(user);
}
public synchronized void checkPerSite(VotingPluginUser user) {
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
@@ -117,6 +131,74 @@ public class CoolDownCheck implements Listener {
}
public void load() {
plugin.addUserStartup(new UserStartup() {
@Override
public void onFinish() {
}
@Override
public void onStart() {
}
@Override
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
user.dontCache();
if (cooldownCheckEnabled) {
check(user);
}
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
checkPerSite(user);
}
}
});
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
"VoteCoolDownEndedReward", new RewardOptions());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
new RewardOptions().addPlaceholder("sitename", event.getSite().getDisplayName()).addPlaceholder("url",
event.getSite().getVoteURL(false)));
}
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);
}
if (time > 0) {
user.setCoolDownCheck(true);
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
@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 schedulePerSite(VotingPluginUser user, boolean force) {
if (user.getSitesVotedOn() > 0 || force) {
final UUID uuid = UUID.fromString(user.getUUID());
@@ -143,97 +225,15 @@ public class CoolDownCheck implements Listener {
}
}
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);
}
if (time > 0) {
user.setCoolDownCheck(true);
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
@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 vote(VotingPluginUser user, VoteSite site) {
if (cooldownCheckEnabled) {
schedule(user, true);
}
}
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);
}
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
checkPerSite(user);
}
}
@Override
public void onStart() {
}
@Override
public void onFinish() {
}
});
}
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;
}
}
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
user.setCoolDownCheckSite(site, Boolean.FALSE);
schedulePerSite(user, true);
}
cols.clear();
cols = null;
plugin.getLogger().info("Finished checking vote cooldown rewards for all players: " + site.getKey());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
"VoteCoolDownEndedReward", new RewardOptions());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
new RewardOptions().addPlaceholder("sitename", event.getSite().getDisplayName()).addPlaceholder("url",
event.getSite().getVoteURL(false)));
}
}
@@ -12,7 +12,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.signs.SignHandler;
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
@@ -32,57 +32,18 @@ public class ServerData {
public void addAutoCachedPlaceholder(String placeholder) {
List<String> p = getAutoCachedPlaceholder();
if (!ArrayUtils.getInstance().containsIgnoreCase(p, placeholder)) {
if (!ArrayUtils.containsIgnoreCase(p, placeholder)) {
p.add(placeholder);
setAutoCachedPlaceholder(p);
}
}
public void updatePlaceholders() {
boolean data = getData().getBoolean("AutoCacheUpdated", false);
if (!data) {
List<String> placeholders = getAutoCachedPlaceholder();
for (int i = 0; i < placeholders.size(); i++) {
placeholders.set(i, placeholders.get(i).toLowerCase());
}
setAutoCachedPlaceholder(placeholders);
getData().set("AutoCacheUpdated", true);
saveData();
}
}
public void addVoteShopPurchase(String ident) {
setVoteShopPurchases(ident, (getVoteShopPurchases(ident) + 1));
}
public void setVoteShopPurchases(String ident, int amount) {
getData().set("VoteShopPurchases." + ident, amount);
saveData();
}
public int getVoteShopPurchases(String ident) {
return getData().getInt("VoteShopPurchases." + ident);
}
public void setAutoCachedPlaceholder(List<String> placeholders) {
getData().set("AutoCachePlaceholders", placeholders);
saveData();
}
public List<String> getAutoCachedPlaceholder() {
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)) {
l.add(site);
}
setServiceSites(ArrayUtils.getInstance().removeDuplicates(l));
setServiceSites(ArrayUtils.removeDuplicates(l));
}
/**
@@ -107,6 +68,34 @@ public class ServerData {
getSignSkullLocation("" + count), getSignData("" + count), getSignPosition("" + count)));
}
public void addTimeVoted(int num, VoteTimeQueue vote) {
getData().set("TimedVoteCache." + num + ".Name", vote.getName());
getData().set("TimedVoteCache." + num + ".Service", vote.getService());
getData().set("TimedVoteCache." + num + ".Time", vote.getTime());
saveData();
}
public void addVoteShopPurchase(String ident) {
setVoteShopPurchases(ident, (getVoteShopPurchases(ident) + 1));
}
public void clearTimedVoteCache() {
getData().set("TimedVoteCache", null);
saveData();
}
public List<String> getAutoCachedPlaceholder() {
return getData().getStringList("AutoCachePlaceholders");
}
public int getBungeeVotePartyCurrent() {
return getData().getInt("BungeeVotePartyCurrent");
}
public int getBungeeVotePartyRequired() {
return getData().getInt("BungeeVotePartyRequired");
}
/**
* Gets the data.
*
@@ -121,9 +110,13 @@ public class ServerData {
return data;
}
public List<String> getDisabledReminders() {
return getData().getStringList("DisabledReminders");
}
@SuppressWarnings("unchecked")
public ArrayList<String> getServiceSites() {
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<String>());
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<>());
}
/**
@@ -167,7 +160,7 @@ public class ServerData {
try {
return getData().getConfigurationSection("Signs").getKeys(false);
} catch (Exception ex) {
return new HashSet<String>();
return new HashSet<>();
}
}
@@ -186,10 +179,25 @@ public class ServerData {
getData().getDouble("Signs." + sign + ".Skull.Z"));
}
public Set<String> getTimedVoteCacheKeys() {
if (getData().isConfigurationSection("TimedVoteCache")) {
return getData().getConfigurationSection("TimedVoteCache").getKeys(false);
}
return new HashSet<>();
}
public ConfigurationSection getTimedVoteCacheSection(String num) {
return getData().getConfigurationSection("TimedVoteCache." + num);
}
public int getVotePartyExtraRequired() {
return getData().getInt("VotePartyExtraRequired", 0);
}
public int getVoteShopPurchases(String ident) {
return getData().getInt("VoteShopPurchases." + ident);
}
public boolean isLastVotePartySameDay() {
int num = getData().getInt("LastVoteParty", 0);
if (num == plugin.getTimeChecker().getTime().getDayOfYear()) {
@@ -207,6 +215,10 @@ public class ServerData {
return false;
}
public boolean isVoteShopConverted() {
return getData().getBoolean("VoteShopConverted");
}
/**
* Next sign number.
*
@@ -259,11 +271,40 @@ public class ServerData {
plugin.getServerDataFile().saveData();
}
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
ArrayList<String> uuids = new ArrayList<>();
for (UUID uuid : disabledReminders) {
uuids.add(uuid.toString());
}
getData().set("DisabledReminders", uuids);
saveData();
}
public void setAutoCachedPlaceholder(List<String> placeholders) {
getData().set("AutoCachePlaceholders", placeholders);
saveData();
}
public void setBungeeVotePartyCurrent(int current) {
getData().set("BungeeVotePartyCurrent", current);
saveData();
}
public void setBungeeVotePartyRequired(int required) {
getData().set("BungeeVotePartyRequired", required);
saveData();
}
public void setServiceSites(ArrayList<String> list) {
getData().set("ServiceSites", list);
saveData();
}
public void setShopConverted(boolean value) {
getData().set("VoteShopConverted", value);
saveData();
}
public void setSign(String count, Location location, Location skullLocation, String data, int position) {
getData().set("Signs." + count + ".World", location.getWorld().getName());
@@ -303,6 +344,11 @@ public class ServerData {
saveData();
}
public void setVoteShopPurchases(String ident, int amount) {
getData().set("VoteShopPurchases." + ident, amount);
saveData();
}
public void updateLastVoteParty() {
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
saveData();
@@ -314,31 +360,17 @@ public class ServerData {
saveData();
}
public int getBungeeVotePartyCurrent() {
return getData().getInt("BungeeVotePartyCurrent");
}
public int getBungeeVotePartyRequired() {
return getData().getInt("BungeeVotePartyRequired");
}
public void setBungeeVotePartyCurrent(int current) {
getData().set("BungeeVotePartyCurrent", current);
saveData();
}
public void setBungeeVotePartyRequired(int required) {
getData().set("BungeeVotePartyRequired", required);
saveData();
}
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
ArrayList<String> uuids = new ArrayList<String>();
for (UUID uuid : disabledReminders) {
uuids.add(uuid.toString());
public void updatePlaceholders() {
boolean data = getData().getBoolean("AutoCacheUpdated", false);
if (!data) {
List<String> placeholders = getAutoCachedPlaceholder();
for (int i = 0; i < placeholders.size(); i++) {
placeholders.set(i, placeholders.get(i).toLowerCase());
}
setAutoCachedPlaceholder(placeholders);
getData().set("AutoCacheUpdated", true);
saveData();
}
getData().set("DisabledReminders", uuids);
saveData();
}
/**
@@ -347,28 +379,4 @@ public class ServerData {
public void updateValues() {
setVersion();
}
public void addTimeVoted(int num, VoteTimeQueue vote) {
getData().set("TimedVoteCache." + num + ".Name", vote.getName());
getData().set("TimedVoteCache." + num + ".Service", vote.getService());
getData().set("TimedVoteCache." + num + ".Time", vote.getTime());
saveData();
}
public Set<String> getTimedVoteCacheKeys() {
if (getData().isConfigurationSection("TimedVoteCache")) {
return getData().getConfigurationSection("TimedVoteCache").getKeys(false);
} else {
return new HashSet<String>();
}
}
public ConfigurationSection getTimedVoteCacheSection(String num) {
return getData().getConfigurationSection("TimedVoteCache." + num);
}
public void clearTimedVoteCache() {
getData().set("TimedVoteCache", null);
saveData();
}
}
@@ -3,8 +3,8 @@ package com.bencodez.votingplugin.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.proxy.BungeeMessageData;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -55,7 +55,7 @@ public class PlayerPostVoteEvent extends Event {
@Getter
@Setter
private VoteSite voteSite;
@Getter
@Setter
private long voteTime = 0;
@@ -64,7 +64,8 @@ public class PlayerPostVoteEvent extends Event {
@Setter
private VotingPluginUser votingPluginUser;
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee, long voteTime) {
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee,
long voteTime) {
super(true);
this.user = user;
this.voteSite = voteSite;
@@ -3,8 +3,8 @@ package com.bencodez.votingplugin.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.proxy.BungeeMessageData;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -9,7 +9,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.misc.PlayerManager;
import com.bencodez.simpleapi.player.PlayerUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.signs.SignHandler;
@@ -55,19 +56,19 @@ public class PlayerInteract implements Listener {
.sendMessage(sign.getRightClickMessage());
if (!sign.isSkullSet()) {
if (PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
if (PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(),
"VotingPlugin.Sign.Create")
|| PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|| PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(),
"VotingPlugin.Admin")) {
player.sendMessage("Skull not set, click to set skull");
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", sign.getSign());
PlayerUtils.setPlayerMeta(plugin, player, "skullset", sign.getSign());
}
}
}
}
} else if (event.getClickedBlock().getState() instanceof Skull) {
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "skullset");
Object ob = PlayerUtils.getPlayerMeta(plugin, player, "skullset");
if (ob != null) {
String sign1 = (String) ob;
for (SignHandler sign : plugin.getSigns().getSigns()) {
@@ -78,7 +79,7 @@ public class PlayerInteract implements Listener {
player.sendMessage("Skull set");
}
}
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", null);
PlayerUtils.setPlayerMeta(plugin, player, "skullset", null);
}
}
}
@@ -8,7 +8,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.user.VotingPluginUser;
// TODO: Auto-generated Javadoc
@@ -42,15 +41,15 @@ public class PlayerJoinEvent implements Listener {
if (data) {
// give offline vote (if they voted offline)
user.offVote();
} else {
plugin.debug("No data detected for " + player.getUniqueId().toString() + "/" + player.getName());
}
user.loginRewards();
plugin.getPlaceholders().onUpdate(user, true);
if (plugin.getBungeeSettings().isUseBungeecoord()
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.REDIS))) {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("Login", user.getPlayerName(),
user.getUUID(), plugin.getBungeeSettings().getServer());
}
@@ -74,14 +73,14 @@ public class PlayerJoinEvent implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event) {
if (plugin != null && plugin.isEnabled()) {
final java.util.UUID uuid = event.getPlayer().getUniqueId();
final Player player = event.getPlayer();
plugin.getLoginTimer().execute(new Runnable() {
@Override
public void run() {
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
VotingPluginMain.plugin.getAdvancedTab().remove(player.getUniqueId());
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
user.dontCache();
user.logoutRewards();
plugin.getPlaceholders().onLogout(user);
@@ -10,13 +10,13 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.misc.PlayerManager;
import com.bencodez.simpleapi.array.ArrayUtils;
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.proxy.BungeeMethod;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -50,7 +50,25 @@ public class PlayerVoteListener implements Listener {
}
String playerName = event.getPlayer();
plugin.debug("Processing PlayerVoteEvent: " + playerName + "/" + event.getServiceSite());
if (!PlayerUtils.getInstance().isValidUser(playerName, plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
boolean notValid = false;
if (!PlayerManager.getInstance().isValidUser(playerName, plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
if (!playerName.startsWith(plugin.getOptions().getBedrockPlayerPrefix())
&& !plugin.getOptions().getBedrockPlayerPrefix().isEmpty()) {
if (!event.isBungee() && PlayerManager.getInstance().isValidUser(
plugin.getOptions().getBedrockPlayerPrefix() + playerName,
plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
plugin.debug("Detected a bedrock user without bedrock prefix, adjusting");
playerName = plugin.getOptions().getBedrockPlayerPrefix() + playerName;
} else {
notValid = true;
}
} else {
notValid = true;
}
}
if (notValid) {
if (!plugin.getConfigFile().isAllowUnjoined()) {
plugin.getLogger().warning("Player " + playerName
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
@@ -86,12 +104,11 @@ public class PlayerVoteListener implements Listener {
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
plugin.getLogger().warning("No voting site with the service site: '" + event.getServiceSite() + "'");
ArrayList<String> services = new ArrayList<String>();
ArrayList<String> services = new ArrayList<>();
for (VoteSite site : plugin.getVoteSites()) {
services.add(site.getServiceSite());
}
plugin.getLogger()
.warning("Currently set service sites: " + ArrayUtils.getInstance().makeStringList(services));
plugin.getLogger().warning("Currently set service sites: " + ArrayUtils.makeStringList(services));
}
return;
}
@@ -118,13 +135,12 @@ public class PlayerVoteListener implements Listener {
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 {
if (!user.hasPermission("VotingPlugin.BypassWaitUntilVoteDelay")) {
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
return;
}
plugin.getLogger()
.info(user.getPlayerName() + " has bypass permission for WaitUntilVoteDelay, bypassing");
}
}
@@ -227,7 +243,10 @@ public class PlayerVoteListener implements Listener {
}
LocalDateTime cTime = plugin.getTimeChecker().getTime();
int days = cTime.getDayOfMonth();
plugin.extraDebug("Current day of month: " + days + " Current total: " + value);
if (value >= days * plugin.getVoteSitesEnabled().size()) {
plugin.debug("Detected higher month total, changing. Current Total: " + value + " Days: " + days
+ " New Total: " + days * plugin.getVoteSitesEnabled().size());
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSitesEnabled().size());
}
}
@@ -4,8 +4,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.SignChangeEvent;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.misc.PlayerManager;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -34,8 +34,8 @@ public class SignChange implements Listener {
@EventHandler(ignoreCancelled = true)
public void onSignChange(SignChangeEvent event) {
if (event.getLine(0).equalsIgnoreCase("[VotingPlugin]")) {
if (PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(), "VotingPlugin.Sign.Create")
|| PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
if (PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(), "VotingPlugin.Sign.Create")
|| PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(),
"VotingPlugin.Admin")) {
String data = event.getLine(2);
if (!data.equalsIgnoreCase("all") && !data.equalsIgnoreCase("monthly")
@@ -45,7 +45,7 @@ public class SignChange implements Listener {
try {
plugin.getServerData().addSign(event.getBlock().getLocation(), event.getLine(2),
Integer.parseInt(event.getLine(1)));
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&aAdded sign!"));
event.getPlayer().sendMessage(MessageAPI.colorize("&aAdded sign!"));
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
@@ -55,12 +55,11 @@ public class SignChange implements Listener {
}
});
} catch (Exception ex) {
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&cError on sign creation!"));
event.getPlayer().sendMessage(MessageAPI.colorize("&cError on sign creation!"));
ex.printStackTrace();
}
} else {
event.getPlayer()
.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatNoPerms()));
event.getPlayer().sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatNoPerms()));
}
}
@@ -6,10 +6,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.bencodez.votingplugin.proxy.BungeeMethod;
import com.vexsoftware.votifier.model.Vote;
import com.vexsoftware.votifier.model.VotifierEvent;
@@ -72,9 +72,11 @@ public class VotiferEvent implements Listener {
plugin.getServerData().addServiceSite(voteSite);
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getBungeeSettings().isVotifierBypass()
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS)
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MQTT)
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.REDIS))) {
plugin.getLogger().severe(
"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");
"Ignoring vote from votifier since pluginmessaging, socket, redis, or mqtt 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 matchSite = "";
@@ -89,7 +91,7 @@ public class VotiferEvent implements Listener {
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
boolean createSite = false;
if (sites != null) {
if (!ArrayUtils.getInstance().containsIgnoreCase(sites, voteSiteNameStr)) {
if (!ArrayUtils.containsIgnoreCase(sites, voteSiteNameStr)) {
createSite = true;
}
} else {
@@ -104,7 +106,7 @@ public class VotiferEvent implements Listener {
plugin.getConfigVoteSites().generateVoteSite(voteSiteNameStr);
plugin.getLogger().info("Current known service sites: "
+ ArrayUtils.getInstance().makeStringList(plugin.getServerData().getServiceSites()));
+ ArrayUtils.makeStringList(plugin.getServerData().getServiceSites()));
}
if (plugin.getTimeChecker().isActiveProcessing()
@@ -10,12 +10,13 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.proxy.BungeeMethod;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -81,6 +82,10 @@ public class VoteSite {
@Setter
private String voteURL;
@Getter
@Setter
private String permissionToView;
@Getter
@Setter
private boolean waitUntilVoteDelay;
@@ -126,8 +131,8 @@ public class VoteSite {
}
} else {
String bc = StringParser.getInstance().colorize(plugin.getConfigFile().getFormatBroadCastMsg());
HashMap<String, String> placeholders = new HashMap<String, String>();
String bc = MessageAPI.colorize(plugin.getConfigFile().getFormatBroadCastMsg());
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("player", playerName);
placeholders.put("nickname",
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
@@ -135,9 +140,9 @@ public class VoteSite {
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>();
bc = PlaceholderUtils.replacePlaceHolder(bc, placeholders);
bc = PlaceholderUtils.replacePlaceHolders(user.getOfflinePlayer(), bc);
ArrayList<Player> players = new ArrayList<>();
for (Player p : Bukkit.getOnlinePlayers()) {
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
players.add(p);
@@ -159,9 +164,8 @@ public class VoteSite {
plugin.getLogger().warning("Invalid display item section in site: " + key);
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid display item for site: " + key)
.setLore("&cInvalid display item for site: " + key);
} else {
return new ItemBuilder(item);
}
return new ItemBuilder(item);
}
public ConfigurationSection getSiteData() {
@@ -173,20 +177,18 @@ public class VoteSite {
}
public String getVoteURL(boolean json) {
if (!plugin.getConfigFile().isFormatCommandsVoteForceLinks() || !json
|| StringParser.getInstance().containsJson(voteURL)) {
if (!plugin.getConfigFile().isFormatCommandsVoteForceLinks() || !json || MessageAPI.containsJson(voteURL)) {
return voteURL;
} else {
if (!voteURL.startsWith("http")) {
return "[Text=\"" + voteURL + "\",url=\"http://" + voteURL + "\"]";
}
return "[Text=\"" + voteURL + "\",url=\"" + voteURL + "\"]";
}
if (!voteURL.startsWith("http")) {
return "[Text=\"" + voteURL + "\",url=\"http://" + voteURL + "\"]";
}
return "[Text=\"" + voteURL + "\",url=\"" + voteURL + "\"]";
}
public String getVoteURLJsonStrip() {
String url = ChatColor.stripColor(StringParser.getInstance()
.colorize(StringParser.getInstance().parseJson(getVoteURL(false)).toPlainText()));
String url = ChatColor
.stripColor(MessageAPI.colorize(PlaceholderUtils.parseJson(getVoteURL(false)).toPlainText()));
if (!url.startsWith("http")) {
if (!url.startsWith("www.")) {
url = "https://www." + url;
@@ -198,15 +200,16 @@ public class VoteSite {
}
public void giveRewards(VotingPluginUser user, boolean online, boolean bungee) {
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getEverySiteRewardPath())
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getRewardsPath(key))
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getEverySiteRewardPath())
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
}
public boolean hasRewards() {
@@ -235,10 +238,11 @@ public class VoteSite {
voteDelayDailyHour = plugin.getConfigVoteSites().getVoteDelayDailyHour(key);
hidden = plugin.getConfigVoteSites().getVoteSiteHidden(key);
ignoreCanVote = plugin.getConfigVoteSites().getVoteSiteIgnoreCanVote(key);
permissionToView = plugin.getConfigVoteSites().getPermissionToView(key);
}
public boolean isVaidServiceSite() {
return ArrayUtils.getInstance().containsIgnoreCase(plugin.getServerData().getServiceSites(), getServiceSite());
return ArrayUtils.containsIgnoreCase(plugin.getServerData().getServiceSites(), getServiceSite());
}
public String loadingDebug() {
@@ -44,7 +44,8 @@ public class MVdWPlaceholders {
.getVotingPluginUser(event.getOfflinePlayer());
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()
&& user.hasPrimaryAccount()) {
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(user.getPrimaryAccount());
}
return place.placeholderRequest(user,
event.getPlaceholder().substring("VotingPlugin_".length()));
@@ -55,7 +56,8 @@ public class MVdWPlaceholders {
}
for (final NonPlayerPlaceHolder<VotingPluginUser> place : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
for (final NonPlayerPlaceHolder<VotingPluginUser> place : plugin.getPlaceholders()
.getNonPlayerPlaceholders()) {
String str = place.getIdentifier();
if (!str.endsWith("_")) {
PlaceholderAPI.registerPlaceholder(VotingPluginMain.plugin, "VotingPlugin_" + str,
@@ -19,12 +19,13 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
import com.bencodez.advancedcore.api.placeholder.CalculatingPlaceholder;
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
import com.bencodez.advancedcore.api.user.UserDataChanged;
import com.bencodez.simpleapi.messages.MessageAPI;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -40,35 +41,52 @@ import lombok.Getter;
public class PlaceHolders {
@Getter
private ArrayList<NonPlayerPlaceHolder<VotingPluginUser>> nonPlayerPlaceholders = new ArrayList<NonPlayerPlaceHolder<VotingPluginUser>>();
private ArrayList<NonPlayerPlaceHolder<VotingPluginUser>> nonPlayerPlaceholders = new ArrayList<>();
@Getter
private ArrayList<PlaceHolder<VotingPluginUser>> placeholders = new ArrayList<PlaceHolder<VotingPluginUser>>();
private ArrayList<PlaceHolder<VotingPluginUser>> placeholders = new ArrayList<>();
private VotingPluginMain plugin;
private ArrayList<String> cachedPlaceholders = new ArrayList<>();
private ConcurrentLinkedQueue<String> placeholdersToSetCacheOn = new ConcurrentLinkedQueue<>();
@Getter
private PlaceholderCacheLevel cacheLevel;
public PlaceHolders(VotingPluginMain plugin) {
this.plugin = plugin;
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
}
public void reload() {
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
onUpdate();
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
for (Player player : Bukkit.getOnlinePlayers()) {
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(player), player.isOnline());
public void checkNonCachedPlaceholders() {
while (!placeholdersToSetCacheOn.isEmpty()) {
String toCache = placeholdersToSetCacheOn.poll().toLowerCase();
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 (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.matches(toCache)) {
placeholder.setUseCache(true, toCache);
cachedPlaceholders.add(toCache);
plugin.getServerData().addAutoCachedPlaceholder(toCache);
plugin.extraDebug("Auto Caching placeholder " + toCache);
}
}
}
}
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
private ConcurrentLinkedQueue<String> placeholdersToSetCacheOn = new ConcurrentLinkedQueue<String>();
@Getter
private PlaceholderCacheLevel cacheLevel;
public String getPlaceHolder(OfflinePlayer p, String identifier) {
return getPlaceHolder(p, identifier, true);
}
@@ -95,26 +113,32 @@ public class PlaceHolders {
identifier = identifier.replaceAll("custom_", "");
}
if (custom && plugin.getConfigFile().getCustomPlaceholderReturns().contains(identifier)) {
String str = getPlaceholderValue(p, identifier, javascript, true, useCache);
String returnStr = plugin.getConfigFile().getCustomPlaceholderReturns(identifier, str);
if (!returnStr.isEmpty()) {
return returnStr;
}
return str;
} else {
if (!custom || !plugin.getConfigFile().getCustomPlaceholderReturns().contains(identifier)) {
return getPlaceholderValue(p, identifier, javascript, forceProcess, useCache);
}
String str = getPlaceholderValue(p, identifier, javascript, true, useCache);
String returnStr = plugin.getConfigFile().getCustomPlaceholderReturns(identifier, str);
if (!returnStr.isEmpty()) {
return returnStr;
}
return str;
}
public String getPlaceHolder(Player p, String identifier) {
if (plugin.getConfigFile().isUseJavascriptPlaceholders()) {
identifier = PlaceholderUtils.replaceJavascript(p, identifier);
}
return getPlaceHolder(p, identifier, false);
}
public String getPlaceholderValue(OfflinePlayer p, String identifier, boolean javascript, boolean forceProcess,
boolean useCache) {
if (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript && p != null) {
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
identifier = PlaceholderUtils.replaceJavascript(p, identifier);
}
if (!identifier.endsWith("Position")) {
if (!identifier.toLowerCase().endsWith("position")) {
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
if (placeholder.matches(identifier)) {
String str = placeholder.placeholderRequest(identifier);
@@ -156,81 +180,81 @@ public class PlaceHolders {
}
}
UUID uuid = user.getJavaUUID();
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
try {
if (placeholder.matches(identifier)) {
if (placeholder instanceof CalculatingPlaceholder<?>) {
if (useCache) {
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
if (cache.containsKey(p.getUniqueId())) {
if (cPlaceholder.getCacheData().containsKey(user.getJavaUUID())) {
return cPlaceholder.placeholderRequest(user, identifier);
}
return cache.get(p.getUniqueId());
} else if (!forceProcess) {
schedulePlaceholderCheck(user);
return "...";
}
}
if (forceProcess) {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return placeholder.placeholderRequest(user, identifier);
} else {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return ".";
}
} else {
if (!useCache) {
return placeholder.placeholderRequest(user, identifier);
}
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
if (cache.containsKey(uuid)) {
if (cPlaceholder.getCacheData().containsKey(uuid)) {
return cPlaceholder.placeholderRequest(user, identifier);
}
return cache.get(uuid);
} else if (!forceProcess) {
schedulePlaceholderCheck(user);
return "...";
}
}
if (forceProcess) {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return placeholder.placeholderRequest(user, identifier);
} else {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return ".";
}
}
if (!useCache) {
return placeholder.placeholderRequest(user, identifier);
}
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
if (cache.containsKey(uuid)) {
return cache.get(uuid);
} else if (!forceProcess) {
schedulePlaceholderCheck(user);
return "...";
}
}
if (forceProcess) {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return placeholder.placeholderRequest(user, identifier);
} else {
if (useCache) {
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
if (cache.containsKey(p.getUniqueId())) {
return cache.get(p.getUniqueId());
} else if (!forceProcess) {
schedulePlaceholderCheck(user);
return "...";
}
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
if (forceProcess) {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return placeholder.placeholderRequest(user, identifier);
} else {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return ".";
}
} else {
return placeholder.placeholderRequest(user, identifier);
}
return ".";
}
}
} catch (Exception e) {
@@ -242,13 +266,6 @@ public class PlaceHolders {
return "Not a valid placeholder";
}
public String getPlaceHolder(Player p, String identifier) {
if (plugin.getConfigFile().isUseJavascriptPlaceholders()) {
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
}
return getPlaceHolder(p, identifier, false);
}
public void load() {
placeholders.clear();
nonPlayerPlaceholders.clear();
@@ -312,7 +329,7 @@ public class PlaceHolders {
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
for (String vote : mVotes) {
if (StringParser.getInstance().isInt(vote)) {
if (MessageAPI.isInt(vote)) {
final int num = Integer.parseInt(vote);
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
@@ -351,8 +368,20 @@ public class PlaceHolders {
}
}.withDescription("Get number of votes until next available milestone").updateDataKey("MilestoneCount"));
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
if (plugin.getGui().getChestShopIdentifierLimit(identifier) > 0) {
placeholders.add(new PlaceHolder<VotingPluginUser>("lastmilestone_votes_since") {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
int toGo = user.getMilestoneCount() - user.getLastGottenMilestone();
if (toGo >= 0) {
return "" + toGo;
}
return "0";
}
}.withDescription("Get number of votes since last milestone").updateDataKey("MilestoneCount"));
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
if (plugin.getShopFile().getShopIdentifierLimit(identifier) > 0) {
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
@Override
@@ -486,7 +515,7 @@ public class PlaceHolders {
return plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
}
long smallest = -1;
HashMap<Long, VoteSite> times = new HashMap<Long, VoteSite>();
HashMap<Long, VoteSite> times = new HashMap<>();
for (VoteSite site : plugin.getVoteSitesEnabled()) {
long t = user.voteNextDurationTime(site);
if (smallest == -1) {
@@ -515,9 +544,23 @@ public class PlaceHolders {
}
}.withDescription("Get number of sites available to be voted on").updateDataKey("LastVotes"));
placeholders.add(new PlaceHolder<VotingPluginUser>("SitesAvailableTotal") {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
return "" + user.getTotalNumberOfSites();
}
}.withDescription("Get total number of sites available to be voted on"));
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
placeholders.add(new CalculatingPlaceholder<VotingPluginUser>("Next_" + voteSite.getKey()) {
@Override
public String placeholderDataRequest(VotingPluginUser user, String identifier) {
long time = user.getTime(voteSite);
return "" + time;
}
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
if (getCacheData().containsKey(user.getJavaUUID())) {
@@ -529,12 +572,6 @@ public class PlaceHolders {
}
return user.voteCommandNextInfo(voteSite);
}
@Override
public String placeholderDataRequest(VotingPluginUser user, String identifier) {
long time = user.getTime(voteSite);
return "" + time;
}
}.withDescription("How long until user can vote on " + voteSite.getKey()).updateDataKey("LastVotes"));
placeholders.add(new PlaceHolder<VotingPluginUser>("Last_" + voteSite.getKey()) {
@@ -572,6 +609,9 @@ public class PlaceHolders {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
if (!MessageAPI.isInt(identifier.split("_")[1])) {
return "invalid";
}
int number = Integer.parseInt(identifier.split("_")[1]);
if (user.getPoints() >= number) {
return "true";
@@ -600,8 +640,8 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
return null;
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -613,7 +653,7 @@ public class PlaceHolders {
}
return "";
}
}.useStartsWith().withDescription("Get user at postion in top voter"));
}.useStartsWith().withDescription("Get username at postion in top voter"));
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Month_Position") {
@@ -629,7 +669,7 @@ public class PlaceHolders {
}
return "";
}
}.withDescription("Get user top voter position"));
}.withDescription("Get user's current top voter position"));
if (plugin.getGui().isLastMonthGUI()) {
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_LastMonth_Position") {
@@ -651,8 +691,8 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
return null;
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -688,8 +728,8 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
return null;
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -701,7 +741,7 @@ public class PlaceHolders {
}
return "";
}
}.useStartsWith().withDescription("Get user at position in top voter"));
}.useStartsWith().withDescription("Get username at position in top voter"));
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_MonthVotes_") {
@@ -739,8 +779,8 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
return null;
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -752,7 +792,7 @@ public class PlaceHolders {
}
return "";
}
}.useStartsWith().withDescription("Get user at postion in top voter"));
}.useStartsWith().withDescription("Get username at postion in top voter"));
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_WeekVotes_") {
@@ -790,8 +830,8 @@ public class PlaceHolders {
@Override
public String placeholderRequest(String identifier) {
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
return null;
if (!MessageAPI.isInt(identifier.split("_")[2])) {
return "invalid";
}
int num = 1;
int number = Integer.parseInt(identifier.split("_")[2]);
@@ -803,7 +843,7 @@ public class PlaceHolders {
}
return "";
}
}.useStartsWith().withDescription("Get user at postion in top voter"));
}.useStartsWith().withDescription("Get username at postion in top voter"));
placeholders.add(new PlaceHolder<VotingPluginUser>("VotePartyContributedVotes") {
@@ -967,9 +1007,8 @@ public class PlaceHolders {
diffMinutes = diffMinutes * -1;
}
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
Long.toString(diffMinutes));
timeMsg = MessageAPI.replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
timeMsg = MessageAPI.replaceIgnoreCase(timeMsg, "%minutes%", Long.toString(diffMinutes));
return timeMsg;
}
@@ -1008,10 +1047,9 @@ public class PlaceHolders {
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));
timeMsg = MessageAPI.replaceIgnoreCase(timeMsg, "%days%", Integer.toString(diffDays));
timeMsg = MessageAPI.replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
timeMsg = MessageAPI.replaceIgnoreCase(timeMsg, "%minutes%", Long.toString(diffMinutes));
return timeMsg;
}
@@ -1042,16 +1080,15 @@ public class PlaceHolders {
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));
timeMsg = MessageAPI.replaceIgnoreCase(timeMsg, "%days%", Integer.toString(diffDays));
timeMsg = MessageAPI.replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
timeMsg = MessageAPI.replaceIgnoreCase(timeMsg, "%minutes%", Long.toString(diffMinutes));
return timeMsg;
}
}.withDescription("Time until plugin time month changes"));
Set<String> placeholdersSet = new HashSet<String>();
Set<String> placeholdersSet = new HashSet<>();
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
if (getCacheLevel().equals(PlaceholderCacheLevel.AUTO)) {
placeholdersSet.addAll(plugin.getServerData().getAutoCachedPlaceholder());
@@ -1129,16 +1166,6 @@ 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)); } } } }
*/
}
public void onBungeeVotePartyUpdate() {
/*
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
@@ -1159,6 +1186,22 @@ public class PlaceHolders {
}
}
public void onUpdate() {
checkNonCachedPlaceholders();
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()); } } } }
*/
}
public void onUpdate(VotingPluginUser user, boolean login) {
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.isUsesCache()) {
@@ -1188,30 +1231,23 @@ public class PlaceHolders {
}
}
public void checkNonCachedPlaceholders() {
while (!placeholdersToSetCacheOn.isEmpty()) {
String toCache = placeholdersToSetCacheOn.poll().toLowerCase();
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 (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.matches(toCache)) {
placeholder.setUseCache(true, toCache);
cachedPlaceholders.add(toCache);
plugin.getServerData().addAutoCachedPlaceholder(toCache);
plugin.extraDebug("Auto Caching placeholder " + toCache);
}
}
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)); } } } }
*/
}
public void reload() {
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
onUpdate();
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
for (Player player : Bukkit.getOnlinePlayers()) {
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(player), player.isOnline());
}
}
}
@@ -1225,20 +1261,4 @@ public class PlaceHolders {
}
});
}
public void onUpdate() {
checkNonCachedPlaceholders();
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()); } } } }
*/
}
}
@@ -13,10 +13,7 @@ public enum PlaceholderCacheLevel {
}
public boolean onlineOnly() {
if (this == AUTOALL) {
return false;
}
if (this == SPECIFICALL) {
if ((this == AUTOALL) || (this == SPECIFICALL)) {
return false;
}
return true;
@@ -29,13 +29,13 @@ public class VotingPluginExpansion extends PlaceholderExpansion {
return "1.6";
}
@Override
public boolean persist() {
return true;
}
@Override
public String onRequest(OfflinePlayer p, String indendifier) {
return plugin.getPlaceholders().getPlaceHolder(p, indendifier);
}
@Override
public boolean persist() {
return true;
}
}
@@ -1,4 +1,4 @@
package com.bencodez.votingplugin.bungee;
package com.bencodez.votingplugin.proxy;
import java.util.regex.Pattern;
@@ -8,7 +8,7 @@ import lombok.Setter;
public class BungeeMessageData {
// Message string
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired//datemonthtotal
@Getter
@Setter
@@ -24,6 +24,9 @@ public class BungeeMessageData {
private int monthTotal = 0;
@Getter
@Setter
private int dateMonthTotal = 0;
@Getter
@Setter
private int points = 0;
@Getter
@Setter
@@ -36,7 +39,7 @@ public class BungeeMessageData {
private int votePartyRequired = 0;
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
int milestoneCount, int votePartyCurrent, int votePartyRequired) {
int milestoneCount, int votePartyCurrent, int votePartyRequired, int dateMonthTotal) {
this.allTimeTotal = allTimeTotal;
this.monthTotal = monthTotal;
this.weeklyTotal = weeklyTotal;
@@ -45,6 +48,7 @@ public class BungeeMessageData {
this.milestoneCount = milestoneCount;
this.votePartyCurrent = votePartyCurrent;
this.votePartyRequired = votePartyRequired;
this.dateMonthTotal = dateMonthTotal;
}
public BungeeMessageData(String str) {
@@ -61,6 +65,9 @@ public class BungeeMessageData {
votePartyCurrent = Integer.parseInt(data[6]);
votePartyRequired = Integer.parseInt(data[7]);
}
if (data.length >= 9) {
dateMonthTotal = Integer.parseInt(data[8]);
}
}
@Override
@@ -1,7 +1,11 @@
package com.bencodez.votingplugin.bungee;
package com.bencodez.votingplugin.proxy;
public enum BungeeMethod {
MYSQL, PLUGINMESSAGING, SOCKETS, REDIS;
MYSQL, PLUGINMESSAGING, SOCKETS, REDIS, MQTT;
public boolean requiresPlayerOnline() {
return this == MYSQL || this == PLUGINMESSAGING;
}
public static BungeeMethod getByName(String str) {
for (BungeeMethod method : values()) {
@@ -1,4 +1,4 @@
package com.bencodez.votingplugin.bungee;
package com.bencodez.votingplugin.proxy;
public class BungeeVersion {
public static int getPluginMessageVersion() {
@@ -1,4 +1,4 @@
package com.bencodez.votingplugin.bungee;
package com.bencodez.votingplugin.proxy;
import lombok.Getter;
@@ -0,0 +1,549 @@
package com.bencodez.votingplugin.proxy;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.bencodez.simpleapi.sql.Column;
import com.bencodez.simpleapi.sql.DataType;
import com.bencodez.simpleapi.sql.data.DataValue;
import com.bencodez.simpleapi.sql.data.DataValueInt;
import com.bencodez.simpleapi.sql.data.DataValueString;
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfig;
import com.bencodez.simpleapi.sql.mysql.queries.Query;
import lombok.Getter;
public abstract class ProxyMysqlUserTable {
private List<String> columns = Collections.synchronizedList(new ArrayList<String>());
private List<String> intColumns = new ArrayList<>();
// private HashMap<String, ArrayList<Column>> table;
// ConcurrentMap<String, ArrayList<Column>> table = new
// ConcurrentHashMap<String, ArrayList<Column>>();
@Getter
private com.bencodez.simpleapi.sql.mysql.MySQL mysql;
private String name;
private Object object2 = new Object();
private Object object3 = new Object();
private Object object4 = new Object();
private Set<String> uuids = Collections.synchronizedSet(new HashSet<String>());
public abstract void logSevere(String string);
public abstract void logInfo(String string);
public ProxyMysqlUserTable(String tableName, MysqlConfig config, boolean debug) {
if (config.hasTableNameSet()) {
tableName = config.getTableName();
}
name = tableName;
if (config.getTablePrefix() != null) {
name = config.getTablePrefix() + tableName;
}
mysql = new com.bencodez.simpleapi.sql.mysql.MySQL(config.getMaxThreads()) {
@Override
public void debug(SQLException e) {
if (debug) {
e.printStackTrace();
}
}
@Override
public void severe(String string) {
logSevere(string);
}
@Override
public void debug(String msg) {
if (debug) {
logInfo("MYSQL DEBUG: " + msg);
}
}
};
if (!mysql.connect(config)) {
}
try {
Query q = new Query(mysql, "USE `" + config.getDatabase() + "`;");
q.executeUpdateAsync();
} catch (SQLException e) {
severe("Failed to send use database query: " + config.getDatabase() + " Error: " + e.getMessage());
debug(e);
}
String sql = "CREATE TABLE IF NOT EXISTS " + getName() + " (";
sql += "uuid VARCHAR(37),";
sql += "PRIMARY KEY ( uuid )";
sql += ");";
Query query;
try {
query = new Query(mysql, sql);
query.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
loadData();
// tempoary to improve performance from old tables
// addToQue("ALTER TABLE " + getName() + " MODIFY uuid VARCHAR(37);");
alterColumnType("uuid", "VARCHAR(37)");
}
public void addColumn(String column, DataType dataType) {
synchronized (object3) {
String sql = "ALTER TABLE " + getName() + " ADD COLUMN `" + column + "` text" + ";";
try {
Query query = new Query(mysql, sql);
query.executeUpdate();
getColumns().add(column);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public void alterColumnType(String column, String newType) {
checkColumn(column, DataType.STRING);
try {
new Query(mysql, "ALTER TABLE " + getName() + " MODIFY `" + column + "` " + newType + ";")
.executeUpdateAsync();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (newType.contains("INT")) {
if (!intColumns.contains(column)) {
intColumns.add(column);
}
}
}
public void checkColumn(String column, DataType dataType) {
synchronized (object4) {
if (!getColumns().contains(column)) {
if (!getColumnsQueury().contains(column)) {
addColumn(column, dataType);
}
}
}
}
public void clearCache() {
clearCacheBasic();
}
public void clearCacheBasic() {
columns.clear();
columns.addAll(getColumnsQueury());
uuids.clear();
uuids.addAll(getUuidsQuery());
}
public void close() {
mysql.disconnect();
}
public boolean containsKeyQuery(String index) {
String sqlStr = "SELECT uuid FROM " + getName() + ";";
try (Connection conn = mysql.getConnectionManager().getConnection();
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
ResultSet rs = sql.executeQuery();
/*
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
*/
while (rs.next()) {
if (rs.getString("uuid").equals(index)) {
rs.close();
return true;
}
}
rs.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
return false;
}
public void copyColumnData(String columnFromName, String columnToName) {
checkColumn(columnFromName, DataType.STRING);
checkColumn(columnToName, DataType.STRING);
String sql = "UPDATE `" + getName() + "` SET `" + columnToName + "` = `" + columnFromName + "`;";
try {
Query query = new Query(mysql, sql);
query.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
public abstract void debug(SQLException e);
public List<String> getColumns() {
if (columns == null || columns.size() == 0) {
loadData();
}
return columns;
}
public ArrayList<String> getColumnsQueury() {
ArrayList<String> columns = new ArrayList<>();
try (Connection conn = mysql.getConnectionManager().getConnection();
PreparedStatement sql = conn.prepareStatement("SHOW COLUMNS FROM `" + getName() + "`;")) {
ResultSet rs = sql.executeQuery();
while (rs.next()) {
String columnName = rs.getString(1);
columns.add(columnName);
}
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
return columns;
}
public ArrayList<Column> getExactQuery(Column column) {
ArrayList<Column> result = new ArrayList<>();
String query = "SELECT * FROM " + getName() + " WHERE `" + column.getName() + "`='"
+ column.getValue().getString() + "';";
try (Connection conn = mysql.getConnectionManager().getConnection();
PreparedStatement sql = conn.prepareStatement(query)) {
ResultSet rs = sql.executeQuery();
/*
* Query sql = new Query(mysql, query); sql.setParameter(1,
* column.getValue().toString()); ResultSet rs = sql.executeQuery();
*/
if (rs.next()) {
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
String columnName = rs.getMetaData().getColumnLabel(i);
Column rCol = null;
if (intColumns.contains(columnName)) {
rCol = new Column(columnName, DataType.INTEGER);
rCol.setValue(new DataValueInt(rs.getInt(i)));
} else {
rCol = new Column(columnName, DataType.STRING);
rCol.setValue(new DataValueString(rs.getString(i)));
}
result.add(rCol);
}
}
rs.close();
return result;
} catch (SQLException e) {
e.printStackTrace();
} catch (ArrayIndexOutOfBoundsException e) {
}
for (String col : getColumns()) {
result.add(new Column(col, DataType.STRING));
}
return result;
}
public String getName() {
return name;
}
public ArrayList<String> getNamesQuery() {
ArrayList<String> uuids = new ArrayList<>();
checkColumn("PlayerName", DataType.STRING);
ArrayList<Column> rows = getRowsNameQuery();
if (rows != null) {
for (Column c : rows) {
if (c.getValue().isString()) {
uuids.add(c.getValue().getString());
}
}
}
return uuids;
}
public ArrayList<Column> getRowsNameQuery() {
ArrayList<Column> result = new ArrayList<>();
String sqlStr = "SELECT PlayerName FROM " + getName() + ";";
try (Connection conn = mysql.getConnectionManager().getConnection();
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
ResultSet rs = sql.executeQuery();
/*
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
*/
while (rs.next()) {
Column rCol = new Column("PlayerName", new DataValueString(rs.getString("PlayerName")));
result.add(rCol);
}
sql.close();
conn.close();
} catch (SQLException e) {
}
return result;
}
public ArrayList<Column> getRowsQuery() {
ArrayList<Column> result = new ArrayList<>();
String sqlStr = "SELECT uuid FROM " + getName() + ";";
try (Connection conn = mysql.getConnectionManager().getConnection();
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
ResultSet rs = sql.executeQuery();
/*
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
*/
while (rs.next()) {
Column rCol = new Column("uuid", new DataValueString(rs.getString("uuid")));
result.add(rCol);
}
rs.close();
} catch (SQLException e) {
return null;
}
return result;
}
public ConcurrentHashMap<UUID, String> getRowsUUIDNameQuery() {
ConcurrentHashMap<UUID, String> uuidNames = new ConcurrentHashMap<>();
String sqlStr = "SELECT UUID, PlayerName FROM " + getName() + ";";
try (Connection conn = mysql.getConnectionManager().getConnection();
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
ResultSet rs = sql.executeQuery();
/*
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
*/
while (rs.next()) {
String uuid = rs.getString("uuid");
String playerName = rs.getString("PlayerName");
if (uuid != null && !uuid.isEmpty() && !uuid.equals("null") && playerName != null) {
uuidNames.put(UUID.fromString(uuid), playerName);
}
}
sql.close();
conn.close();
} catch (SQLException e) {
}
return uuidNames;
}
public String getUUID(String playerName) {
String query = "SELECT uuid FROM " + getName() + " WHERE " + "PlayerName" + "='" + playerName + "';";
try (Connection conn = mysql.getConnectionManager().getConnection();
PreparedStatement sql = conn.prepareStatement(query)) {
ResultSet rs = sql.executeQuery();
/*
* Query sql = new Query(mysql, query); ResultSet rs = sql.executeQuery();
*/
if (rs.next()) {
String uuid = rs.getString("uuid");
if (uuid != null && !uuid.isEmpty()) {
rs.close();
return uuid;
}
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
} catch (ArrayIndexOutOfBoundsException e) {
}
return null;
}
public Set<String> getUuids() {
if (uuids == null || uuids.size() == 0) {
uuids.clear();
uuids.addAll(getUuidsQuery());
return uuids;
}
return uuids;
}
public ArrayList<String> getUuidsQuery() {
ArrayList<String> uuids = new ArrayList<>();
ArrayList<Column> rows = getRowsQuery();
for (Column c : rows) {
if (c.getValue().isString()) {
uuids.add(c.getValue().getString());
}
}
return uuids;
}
public void insert(String index, String column, DataValue value) {
insertQuery(index, Arrays.asList(new Column(column, value)));
}
public void insertQuery(String index, List<Column> cols) {
String query = "INSERT IGNORE " + getName() + " ";
query += "set uuid='" + index + "', ";
for (int i = 0; i < cols.size(); i++) {
Column col = cols.get(i);
if (i == cols.size() - 1) {
if (col.getValue().isString()) {
query += "`" + col.getName() + "`='" + col.getValue().getString() + "';";
} else if (col.getValue().isBoolean()) {
query += "`" + col.getName() + "`='" + col.getValue().getBoolean() + "';";
} else if (col.getValue().isInt()) {
query += "`" + col.getName() + "`='" + col.getValue().getInt() + "';";
}
} else {
if (col.getValue().isString()) {
query += "`" + col.getName() + "`='" + col.getValue().getString() + "', ";
} else if (col.getValue().isBoolean()) {
query += "`" + col.getName() + "`='" + col.getValue().getBoolean() + "', ";
} else if (col.getValue().isInt()) {
query += "`" + col.getName() + "`='" + col.getValue().getInt() + "', ";
}
}
}
try {
uuids.add(index);
new Query(mysql, query).executeUpdateAsync();
} catch (SQLException e) {
e.printStackTrace();
}
}
public boolean isIntColumn(String key) {
return intColumns.contains(key);
}
public void loadData() {
columns = getColumnsQueury();
}
public abstract void severe(String str);
public void shutdown() {
mysql.disconnect();
}
public void update(String index, List<Column> cols) {
for (Column col : cols) {
checkColumn(col.getName(), col.getDataType());
}
if (getUuids().contains(index)) {
synchronized (object2) {
String query = "UPDATE " + getName() + " SET ";
for (int i = 0; i < cols.size(); i++) {
Column col = cols.get(i);
if (i == cols.size() - 1) {
if (col.getValue().isString()) {
query += "`" + col.getName() + "`='" + col.getValue().getString() + "'";
} else if (col.getValue().isBoolean()) {
query += "`" + col.getName() + "`='" + col.getValue().getBoolean() + "'";
} else if (col.getValue().isInt()) {
query += "`" + col.getName() + "`='" + col.getValue().getInt() + "'";
}
} else {
if (col.getValue().isString()) {
query += "`" + col.getName() + "`='" + col.getValue().getString() + "', ";
} else if (col.getValue().isBoolean()) {
query += "`" + col.getName() + "`='" + col.getValue().getBoolean() + "', ";
} else if (col.getValue().isInt()) {
query += "`" + col.getName() + "`='" + col.getValue().getInt() + "', ";
}
}
}
query += " WHERE `uuid`=";
query += "'" + index + "';";
try {
Query q = new Query(mysql, query);
q.executeUpdateAsync();
} catch (SQLException e) {
e.printStackTrace();
}
}
} else {
insertQuery(index, cols);
}
}
public void update(String index, String column, DataValue value) {
checkColumn(column, value.getType());
if (getUuids().contains(index)) {
synchronized (object2) {
String query = "UPDATE " + getName() + " SET ";
if (value.isString()) {
query += column + "='" + value.getString() + "'";
} else if (value.isBoolean()) {
query += column + "='" + value.getBoolean() + "'";
} else if (value.isInt()) {
query += column + "='" + value.getInt() + "'";
}
query += " WHERE `uuid`=";
query += "'" + index + "';";
try {
Query q = new Query(mysql, query);
q.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
} else {
insert(index, column, value);
}
}
public void wipeColumnData(String columnName, DataType dataType) {
checkColumn(columnName, dataType);
String sql = "UPDATE " + getName() + " SET " + columnName + " = " + dataType.getNoValue() + ";";
try {
Query query = new Query(mysql, sql);
query.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,120 @@
package com.bencodez.votingplugin.proxy;
import com.bencodez.advancedcore.api.time.TimeType;
public class VotingPluginProxyCommand {
private VotingPluginProxy plugin;
public VotingPluginProxyCommand(VotingPluginProxy plugin) {
this.plugin = plugin;
}
/**
* Execute the command and return a message as a String.
*
* @param args Command arguments
* @return The resulting message to send
*/
public String execute(String[] args) {
if (args.length == 0)
return "&cPlease provide a valid command. Use 'help' to view all commands.";
switch (args[0].toLowerCase()) {
case "reload":
plugin.reloadCore(false);
return "&aReloading VotingPlugin";
case "reloadmysql":
plugin.reloadCore(true);
return "&aReloading VotingPlugin including MySQL";
case "vote":
if (args.length >= 3) {
String user = args[1];
String site = args[2];
plugin.vote(user, site, false, true, 0, null, null);
return "&aVote sent for " + user + " on " + site;
}
return "&cUsage: vote <player> <site>";
case "forcetimechange":
if (args.length >= 2) {
plugin.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
return "&aTriggered time change to " + args[1];
}
return "&cUsage: forcetimechange <TimeType>";
case "status":
return handleStatusCommand();
case "multiproxystatus":
plugin.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
return "&aSent status message across multi-proxy";
case "help":
return getHelpMessage();
case "voteparty":
return handleVotePartyCommand(args);
default:
return "&cUnknown command. Use 'help' to view all commands.";
}
}
private String handleStatusCommand() {
BungeeMethod method = plugin.getMethod();
switch (method) {
case SOCKETS:
plugin.status();
return "&aChecking status via sockets. Check console for details.";
case PLUGINMESSAGING:
case REDIS:
plugin.status();
plugin.sendServerNameMessage();
return "&aChecking status with method: " + method.toString().toLowerCase();
default:
return "&cStatus command unavailable for the current connection method.";
}
}
private String handleVotePartyCommand(String[] args) {
if (args.length > 1) {
if ("force".equalsIgnoreCase(args[1])) {
plugin.setCurrentVotePartyVotes(plugin.getCurrentVotePartyVotesRequired());
plugin.checkVoteParty();
return "&aVote party forced";
} else if ("setvotecount".equalsIgnoreCase(args[1]) && args.length > 2 && isInt(args[2])) {
plugin.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
return "&aSet current vote party votes to " + args[2];
} else {
return "&cInvalid usage. Use 'help' for correct syntax.";
}
}
return "&cUsage: voteparty <force/setvotecount>";
}
private String getHelpMessage() {
StringBuilder helpBuilder = new StringBuilder("&aVotingPlugin Commands:\n");
helpBuilder.append("/votingplugin reload - Reload the plugin\n");
helpBuilder.append("/votingplugin reloadmysql - Reload the plugin including MySQL\n");
helpBuilder.append("/votingplugin vote <player> <site> - Send a vote\n");
helpBuilder.append("/votingplugin forcetimechange <TimeType> - Force a time change\n");
helpBuilder.append("/votingplugin status - Check connection status\n");
helpBuilder.append("/votingplugin multiproxystatus - Send status message across proxies\n");
helpBuilder.append("/votingplugin voteparty <force/setvotecount> - Trigger or modify vote party\n");
return helpBuilder.toString();
}
private boolean isInt(String str) {
try {
Integer.parseInt(str);
return true;
} catch (NumberFormatException e) {
return false;
}
}
}
@@ -0,0 +1,149 @@
package com.bencodez.votingplugin.proxy;
import java.util.Collection;
import java.util.List;
import java.util.Map;
public interface VotingPluginProxyConfig {
public boolean getAllowUnJoined();
public String getBedrockPlayerPrefix();
public List<String> getBlockedServers();
public boolean getBroadcast();
public String getBungeeHost();
public boolean getBungeeManageTotals();
public String getBungeeMethod();
public int getBungeePort();
public String getPluginMessageChannel();
public boolean getPluginMessageEncryption();
public boolean getDebug();
public String getMqttClientID();
public String getMqttBrokerURL();
public String getMqttUsername();
public String getMqttPassword();
public String getMqttPrefix();
public String getFallBack();
public boolean getGlobalDataEnabled();
public boolean getGlobalDataUseMainMySQL();
public int getLimitVotePoints();
public int getMaxAmountOfVotesPerDay();
public String getMultiProxyMethod();
public boolean getMultiProxyOneGlobalReward();
public String getMultiProxyRedisHost();
public String getMultiProxyRedisPassword();
public int getMultiProxyRedisPort();
public boolean getMultiProxyRedisUseExistingConnection();
public String getMultiProxyRedisUsername();
public Collection<String> getMultiProxyServers();
public Map<String, Object> getMultiProxyServersConfiguration(String s);
public String getMultiProxySocketHostHost();
public int getMultiProxySocketHostPort();
public boolean getMultiProxySupport();
public boolean getOnlineMode();
public int getPointsOnVote();
public boolean getPrimaryServer();
public String getProxyServerName();
public List<String> getProxyServers();
public String getRedisHost();
public String getRedisPassword();
public int getRedisPort();
public String getRedisPrefix();
public String getRedisUsername();
public boolean getSendVotesToAllServers();
public Map<String, Object> getSpigotServerConfiguration(String s);
public Collection<String> getSpigotServers();
public boolean getStoreMonthTotalsWithDate();
public boolean getTimeChangeFailSafeBypass();
public int getTimeHourOffSet();
public String getTimeZone();
public boolean getUseMonthDateTotalsAsPrimaryTotal();
public boolean getUUIDLookup();
public int getVoteCacheTime();
public String getVotePartyBroadcast();
public List<String> getVotePartyBungeeCommands();
public boolean getVotePartyEnabled();
public int getVotePartyIncreaseVotesRequired();
public boolean getVotePartySendToAllServers();
public List<String> getVotePartyServersToSend();
public int getVotePartyVotesRequired();
public boolean getWaitForUserOnline();
public List<String> getWhiteListedServers();
public Collection<String> getWaitUntilVoteDelaySites();
public String getWaitUntilVoteDelayService(String site);
public int getWaitUntilVoteDelayVoteDelay(String site);
public int getWaitUntilVoteDelayVoteDelayMin(String site);
public int getWaitUntilVoteDelayVoteDelayHour(String site);
public boolean getWaitUntilVoteDelayVoteDelayDaily(String site);
public void load();
public void save();
}
@@ -1,4 +1,4 @@
package com.bencodez.votingplugin.bungee;
package com.bencodez.votingplugin.proxy.bungee;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -1,18 +1,22 @@
package com.bencodez.votingplugin.bungee;
package com.bencodez.votingplugin.proxy.bungee;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
import lombok.Getter;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
public class Config {
public class Config implements VotingPluginProxyConfig {
private VotingPluginBungee bungee;
@Getter
private Configuration data;
@@ -21,196 +25,312 @@ 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 Map<String, Object> configToMap(Configuration config) {
Map<String, Object> map = new HashMap<>();
if (config != null) {
config.getKeys().forEach(key -> map.put(key, config.get(key)));
}
return map;
}
@Override
public boolean getAllowUnJoined() {
return getData().getBoolean("AllowUnJoined", false);
}
public List<String> getBlockedServers() {
return getData().getStringList("BlockedServers");
}
public List<String> getWhiteListedServers() {
return getData().getStringList("WhiteListedServers");
}
public boolean getBroadcast() {
return getData().getBoolean("Broadcast", false);
}
@Override
public String getBedrockPlayerPrefix() {
return getData().getString("BedrockPlayerPrefix", ".");
}
public boolean getOnlineMode() {
return getData().getBoolean("OnlineMode", true);
@Override
public List<String> getBlockedServers() {
return getData().getStringList("BlockedServers");
}
public boolean getGlobalDataEnabled() {
return getData().getBoolean("GlobalData.Enabled", false);
}
public boolean getGlobalDataUseMainMySQL() {
return getData().getBoolean("GlobalData.UseMainMySQL", true);
@Override
public boolean getBroadcast() {
return getData().getBoolean("Broadcast", false);
}
@Override
public String getBungeeHost() {
return getData().getString("BungeeServer.Host", "");
}
@Override
public boolean getBungeeManageTotals() {
return getData().getBoolean("BungeeManageTotals", true);
}
@Override
public String getBungeeMethod() {
return getData().getString("BungeeMethod", "SOCKETS");
}
@Override
public int getBungeePort() {
return getData().getInt("BungeeServer.Port", 1297);
}
@Override
public boolean getDebug() {
return getData().getBoolean("Debug", false);
}
public boolean getMultiProxySupport() {
return getData().getBoolean("MultiProxySupport", false);
}
public int getMaxAmountOfVotesPerDay() {
return getData().getInt("MaxAmountOfVotesPerDay", -1);
}
public int getMultiProxySocketHostPort() {
return getData().getInt("MultiProxySocketHost.Port", 1297);
}
public String getMultiProxySocketHostHost() {
return getData().getString("MultiProxySocketHost.Host", "");
}
public boolean getMultiProxyOneGlobalReward() {
return getData().getBoolean("MultiProxyOneGlobalReward", false);
}
public Configuration getMultiProxyServersConfiguration(String s) {
return getData().getSection("MultiProxyServers." + s);
}
public Collection<String> getMultiProxyServers() {
return getData().getSection("MultiProxyServers").getKeys();
}
public boolean getPrimaryServer() {
return getData().getBoolean("PrimaryServer", false);
}
@Override
public String getFallBack() {
return getData().getString("FallBackServer", "");
}
public int getPointsOnVote() {
return getData().getInt("PointsOnVote", 1);
@Override
public boolean getGlobalDataEnabled() {
return getData().getBoolean("GlobalData.Enabled", false);
}
public boolean getSendVotesToAllServers() {
return getData().getBoolean("SendVotesToAllServers");
@Override
public boolean getGlobalDataUseMainMySQL() {
return getData().getBoolean("GlobalData.UseMainMySQL", true);
}
public Configuration getSpigotServerConfiguration(String s) {
return getData().getSection("SpigotServers." + s);
@Override
public int getLimitVotePoints() {
return getData().getInt("LimitVotePoints", -1);
}
public Collection<String> getSpigotServers() {
return getData().getSection("SpigotServers").getKeys();
}
public boolean getWaitForUserOnline() {
return getData().getBoolean("WaitForUserOnline", false);
}
public boolean getVotePartyEnabled() {
return getData().getBoolean("VoteParty.Enabled", false);
}
public boolean getVotePartySendToAllServers() {
return getData().getBoolean("VoteParty.SendToAllServers", true);
}
public int getVotePartyVotesRequired() {
return getData().getInt("VoteParty.VotesRequired", 100);
}
public int getVotePartyIncreaseVotesRequired() {
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
}
public int getVoteCacheTime() {
return getData().getInt("VoteCacheTime", -1);
}
public String getVotePartyBroadcast() {
return getData().getString("VoteParty.Broadcast", "");
@Override
public int getMaxAmountOfVotesPerDay() {
return getData().getInt("MaxAmountOfVotesPerDay", -1);
}
@Override
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");
}
public List<String> getVotePartyBungeeCommands() {
return getData().getStringList("VoteParty.BungeeCommands");
@Override
public boolean getMultiProxyOneGlobalReward() {
return getData().getBoolean("MultiProxyOneGlobalReward", false);
}
@Override
public String getMultiProxyRedisHost() {
return getData().getString("MultiProxyRedis.Host", "");
}
@Override
public String getMultiProxyRedisPassword() {
return getData().getString("MultiProxyRedis.Password", "");
}
@Override
public int getMultiProxyRedisPort() {
return getData().getInt("MultiProxyRedis.Port", 6379);
}
@Override
public boolean getMultiProxyRedisUseExistingConnection() {
return getData().getBoolean("MultiProxyRedis.UseExistingConnection", false);
}
@Override
public String getMultiProxyRedisUsername() {
return getData().getString("MultiProxyRedis.Username", "");
}
public String getMultiProxyRedisPassword() {
return getData().getString("MultiProxyRedis.Password", "");
@Override
public Collection<String> getMultiProxyServers() {
return getData().getSection("MultiProxyServers").getKeys();
}
@Override
public Map<String, Object> getMultiProxyServersConfiguration(String s) {
return configToMap(getData().getSection("MultiProxyServers." + s));
}
@Override
public String getMultiProxySocketHostHost() {
return getData().getString("MultiProxySocketHost.Host", "");
}
@Override
public int getMultiProxySocketHostPort() {
return getData().getInt("MultiProxySocketHost.Port", 1297);
}
@Override
public boolean getMultiProxySupport() {
return getData().getBoolean("MultiProxySupport", false);
}
@Override
public boolean getOnlineMode() {
return getData().getBoolean("OnlineMode", true);
}
@Override
public int getPointsOnVote() {
return getData().getInt("PointsOnVote", 1);
}
@Override
public boolean getPrimaryServer() {
return getData().getBoolean("PrimaryServer", false);
}
@Override
public String getProxyServerName() {
return getData().getString("ProxyServerName", "SOCKET");
}
@Override
public List<String> getProxyServers() {
return getData().getStringList("ProxyServers");
}
@Override
public String getRedisHost() {
return getData().getString("Redis.Host", "");
}
@Override
public String getRedisPassword() {
return getData().getString("Redis.Password", "");
}
@Override
public int getRedisPort() {
return getData().getInt("Redis.Port", 6379);
}
@Override
public String getRedisPrefix() {
return getData().getString("Redis.Prefix", "");
}
@Override
public String getRedisUsername() {
return getData().getString("Redis.Username", "");
}
@Override
public boolean getSendVotesToAllServers() {
return getData().getBoolean("SendVotesToAllServers");
}
@Override
public Map<String, Object> getSpigotServerConfiguration(String s) {
return configToMap(getData().getSection("SpigotServers." + s));
}
@Override
public Collection<String> getSpigotServers() {
return getData().getSection("SpigotServers").getKeys();
}
@Override
public boolean getStoreMonthTotalsWithDate() {
return getData().getBoolean("StoreMonthTotalsWithDate", false);
}
@Override
public boolean getTimeChangeFailSafeBypass() {
return getData().getBoolean("TimeChangeFailSafeBypass", false);
}
@Override
public int getTimeHourOffSet() {
return getData().getInt("TimeHourOffSet");
}
@Override
public String getTimeZone() {
return getData().getString("TimeZone", "");
}
@Override
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
return getData().getBoolean("UseMonthDateTotalsAsPrimaryTotal", false);
}
@Override
public boolean getUUIDLookup() {
return getData().getBoolean("UUIDLookup", true);
}
@Override
public int getVoteCacheTime() {
return getData().getInt("VoteCacheTime", -1);
}
@Override
public String getVotePartyBroadcast() {
return getData().getString("VoteParty.Broadcast", "");
}
@Override
public List<String> getVotePartyBungeeCommands() {
return getData().getStringList("VoteParty.BungeeCommands");
}
@Override
public boolean getVotePartyEnabled() {
return getData().getBoolean("VoteParty.Enabled", false);
}
@Override
public int getVotePartyIncreaseVotesRequired() {
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
}
@Override
public boolean getVotePartySendToAllServers() {
return getData().getBoolean("VoteParty.SendToAllServers", true);
}
@Override
public List<String> getVotePartyServersToSend() {
return getData().getStringList("VoteParty.ServersToSend");
}
@Override
public int getVotePartyVotesRequired() {
return getData().getInt("VoteParty.VotesRequired", 100);
}
@Override
public boolean getWaitForUserOnline() {
return getData().getBoolean("WaitForUserOnline", false);
}
@Override
public List<String> getWhiteListedServers() {
return getData().getStringList("WhiteListedServers");
}
@Override
public String getMqttClientID() {
return getData().getString("MQTT.ClientID", "proxy");
}
@Override
public String getMqttBrokerURL() {
return getData().getString("MQTT.BrokerURL", "tcp://localhost:1883");
}
@Override
public String getMqttUsername() {
return getData().getString("MQTT.Username", "");
}
@Override
public String getMqttPassword() {
return getData().getString("MQTT.Password", "");
}
@Override
public String getMqttPrefix() {
return getData().getString("MQTT.Prefix", "");
}
public void load() {
@@ -244,4 +364,44 @@ public class Config {
}
}
@Override
public String getPluginMessageChannel() {
return getData().getString("PluginMessageChannel", "vp:vp");
}
@Override
public boolean getPluginMessageEncryption() {
return getData().getBoolean("PluginMessageEncryption", false);
}
@Override
public Collection<String> getWaitUntilVoteDelaySites() {
return getData().getSection("WaitUntilVoteDelay").getKeys();
}
@Override
public String getWaitUntilVoteDelayService(String site) {
return getData().getString("WaitUntilVoteDelay." + site + ".ServiceSite", "");
}
@Override
public int getWaitUntilVoteDelayVoteDelay(String site) {
return getData().getInt("WaitUntilVoteDelay." + site + ".VoteDelay", 24);
}
@Override
public boolean getWaitUntilVoteDelayVoteDelayDaily(String site) {
return getData().getBoolean("WaitUntilVoteDelay." + site + ".VoteDelayDaily", false);
}
@Override
public int getWaitUntilVoteDelayVoteDelayHour(String site) {
return getData().getInt("WaitUntilVoteDelay." + site + ".VoteDelayDailyHour", 0);
}
@Override
public int getWaitUntilVoteDelayVoteDelayMin(String site) {
return getData().getInt("WaitUntilVoteDelay." + site + ".VoteDelayMin", 0);
}
}
@@ -0,0 +1,73 @@
package com.bencodez.votingplugin.proxy.bungee;
import java.io.File;
import com.bencodez.simpleapi.file.BungeeJsonFile;
import com.velocitypowered.api.proxy.Player;
import lombok.Getter;
import net.md_5.bungee.config.Configuration;
public class NonVotedPlayersCache extends BungeeJsonFile {
private VotingPluginBungee plugin;
@Getter
private Configuration data;
public NonVotedPlayersCache(VotingPluginBungee plugin) {
super(new File(plugin.getDataFolder(), "nonvotedplayerscache.json"));
this.plugin = plugin;
}
public void addPlayer(Player player) {
if (!plugin.getVotingPluginProxy().getProxyMySQL().containsKeyQuery(player.getUniqueId().toString())) {
addPlayer(player.getUniqueId().toString(), player.getUsername());
}
}
public void addPlayer(String uuid, String playerName) {
setString("NonVotedPlayers." + playerName + ".UUID", uuid);
setLong("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
save();
}
public void addPlayerCheck(String uuid, String playerName) {
if (!plugin.getVotingPluginProxy().getProxyMySQL().containsKeyQuery(uuid)) {
addPlayer(uuid, playerName);
}
}
public void check() {
for (String player : getKeys("NonVotedPlayers")) {
long time = getLong("NonVotedPlayers." + player + ".LastTime", 0);
if ((System.currentTimeMillis() - time) > 1000 * 60 * 60 * 24 * 5) {
removePlayer(player);
} else {
String uuid = getString("NonVotedPlayers." + player + ".UUID", "");
if (!uuid.isEmpty()) {
if (plugin.getVotingPluginProxy().getProxyMySQL().containsKeyQuery(uuid)) {
removePlayer(player);
}
} else {
removePlayer(player);
}
}
}
save();
}
public String playerExists(String playerName) {
String uuid = getString("NonVotedPlayers." + playerName + ".UUID", "");
if (!uuid.isEmpty()) {
return uuid;
}
return "";
}
private void removePlayer(String player) {
plugin.debug("Removing nonvotedplayer: " + player);
remove("NonVotedPlayers." + player);
save();
}
}
@@ -0,0 +1,127 @@
package com.bencodez.votingplugin.proxy.bungee;
import java.io.File;
import java.util.Collection;
import com.bencodez.simpleapi.file.BungeeJsonFile;
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
import com.google.gson.JsonElement;
public class VoteCache extends BungeeJsonFile {
private VotingPluginBungee bungee;
public VoteCache(VotingPluginBungee bungee) {
super(new File(bungee.getDataFolder(), "votecache.json"));
this.bungee = bungee;
initialize();
}
private void initialize() {
if (!bungee.getDataFolder().exists()) {
bungee.getDataFolder().mkdir();
}
// Reload the JSON file to ensure latest data
reload();
}
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
String path = "TimedVoteCache." + num;
setString(path + ".Name", voteTimedQueue.getName());
setString(path + ".Service", voteTimedQueue.getService());
setLong(path + ".Time", voteTimedQueue.getTime());
}
public void addVote(String server, int num, OfflineBungeeVote voteData) {
String path = "VoteCache." + server + "." + num;
setString(path + ".Name", voteData.getPlayerName());
setString(path + ".Service", voteData.getService());
setString(path + ".UUID", voteData.getUuid());
setLong(path + ".Time", voteData.getTime());
setBoolean(path + ".Real", voteData.isRealVote());
setString(path + ".Text", voteData.getText());
}
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
String path = "OnlineCache." + player + "." + num;
setString(path + ".Name", voteData.getPlayerName());
setString(path + ".Service", voteData.getService());
setString(path + ".UUID", voteData.getUuid());
setLong(path + ".Time", voteData.getTime());
setBoolean(path + ".Real", voteData.isRealVote());
setString(path + ".Text", voteData.getText());
}
public void clearData() {
setString("VoteCache", null);
setString("OnlineCache", null);
setString("TimedVoteCache", null);
save();
}
public Collection<String> getOnlineVotes(String name) {
return getKeys("OnlineCache." + name);
}
public JsonElement getOnlineVotes(String name, String num) {
return getNode("OnlineCache." + name + "." + num);
}
public Collection<String> getPlayers() {
return getKeys("OnlineCache");
}
public Collection<String> getServers() {
return getKeys("VoteCache");
}
public Collection<String> getServerVotes(String server) {
return getKeys("VoteCache." + server);
}
public JsonElement getServerVotes(String server, String num) {
return getNode("VoteCache." + server + "." + num);
}
public Collection<String> getTimedVoteCache() {
return getKeys("TimedVoteCache");
}
public JsonElement getTimedVoteCache(String key) {
return getNode("TimedVoteCache." + key);
}
public int getVotePartyCache(String server) {
return getInt("VoteParty.Cache." + server, 0);
}
public int getVotePartyCurrentVotes() {
return getInt("VoteParty.CurrentVotes", 0);
}
public int getVotePartyInreaseVotesRequired() {
return getInt("VoteParty.IncreaseVotes", 0);
}
public void setVotePartyCache(String server, int amount) {
setInt("VoteParty.Cache." + server, amount);
}
public void setVotePartyCurrentVotes(int amount) {
setInt("VoteParty.CurrentVotes", amount);
}
public void setVotePartyInreaseVotesRequired(int amount) {
setInt("VoteParty.IncreaseVotes", amount);
}
@Override
public void save() {
super.save();
}
@Override
public void reload() {
super.reload();
}
}
@@ -1,4 +1,4 @@
package com.bencodez.votingplugin.bungee;
package com.bencodez.votingplugin.proxy.bungee;
import com.vexsoftware.votifier.bungee.events.VotifierEvent;
import com.vexsoftware.votifier.model.Vote;
@@ -28,7 +28,7 @@ public class VoteEventBungee implements net.md_5.bungee.api.plugin.Listener {
vote.setServiceName(serviceSite);
}
plugin.vote(vote.getUsername(), serviceSite, true, true, 0, null, null);
plugin.getVotingPluginProxy().vote(vote.getUsername(), serviceSite, true, true, 0, null, null);
}
});
@@ -0,0 +1,880 @@
package com.bencodez.votingplugin.proxy.bungee;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.CodeSource;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import com.bencodez.advancedcore.api.time.TimeType;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
import com.bencodez.simpleapi.sql.DataType;
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigBungee;
import com.bencodez.votingplugin.proxy.BungeeMethod;
import com.bencodez.votingplugin.proxy.BungeeVersion;
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
import com.bencodez.votingplugin.proxy.ProxyMysqlUserTable;
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import lombok.Getter;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.event.EventHandler;
public class VotingPluginBungee extends Plugin implements Listener {
@Getter
private Config config;
private NonVotedPlayersCache nonVotedPlayersCache;
private VoteCache voteCacheFile;
private String buildNumber = "NOTSET";
private VoteEventBungee voteEventBungee;
@Getter
private VotingPluginProxy votingPluginProxy;
public void debug(String msg) {
if (config.getDebug()) {
getLogger().info("Debug: " + msg);
}
}
public void debug2(String msg) {
debug(msg);
}
public Set<String> getAvailableAllServers() {
Set<String> servers = new HashSet<>();
if (config.getWhiteListedServers().isEmpty()) {
for (String s : getProxy().getServers().keySet()) {
if (!config.getBlockedServers().contains(s)) {
servers.add(s);
}
}
} else {
servers.addAll(config.getWhiteListedServers());
}
return servers;
}
public String getProperPlayerName(String uuid, String currentName) {
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
if (p != null && p.isConnected()) {
return p.getName();
}
return currentName;
}
private Configuration getVersionFile() {
try {
CodeSource src = this.getClass().getProtectionDomain().getCodeSource();
if (src != null) {
URL jar = src.getLocation();
ZipInputStream zip = null;
zip = new ZipInputStream(jar.openStream());
while (true) {
ZipEntry e = zip.getNextEntry();
if (e != null) {
String name = e.getName();
if (name.equals("votingpluginversion.yml")) {
Reader defConfigStream = new InputStreamReader(zip);
if (defConfigStream != null) {
Configuration conf = ConfigurationProvider
.getProvider(net.md_5.bungee.config.YamlConfiguration.class)
.load(defConfigStream);
defConfigStream.close();
return conf;
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public boolean isOnline(ProxiedPlayer p) {
if (p != null) {
return p.isConnected();
}
return false;
}
private void loadMysql() {
votingPluginProxy.setProxyMySQL(new ProxyMysqlUserTable("VotingPlugin_Users",
new MysqlConfigBungee(config.getData()), config.getDebug()) {
@Override
public void debug(SQLException e) {
if (config.getDebug()) {
e.printStackTrace();
}
}
@Override
public void logSevere(String string) {
getLogger().severe(string);
}
@Override
public void logInfo(String string) {
getLogger().info(string);
}
@Override
public void severe(String string) {
getLogger().severe(string);
}
});
ArrayList<String> servers = new ArrayList<>();
for (String s : getAvailableAllServers()) {
servers.add(s);
}
if (config.getGlobalDataEnabled()) {
if (config.getGlobalDataUseMainMySQL()) {
votingPluginProxy.setGlobalDataHandler(new GlobalDataHandlerProxy(
new GlobalMySQL("VotingPlugin_GlobalData", getVotingPluginProxy().getProxyMySQL().getMysql()) {
@Override
public void debugEx(Exception e) {
if (config.getDebug()) {
e.printStackTrace();
}
}
@Override
public void debugLog(String text) {
debug2(text);
}
@Override
public void info(String text) {
getLogger().info(text);
}
@Override
public void logSevere(String text) {
getLogger().severe(text);
}
@Override
public void warning(String text) {
getLogger().warning(text);
}
}, servers) {
@Override
public void onTimeChangedFailed(String server, TimeType type) {
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, type.toString(), false);
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, "Processing", false);
}
@Override
public void onTimeChangedFinished(TimeType type) {
if (type.equals(TimeType.MONTH)) {
getVotingPluginProxy().getProxyMySQL().copyColumnData(TopVoter.Monthly.getColumnName(),
"LastMonthTotal");
}
getVotingPluginProxy().getProxyMySQL().wipeColumnData(TopVoter.of(type).getColumnName(),
DataType.INTEGER);
if (!config.getGlobalDataEnabled()) {
return;
}
for (String s : getAvailableAllServers()) {
getVotingPluginProxy().getGlobalDataHandler().setBoolean(s, "ForceUpdate", true);
if (getVotingPluginProxy().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
getVotingPluginProxy().sendPluginMessageServer(s, "BungeeTimeChange", "");
} else if (getVotingPluginProxy().getMethod().equals(BungeeMethod.SOCKETS)) {
getVotingPluginProxy().sendServerMessage(s, "BungeeTimeChange");
}
}
getVotingPluginProxy().processQueue();
}
});
} else {
votingPluginProxy
.setGlobalDataHandler(new GlobalDataHandlerProxy(new GlobalMySQL("VotingPlugin_GlobalData",
new MysqlConfigBungee(config.getData().getSection("GlobalData"))) {
@Override
public void debugEx(Exception e) {
if (config.getDebug()) {
e.printStackTrace();
}
}
@Override
public void debugLog(String text) {
debug2(text);
}
@Override
public void info(String text) {
getLogger().info(text);
}
@Override
public void logSevere(String text) {
getLogger().severe(text);
}
@Override
public void warning(String text) {
getLogger().warning(text);
}
}, servers) {
@Override
public void onTimeChangedFailed(String server, TimeType type) {
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, type.toString(),
false);
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, "FinishedProcessing",
true);
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, "Processing", false);
}
@Override
public void onTimeChangedFinished(TimeType type) {
if (type.equals(TimeType.MONTH)) {
getVotingPluginProxy().getProxyMySQL()
.copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
}
getVotingPluginProxy().getProxyMySQL().wipeColumnData(TopVoter.of(type).getColumnName(),
DataType.INTEGER);
if (!config.getGlobalDataEnabled()) {
return;
}
for (String s : getAvailableAllServers()) {
getVotingPluginProxy().getGlobalDataHandler().setBoolean(s, "ForceUpdate", true);
if (getVotingPluginProxy().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
getVotingPluginProxy().sendPluginMessageServer(s, "BungeeTimeChange", "");
} else if (getVotingPluginProxy().getMethod().equals(BungeeMethod.SOCKETS)) {
getVotingPluginProxy().sendServerMessage(s, "BungeeTimeChange");
}
}
getVotingPluginProxy().processQueue();
}
});
}
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("FinishedProcessing",
"VARCHAR(5)");
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
}
// column types
getVotingPluginProxy().getProxyMySQL().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
getVotingPluginProxy().getProxyMySQL().alterColumnType("CheckWorld", "VARCHAR(5)");
getVotingPluginProxy().getProxyMySQL().alterColumnType("Reminded", "VARCHAR(5)");
getVotingPluginProxy().getProxyMySQL().alterColumnType("DisableBroadcast", "VARCHAR(5)");
getVotingPluginProxy().getProxyMySQL().alterColumnType("LastOnline", "VARCHAR(20)");
getVotingPluginProxy().getProxyMySQL().alterColumnType("PlayerName", "VARCHAR(30)");
getVotingPluginProxy().getProxyMySQL().alterColumnType("DailyTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("WeeklyTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("DayVoteStreak", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("BestDayVoteStreak", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("WeekVoteStreak", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("BestWeekVoteStreak", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("VotePartyVotes", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("MonthVoteStreak", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("Points", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("HighestDailyTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("AllTimeTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("HighestMonthlyTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("MilestoneCount", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("MonthTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("LastWeeklyTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType("OfflineRewards", "MEDIUMTEXT");
getVotingPluginProxy().getProxyMySQL().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
if (config.getStoreMonthTotalsWithDate()) {
getVotingPluginProxy().getProxyMySQL().alterColumnType(
getVotingPluginProxy().getMonthTotalsWithDatePath(LocalDateTime.now()), "INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType(
getVotingPluginProxy().getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1)),
"INT DEFAULT '0'");
getVotingPluginProxy().getProxyMySQL().alterColumnType(
getVotingPluginProxy().getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2)),
"INT DEFAULT '0'");
}
}
public void loadVersionFile() {
Configuration conf = getVersionFile();
if (conf != null) {
buildNumber = conf.get("buildnumber", "NOTSET");
}
}
public void login(ProxiedPlayer p) {
if (p != null && p.getServer() != null && p.getServer().getInfo() != null) {
final ProxiedPlayer proxiedPlayer = p;
getProxy().getScheduler().schedule(this, new Runnable() {
@Override
public void run() {
getVotingPluginProxy().login(proxiedPlayer.getName(), proxiedPlayer.getUniqueId().toString(),
proxiedPlayer.getServer().getInfo().getName());
}
}, 1, TimeUnit.SECONDS);
}
}
@Override
public void onDisable() {
if (getVotingPluginProxy().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
getLogger().info("VotingPlugin saving vote cache: " + getVotingPluginProxy().getCachedVotes().size() + "/"
+ getVotingPluginProxy().getCachedOnlineVotes().size());
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : getVotingPluginProxy().getCachedVotes()
.entrySet()) {
String server = entry.getKey();
int num = 0;
for (OfflineBungeeVote voteData : entry.getValue()) {
voteCacheFile.addVote(server, num, voteData);
num++;
}
}
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : getVotingPluginProxy().getCachedOnlineVotes()
.entrySet()) {
String name = entry.getKey();
int num = 0;
for (OfflineBungeeVote voteData : entry.getValue()) {
voteCacheFile.addVoteOnline(name, num, voteData);
num++;
}
}
}
if (!getVotingPluginProxy().getTimeChangeQueue().isEmpty()) {
int num = 0;
for (VoteTimeQueue vote : getVotingPluginProxy().getTimeChangeQueue()) {
voteCacheFile.addTimedVote(num, vote);
num++;
}
}
getVotingPluginProxy().onDisable();
voteCacheFile.save();
nonVotedPlayersCache.save();
getLogger().info("VotingPlugin disabled");
}
@Override
public void onEnable() {
getProxy().getPluginManager().registerListener(this, this);
config = new Config(this);
config.load();
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
votingPluginProxy = new VotingPluginProxy() {
@Override
public void addNonVotedPlayer(String uuid, String playerName) {
nonVotedPlayersCache.addPlayer(uuid, playerName);
}
@Override
public void broadcast(String message) {
getProxy().broadcast(new TextComponent(ChatColor.translateAlternateColorCodes('&', message)));
}
@Override
public void debug(String str) {
debug2(str);
}
@Override
public Set<String> getAllAvailableServers() {
return getAvailableAllServers();
}
@Override
public VotingPluginProxyConfig getConfig() {
return config;
}
@Override
public String getCurrentPlayerServer(String player) {
return getProxy().getPlayer(player).getServer().getInfo().getName();
}
@Override
public File getDataFolderPlugin() {
return getDataFolder();
}
@Override
public String getProperName(String uuid, String playerName) {
return getProperPlayerName(uuid, playerName);
}
@Override
public String getUUID(String playerName) {
if (!config.getOnlineMode()) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(StandardCharsets.UTF_8))
.toString();
}
ProxiedPlayer p = getProxy().getPlayer(playerName);
if (p != null && p.isConnected()) {
return p.getUniqueId().toString();
}
for (Entry<UUID, String> entry : getVotingPluginProxy().getUuidPlayerNameCache().entrySet()) {
if (entry.getValue().equalsIgnoreCase(playerName)) {
return entry.getKey().toString();
}
}
if (getVotingPluginProxy().getProxyMySQL() != null) {
String str = getVotingPluginProxy().getProxyMySQL().getUUID(playerName);
if (str != null) {
return str;
}
}
if (nonVotedPlayersCache != null) {
return nonVotedPlayersCache.playerExists(playerName);
}
return "";
}
@Override
public String getPluginVersion() {
return getDescription().getVersion();
}
@Override
public int getVoteCacheCurrentVotePartyVotes() {
return voteCacheFile.getVotePartyCurrentVotes();
}
@Override
public long getVoteCacheLastUpdated() {
return voteCacheFile.getLong("Time.LastUpdated", 0L);
}
@Override
public int getVoteCachePrevDay() {
return voteCacheFile.getInt("Time.Day", 0);
}
@Override
public String getVoteCachePrevMonth() {
return voteCacheFile.getString("Time.Month", "");
}
@Override
public int getVoteCachePrevWeek() {
return voteCacheFile.getInt("Time.Week", 0);
}
@Override
public int getVoteCacheVotePartyIncreaseVotesRequired() {
return voteCacheFile.getVotePartyInreaseVotesRequired();
}
@Override
public boolean isPlayerOnline(String playerName) {
ProxiedPlayer player = getProxy().getPlayer(playerName);
return player != null && player.isConnected();
}
@Override
public boolean isServerValid(String server) {
return getProxy().getServerInfo(server) != null;
}
@Override
public boolean isSomeoneOnlineServer(String server) {
return !getProxy().getServerInfo(server).getPlayers().isEmpty();
}
@Override
public boolean isVoteCacheIgnoreTime() {
return voteCacheFile.getBoolean("Time.IgnoreTime", false);
}
@Override
public void log(String message) {
getLogger().info(message);
}
@Override
public void logSevere(String message) {
getLogger().severe(message);
}
@Override
public void runAsync(Runnable run) {
runAsyncNow(run);
}
@Override
public void runConsoleCommand(String command) {
getProxy().getPluginManager().dispatchCommand(getProxy().getConsole(), command);
}
@Override
public void saveVoteCacheFile() {
voteCacheFile.save();
}
@Override
public void sendPluginMessageData(String server, String channel, byte[] data, boolean queue) {
getProxy().getServerInfo(server).sendData(channel, data, queue);
}
@Override
public void setVoteCacheLastUpdated() {
voteCacheFile.setLong("Time.LastUpdated", System.currentTimeMillis());
voteCacheFile.save();
}
@Override
public void setVoteCachePrevDay(int day) {
voteCacheFile.setInt("Time.Day", day);
voteCacheFile.save();
}
@Override
public void setVoteCachePrevMonth(String text) {
voteCacheFile.setString("Time.Month", text);
voteCacheFile.save();
}
@Override
public void setVoteCachePrevWeek(int week) {
voteCacheFile.setInt("Time.Week", week);
voteCacheFile.save();
}
@Override
public void setVoteCacheVoteCacheIgnoreTime(boolean ignore) {
voteCacheFile.setBoolean("Time.IgnoreTime", ignore);
voteCacheFile.save();
}
@Override
public void setVoteCacheVotePartyCurrentVotes(int votes) {
voteCacheFile.setVotePartyCurrentVotes(votes);
}
@Override
public void setVoteCacheVotePartyIncreaseVotesRequired(int votes) {
voteCacheFile.setVotePartyInreaseVotesRequired(votes);
}
@Override
public void warn(String message) {
getLogger().warning(message);
}
@Override
public void reloadCore(boolean mysql) {
reloadPlugin(mysql);
}
};
try {
Class.forName("com.vexsoftware.votifier.bungee.events.VotifierEvent");
} catch (ClassNotFoundException e) {
getVotingPluginProxy().setVotifierEnabled(false);
}
if (getVotingPluginProxy().isVotifierEnabled()) {
try {
voteEventBungee = new VoteEventBungee(this);
getProxy().getPluginManager().registerListener(this, voteEventBungee);
} catch (Exception e) {
getVotingPluginProxy().setVotifierEnabled(false);
}
}
boolean mysqlLoaded = true;
try {
if (!config.getData().getString("Host", "").isEmpty()) {
loadMysql();
} else {
mysqlLoaded = false;
getLogger().severe("MySQL settings not set in bungeeconfig.yml");
}
} catch (Exception e) {
mysqlLoaded = false;
e.printStackTrace();
}
this.getProxy().registerChannel(getConfig().getPluginMessageChannel());
if (mysqlLoaded) {
voteCacheFile = new VoteCache(this);
// voteCacheFile.load();
nonVotedPlayersCache = new NonVotedPlayersCache(this);
// nonVotedPlayersCache.load();
getVotingPluginProxy().load();
try {
for (String key : voteCacheFile.getTimedVoteCache()) {
JsonElement dataElement = voteCacheFile.getTimedVoteCache(key);
if (dataElement != null && dataElement.isJsonObject()) {
JsonObject data = dataElement.getAsJsonObject();
String name = data.has("Name") ? data.get("Name").getAsString() : "";
String service = data.has("Service") ? data.get("Service").getAsString() : "";
long time = data.has("Time") ? data.get("Time").getAsLong() : 0L;
getVotingPluginProxy().getTimeChangeQueue().add(new VoteTimeQueue(name, service, time));
}
}
getVotingPluginProxy().processQueue();
} catch (Exception e) {
e.printStackTrace();
}
try {
for (String server : voteCacheFile.getServers()) {
ArrayList<OfflineBungeeVote> votes = new ArrayList<>();
for (String num : voteCacheFile.getServerVotes(server)) {
JsonElement dataElement = voteCacheFile.getServerVotes(server, num);
if (dataElement != null && dataElement.isJsonObject()) {
JsonObject data = dataElement.getAsJsonObject();
String name = data.has("Name") ? data.get("Name").getAsString() : "";
String uuid = data.has("UUID") ? data.get("UUID").getAsString() : "";
String service = data.has("Service") ? data.get("Service").getAsString() : "";
long time = data.has("Time") ? data.get("Time").getAsLong() : 0L;
boolean real = data.has("Real") && data.get("Real").getAsBoolean();
String text = data.has("Text") ? data.get("Text").getAsString() : "";
votes.add(new OfflineBungeeVote(name, uuid, service, time, real, text));
}
}
getVotingPluginProxy().getCachedVotes().put(server, votes);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
for (String player : voteCacheFile.getPlayers()) {
ArrayList<OfflineBungeeVote> votes = new ArrayList<>();
for (String num : voteCacheFile.getOnlineVotes(player)) {
JsonElement dataElement = voteCacheFile.getOnlineVotes(player, num);
if (dataElement != null && dataElement.isJsonObject()) {
JsonObject data = dataElement.getAsJsonObject();
String name = data.has("Name") ? data.get("Name").getAsString() : "";
String uuid = data.has("UUID") ? data.get("UUID").getAsString() : "";
String service = data.has("Service") ? data.get("Service").getAsString() : "";
long time = data.has("Time") ? data.get("Time").getAsLong() : 0L;
boolean real = data.has("Real") && data.get("Real").getAsBoolean();
String text = data.has("Text") ? data.get("Text").getAsString() : "";
votes.add(new OfflineBungeeVote(name, uuid, service, time, real, text));
}
}
getLogger().info("VoteCache: " + player);
getVotingPluginProxy().getCachedOnlineVotes().put(player, votes);
}
} catch (Exception e) {
e.printStackTrace();
}
voteCacheFile.clearData();
getProxy().getScheduler().schedule(this, new Runnable() {
@Override
public void run() {
for (String server : getVotingPluginProxy().getCachedVotes().keySet()) {
getVotingPluginProxy().checkCachedVotes(server);
}
for (String player : getVotingPluginProxy().getCachedOnlineVotes().keySet()) {
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(player));
if (p != null) {
getVotingPluginProxy().checkOnlineVotes(p.getName(), player, null);
}
}
}
}, 120l, 60l, TimeUnit.SECONDS);
getProxy().getScheduler().schedule(this, new Runnable() {
@Override
public void run() {
if (nonVotedPlayersCache != null) {
debug("Checking nonvotedplayers.yml...");
nonVotedPlayersCache.check();
}
if (voteCacheFile != null) {
voteCacheFile.save();
}
}
}, 1l, 60l, TimeUnit.MINUTES);
}
if (!getVotingPluginProxy().isVotifierEnabled()) {
if (!(getConfig().getMultiProxySupport() && !getConfig().getPrimaryServer())) {
getLogger().warning("Votifier event not found, not loading votifier event");
}
}
BStatsMetricsBungee metrics = new BStatsMetricsBungee(this, 9453);
metrics.addCustomChart(
new BStatsMetricsBungee.SimplePie("bungee_method", () -> getConfig().getBungeeMethod().toString()));
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("sendtoallservers",
() -> "" + getConfig().getSendVotesToAllServers()));
metrics.addCustomChart(
new BStatsMetricsBungee.SimplePie("allowunjoined", () -> "" + getConfig().getAllowUnJoined()));
metrics.addCustomChart(
new BStatsMetricsBungee.SimplePie("pointsonvote", () -> "" + getConfig().getPointsOnVote()));
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("bungeemanagetotals",
() -> "" + getConfig().getBungeeManageTotals()));
metrics.addCustomChart(
new BStatsMetricsBungee.SimplePie("waitforuseronline", () -> "" + getConfig().getWaitForUserOnline()));
metrics.addCustomChart(
new BStatsMetricsBungee.SimplePie("globaldata_enabled", () -> "" + getConfig().getGlobalDataEnabled()));
if (getConfig().getGlobalDataEnabled()) {
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("globaldata_usemainmysql",
() -> "" + getConfig().getGlobalDataUseMainMySQL()));
}
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("multi_proxy_support_enabled",
() -> "" + getConfig().getMultiProxySupport()));
if (!buildNumber.equals("NOTSET")) {
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("dev_build_number", () -> "" + buildNumber));
}
loadVersionFile();
getLogger().info("VotingPlugin loaded, using method: " + getVotingPluginProxy().getMethod().toString()
+ ", PluginMessagingVersion: " + BungeeVersion.getPluginMessageVersion());
if (!buildNumber.equals("NOTSET")) {
getLogger().info("Detected using dev build number: " + buildNumber);
}
getVotingPluginProxy().sendServerNameMessage();
}
@EventHandler
public void onPluginMessage(PluginMessageEvent ev) {
if (!ev.getTag().equals(getConfig().getPluginMessageChannel().toLowerCase())) {
return;
}
ev.setCancelled(true);
if (!(ev.getSender() instanceof Server)) {
debug("Ignore plugin message");
return;
}
ByteArrayInputStream instream = new ByteArrayInputStream(ev.getData());
DataInputStream in = new DataInputStream(instream);
try {
getVotingPluginProxy().onPluginMessageReceived(in);
} catch (Exception e) {
e.printStackTrace();
}
}
public void reloadPlugin(boolean loadMysql) {
config.load();
if (loadMysql) {
try {
if (!config.getData().getString("Host", "").isEmpty()) {
loadMysql();
} else {
getLogger().severe("MySQL settings not set in bungeeconfig.yml");
}
} catch (Exception e) {
e.printStackTrace();
}
}
getVotingPluginProxy().reload();
}
private void runAsyncNow(Runnable runnable) {
getProxy().getScheduler().runAsync(this, runnable);
}
}
@@ -0,0 +1,42 @@
package com.bencodez.votingplugin.proxy.bungee;
import com.bencodez.votingplugin.proxy.VotingPluginProxyCommand;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
public class VotingPluginBungeeCommand extends Command {
private VotingPluginBungee bungee;
public VotingPluginBungeeCommand(VotingPluginBungee bungee) {
super("votingpluginbungee", "votingplugin.admin");
this.bungee = bungee;
}
@Override
public void execute(CommandSender sender, String[] args) {
if (sender.hasPermission("votingplugin.admin")) {
String result = new VotingPluginProxyCommand(bungee.getVotingPluginProxy()).execute(args);
if (result != null) {
sender.sendMessage(new TextComponent(result.replace("&", "§")));
}
} else {
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!".replace("&", "§")));
}
}
public boolean isInt(String st) {
if (st == null) {
return false;
}
try {
@SuppressWarnings("unused")
int num = Integer.parseInt(st);
return true;
} catch (NumberFormatException ex) {
return false;
}
}
}
@@ -1,35 +1,21 @@
package com.bencodez.votingplugin.bungee.global.multiproxy;
package com.bencodez.votingplugin.proxy.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 com.bencodez.simpleapi.encryption.EncryptionHandler;
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
import com.bencodez.votingplugin.proxy.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;
@@ -41,19 +27,9 @@ public abstract class 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 void addNonVotedPlayerCache(String string, String string2);
public abstract List<String> getProxyServers();
public abstract void clearVote(String string);
public void close() {
if (multiproxySocketHandler != null) {
@@ -65,11 +41,49 @@ public abstract class MultiProxyHandler {
}
}
public abstract boolean getDebug();
public abstract EncryptionHandler getEncryptionHandler();
public abstract MultiProxyMethod getMultiProxyMethod();
public abstract String getMultiProxyPassword();
public abstract String getMultiProxyRedisHost();
public abstract int getMultiProxyRedisPort();
public abstract boolean getMultiProxyRedisUseExistingConnection();
public abstract String getMultiProxyServerName();
public abstract Collection<String> getMultiProxyServers();
public abstract MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s);
public abstract String getMultiProxySocketHostHost();
public abstract int getMultiProxySocketHostPort();
public abstract boolean getMultiProxySupportEnabled();
public abstract String getMultiProxyUsername();
public abstract File getPluginDataFolder();
public abstract boolean getPrimaryServer();
public abstract List<String> getProxyServers();
public abstract RedisHandler getRedisHandler();
public abstract String getVersion();
public void loadMultiProxySupport() {
if (getMultiProxySupportEnabled()) {
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
if (getEncryptionHandler() == null) {
setEncryptionHandler(new EncryptionHandler(new File(getPluginDataFolder(), "secretkey.key")));
setEncryptionHandler(new EncryptionHandler("VotingPlugin",new File(getPluginDataFolder(), "secretkey.key")));
}
if (multiproxySocketHandler != null) {
@@ -117,7 +131,7 @@ public abstract class MultiProxyHandler {
}
});
multiproxyClientHandles = new HashMap<String, ClientHandler>();
multiproxyClientHandles = new HashMap<>();
for (String s : getMultiProxyServers()) {
MultiProxyServerSocketConfiguration d = getMultiProxyServersConfiguration(s);
multiproxyClientHandles.put(s,
@@ -131,6 +145,13 @@ public abstract class MultiProxyHandler {
multiProxyRedis = new RedisHandler(getMultiProxyRedisHost(), getMultiProxyRedisPort(),
getMultiProxyUsername(), getMultiProxyPassword()) {
@Override
public void debug(String message) {
if (getDebug()) {
logInfo("MultiProxyRedis: " + message);
}
}
@Override
public void onMessage(String channel, String[] data) {
if (data.length > 0) {
@@ -158,13 +179,6 @@ public abstract class MultiProxyHandler {
}
}
}
@Override
public void debug(String message) {
if (getDebug()) {
logInfo("MultiProxyRedis: " + message);
}
}
};
}
@@ -182,48 +196,31 @@ public abstract class MultiProxyHandler {
}
}
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()) {
if (!getMultiProxySupportEnabled() || getPrimaryServer()) {
return;
}
sendMultiProxyServerMessage("Login", uuid, playerName);
}
public abstract int getMultiProxySocketHostPort();
public abstract void logInfo(String msg);
public abstract String getMultiProxySocketHostHost();
public abstract void runAsnc(Runnable runnable);
public abstract MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s);
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 Collection<String> getMultiProxyServers();
public abstract void setEncryptionHandler(EncryptionHandler encryptionHandler);
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);
}
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff. Show more