Compare commits

...

244 Commits

Author SHA1 Message Date
Ryder Belserion 4b20f61b21
set lore to update timer 2024-03-24 11:25:53 -04:00
Ryder Belserion b8e5d2dd7a
Fix other issue with lore duplicating 2024-03-24 11:24:15 -04:00
Ryder Belserion f79a2eed10
Display items in /ah 2024-03-24 11:22:30 -04:00
Ryder Belserion 56278d3313
[ci-skip] update changelog.md 2024-03-20 13:02:07 -04:00
Ryder Belserion 8f22438d4e
Update plugin.yml 2024-03-20 12:27:47 -04:00
Ryder Belserion 1fa748215c
Update itembuilder with custom model data support 2024-03-20 12:26:42 -04:00
TrueDarkLord 35768c9e34
Sell Sound
Should cover #171
2024-03-09 11:09:42 -07:00
Ryder Belserion fa47a8a089
Update api 2024-03-05 23:48:12 -05:00
Ryder Belserion 54c07b7de9
Update build script 2024-03-05 18:57:10 -05:00
Ryder Belserion 6413bcefd8
Update plugin.yml 2024-03-05 18:57:03 -05:00
Ryder Belserion 39c002faaa
Create config file 2024-03-05 18:56:56 -05:00
Ryder Belserion 44ef839651
Create service classes 2024-03-05 18:56:50 -05:00
Ryder Belserion cced985f58
Add server interface 2024-03-05 18:56:33 -05:00
Ryder Belserion 10eed8d0d1
Download required plugins on startup for dev server 2024-03-05 12:15:11 -05:00
Ryder Belserion 47205145fb
Update build script 2024-03-05 12:08:54 -05:00
Ryder Belserion ee28bda29a
Merge pull request #167 from Crazy-Crew/mc/1.20.3
Add a quick bug fix for 1.3.2 before 1.4
2023-12-06 15:19:19 -05:00
Ryder Belserion 4c23e6b11e
version 1.3.2 2023-12-06 15:15:25 -05:00
Ryder Belserion 80de79a82a
fix that 2023-12-06 15:11:58 -05:00
Ryder Belserion e034034077
Fix jar task 2023-12-06 15:00:28 -05:00
Ryder Belserion f95c5277a4
Update methods to check for player uuid instead of player object 2023-12-06 15:00:23 -05:00
Ryder Belserion 2f580dbdfb
this gui code is a dumpster fire 2023-12-06 14:54:54 -05:00
Ryder Belserion 9807a59a88
Merge pull request #164 from Crazy-Crew/ver/1.4
Fix some tab complete stuff (v1.3.1)
2023-11-27 16:13:35 -05:00
Ryder Belserion 93bbb8f7de
Update changelog 2023-11-27 16:13:07 -05:00
Ryder Belserion 663ae04381
fix tab complete order 2023-11-27 16:09:16 -05:00
Ryder Belserion fddbcef0a7
Revert "version bump"
This reverts commit b11f1986cc.
2023-11-27 12:19:50 -05:00
Ryder Belserion b11f1986cc
version bump 2023-11-27 12:18:06 -05:00
Ryder Belserion 3017a4518b
[ci-skip] update changelog 2023-11-27 12:17:38 -05:00
Ryder Belserion b702b762b3
Merge branch 'main' of github.com:Crazy-Crew/CrazyAuctions 2023-11-27 12:15:01 -05:00
Ryder Belserion 02496da1e4
fix permissions 2023-11-27 12:14:56 -05:00
Ryder Belserion b830cfba96
Merge pull request #163 from Crazy-Crew/ryderbelserion-patch-1
Update plugin.yml
2023-11-27 12:14:35 -05:00
Ryder Belserion e67f25b697
Update plugin.yml
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-11-27 12:14:27 -05:00
Ryder Belserion 3eb18d193f
[ci-skip] update changelog 2023-11-27 01:34:10 -05:00
Ryder Belserion 89692c9251
github merge conflicts are put together by morons 2023-11-27 01:26:40 -05:00
Ryder Belserion d3a724a319
Merge pull request #162 from Crazy-Crew/ver/1.3
A kitchen sink
2023-11-27 01:20:55 -05:00
Ryder Belserion 5233dd88db
Merge branch 'main' into ver/1.3
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-11-27 01:20:37 -05:00
Ryder Belserion 24757083a9
update everything 2023-11-27 01:17:59 -05:00
Ryder Belserion 2b1110f03c
update files 2023-11-26 22:57:48 -05:00
Ryder Belserion 689a5170f4
Revert "Bump version"
This reverts commit ac2edcda08.
2023-11-26 22:48:37 -05:00
Ryder Belserion e508750a3b
add build.gradle 2023-11-26 22:46:43 -05:00
Ryder Belserion c8e370a1f2
add empty plugin 2023-11-26 13:51:29 -05:00
Ryder Belserion f41da7ab69
update build script 2023-11-26 12:31:52 -05:00
Ryder Belserion ac2edcda08
Bump version 2023-11-11 12:55:17 -05:00
Ryder Belserion 172df2dfa3
update buildscript 2023-11-11 12:53:47 -05:00
Ryder Belserion 16460b4e1a
Update LICENSE
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-08-23 13:35:36 -04:00
Ryder Belserion bf92cdd0fa
Update LICENSE
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-08-23 13:09:22 -04:00
Ryder Belserion f6182d3b3e
add actual v1 code 2023-08-21 14:06:07 -04:00
Ryder Belserion 9e53ad8eb5
[ci-skip] delete .github 2023-08-21 03:05:21 -04:00
Ryder Belserion a1bc9a041c
[ci-skip] delete .github 2023-08-21 03:03:49 -04:00
Ryder Belserion bb44c6fd22
[ci-skip] Update bugs.yml
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-08-21 02:44:48 -04:00
Ryder Belserion 8b9663f245
Delete FUNDING.yml
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-08-19 01:42:59 -04:00
Ryder Belserion ba850f5c33
rename dir 2023-07-26 10:41:57 -04:00
Ryder Belserion 74dbea8423
changes 2023-07-26 01:33:37 -04:00
Ryder Belserion 5a69919781
fat jar ftw 2023-07-23 14:28:39 -04:00
Ryder Belserion fd55cebcda
Update .gitignore 2023-07-22 17:57:33 -04:00
Ryder Belserion 84abdcdf1d
signing key test 2023-07-22 02:47:40 -04:00
Ryder Belserion 172772340c
another test 2023-07-22 02:46:20 -04:00
Ryder Belserion 8549892420
test 2023-07-22 02:43:31 -04:00
Ryder Belserion 2cf5956595
comment treasury api 2023-07-21 12:43:59 -04:00
Ryder Belserion 4dcf4de6a4
Add treasury api dep 2023-07-21 01:18:13 -04:00
Ryder Belserion 937247d6af
Move currency stuff 2023-07-21 01:18:06 -04:00
Ryder Belserion c29866bb9a
use variable 2023-07-21 01:06:37 -04:00
Ryder Belserion f48bad4f53
Vault please fix your build script 2023-07-21 01:05:59 -04:00
Ryder Belserion e3641ff7bb
fuck you 2023-07-21 00:31:47 -04:00
Ryder Belserion 3021ef6c45
Add default auction house command 2023-07-20 22:23:41 -04:00
Ryder Belserion ae0959c028
Remove old data support 2023-07-20 22:23:34 -04:00
Ryder Belserion 0604cc4e1d
Create inventory handler 2023-07-20 22:23:23 -04:00
Ryder Belserion a66c036289
Add reload command 2023-07-20 22:23:14 -04:00
Ryder Belserion e9fe8d97f6
Update variable name 2023-07-20 22:23:02 -04:00
Ryder Belserion a46b2acfa3
Use plugin variable 2023-07-20 22:22:51 -04:00
Ryder Belserion 453c77f192
That's enough accidentally using this import. 2023-07-20 22:21:28 -04:00
Ryder Belserion 27582743d3
use decorationIfAbsent 2023-07-20 21:03:22 -04:00
Ryder Belserion e110230d24
userdev does not seem to want to work 2023-07-20 20:31:15 -04:00
Ryder Belserion 32f0f642ab
update the entire project 2023-07-20 20:16:20 -04:00
Ryder Belserion 79435f7863
Update README.md
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-06-20 00:02:10 -04:00
Ryder Belserion 651b3a9055
Update README.md
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-06-20 00:01:01 -04:00
Ryder Belserion e824519d47
RalphAuctions, the code you forked is incomplete and is a part of a full re-write.
You should just start over anyway.

Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-06-20 00:00:40 -04:00
Ryder Belserion 4d7191d041
Remove jars folder 2023-04-01 11:20:53 -04:00
Ryder Belserion 74c1f541b6
Update it again 2023-04-01 11:20:30 -04:00
Ryder Belserion 96ae2e249a
Update .gitignore 2023-04-01 11:20:21 -04:00
Ryder Belserion 2f1931bcc2
Update buildscript 2023-04-01 11:19:31 -04:00
Ryder Belserion ef7c6f0041
Update README.md
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-03-21 16:12:29 -04:00
Ryder Belserion 4e34ee7edf
Good old webp, nothing beats good old webp
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-03-19 15:26:30 -04:00
Ryder Belserion eb46b3e2dd
Update README.md
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
2023-03-13 16:53:59 -04:00
Ryder Belserion aa45c88b7e
Renamed core api's 2023-03-05 18:14:10 -05:00
Ryder Belserion aab0b2cae3
Remove unnecessary hex codes from logging 2023-03-04 23:46:47 -05:00
Ryder Belserion 23499e7682
Add verbose check to locale extractor 2023-03-04 23:41:05 -05:00
Ryder Belserion ac6caf62e1
Capitalize artifact/output name 2023-03-04 23:40:48 -05:00
Ryder Belserion 043f216b5e
Rename from locale-en.yml to en-US.yml 2023-03-04 23:40:38 -05:00
Ryder Belserion 0fe4f5d8ef
Add repository to loader 2023-03-04 23:40:29 -05:00
Ryder Belserion a3cde1481d
Reset versioning because it ain't the same plugin 2023-03-04 23:40:18 -05:00
Ryder Belserion aaa07fbd27
add locale class 2023-03-04 23:16:35 -05:00
Ryder Belserion ca89bd6371
(misc) move to api module 2023-03-04 23:16:04 -05:00
Ryder Belserion c5a07ad83b
(gradle) add triumph cmds to class loader 2023-03-04 23:02:25 -05:00
Ryder Belserion 0fff965641
(config) Add some config options 2023-03-04 23:02:12 -05:00
Ryder Belserion aa5696f8b9
(misc) import updates 2023-03-04 22:35:39 -05:00
Ryder Belserion 77d669cff0
(commands) add permissions enum 2023-03-04 22:35:22 -05:00
Ryder Belserion 50a97e63c3
(misc) redundant directory 2023-03-04 22:35:08 -05:00
Ryder Belserion f8b3ec0f65
(bootstrap) Update loader/bootstrap 2023-03-04 22:34:49 -05:00
Ryder Belserion c917f5cbfd
(gradle) Rename core -> api 2023-03-04 22:34:21 -05:00
Ryder Belserion 8187592b3c
(readme) Spigot is not supported. 2023-03-04 22:33:54 -05:00
Ryder Belserion eae9691961
Update java docs 2023-02-28 03:15:41 -05:00
Ryder Belserion cbda4e02a2
Remove server version checking 2023-02-28 03:15:35 -05:00
Ryder Belserion 1ad63d1a56
Add storage manager 2023-02-28 02:59:44 -05:00
Ryder Belserion 65e390131f
Start working on per player data files 2023-02-28 01:27:07 -05:00
Ryder Belserion cf4cab91be
Add configme 2023-02-28 01:26:55 -05:00
Ryder Belserion a28521f105
Make use of paper's new bootstrap/library loader 2023-02-28 01:26:27 -05:00
Ryder Belserion cc10d4d653
Set up crazycore with paper api 2023-02-28 01:25:51 -05:00
Ryder Belserion b64e667ef0
Clean up build script 2023-02-28 01:24:26 -05:00
Ryder Belserion 8bce928446
Remove spigot module 2023-02-28 01:23:59 -05:00
Ryder Belserion 9085d6dda4
Rename to build-src 2023-02-28 01:23:47 -05:00
Ryder Belserion c1a9f79317
Delete run directory 2023-02-21 22:42:53 -05:00
Ryder Belserion f61f2ae66a
Remove runServer 2023-02-21 22:41:53 -05:00
Ryder Belserion 8cf3b02d19
Update project group 2023-02-21 22:41:34 -05:00
Ryder Belserion 0863a4e102
That does not make sense... 2023-02-21 19:54:20 -05:00
Ryder Belserion cb36769d9d
(workflow) Clean up build script
Changed:
 > Remove duplicated repositories
 > Removed paper run
 > Bumped minotaur
 > Bumped ktor
 > Cleaned up plugin.yml
 > Cleaned up build script
 > Changed to us.crazycrew

Added:
 > Issue/Bug Templates
2023-02-21 19:46:09 -05:00
Ryder Belserion 7ba7110b57
Update configurations
Changes:
  - Inherit the plugin variable through the interface
  - Add e.printStackTrace()
  - Update config comments for the storage-method ( Block Comments cannot be used on Java 8 )
2023-02-19 13:03:32 -05:00
Ryder Belserion ba6a47e667
Bump ruby version 2023-02-19 13:02:06 -05:00
Ryder Belserion 1bfc8490c6
Push this shit here 2023-02-19 03:29:05 -05:00
Ryder Belserion fd186f7034
Push my shit 2023-02-19 03:26:19 -05:00
BadBones 7b988d3028
Add TODO 2023-02-19 03:24:57 -05:00
BadBones d8377cacc2
Added categories 2023-02-19 03:20:04 -05:00
Ryder Belserion dc3be9954e
Player texture worky now 2023-02-19 02:55:35 -05:00
BadBones e143cac27a
remove error 2023-02-19 02:48:22 -05:00
BadBones e13d318720
Current code 2023-02-19 02:46:45 -05:00
BadBones 023be7ea5e
Commited 2023-02-19 01:35:17 -05:00
Ryder Belserion e8b64bf928
Add spigot module 2023-02-19 01:33:42 -05:00
Ryder Belserion 017869c38a
Updated version code
Changed:
- Cleaned up the server protocol checker
- Simplified supported game versions in the build script
2023-02-18 22:04:49 -05:00
Ryder Belserion e0f776760f
Do not need to shade api module twice since it's declared as inherited in the base api 2023-02-18 21:50:44 -05:00
Ryder Belserion 03aae70fee
Make config version a double 2023-02-18 21:49:16 -05:00
Ryder Belserion c09adc5991
Change config version to 1 2023-02-18 21:48:55 -05:00
BadBones 06d89cf22e
Commented and Pushed 2023-02-18 21:46:01 -05:00
Ryder Belserion 16e172d0e0
It now is using the proper API 2023-02-18 21:45:25 -05:00
Ryder Belserion bcce34d9c1
I forgot the repository 2023-02-18 21:33:59 -05:00
Ryder Belserion 22be7cf573
Fixed gradle not reloading 2023-02-18 21:31:44 -05:00
Ryder Belserion b53c9dd864
Push latest chanages 2023-02-18 00:48:54 -05:00
Ryder Belserion abc28d901b
Add the config.yml 2023-02-06 02:34:05 -05:00
Ryder Belserion ae1401f00b
Incorporate triumph gui/cmds 2023-02-06 02:12:11 -05:00
Ryder Belserion 4b5018fa0a
Update .gitignore 2023-02-06 02:08:46 -05:00
Ryder Belserion 64cb1aae55
Update build script with the juicy toys 2023-02-06 01:58:02 -05:00
Ryder Belserion 6aca5269ef
Turn off build release 2023-02-06 01:57:40 -05:00
Ryder Belserion f40f8b30a9
Remove old code 2023-02-06 01:56:47 -05:00
Ryder Belserion 11e905f66f
[ci-skip] Fix github action 2023-02-05 23:13:47 -05:00
Ryder Belserion 89077fe9db
[ci-skip] Update README information. 2023-02-05 22:47:15 -05:00
Ryder Belserion d2f26f02ba
[ci-skip] Remove bug reports 2023-01-10 19:57:44 -05:00
Ryder Belserion 2b9f1721cd
Fixes #1 2023-01-10 19:32:31 -05:00
Ryder Belserion 430f7b0cf1
[ci-skip] Fix command example 2023-01-10 18:55:34 -05:00
Ryder Belserion ddd63e3493
[ci-skip] Change title 2023-01-10 18:52:33 -05:00
Ryder Belserion 278b8791c5
Update 2023-01-10 18:49:56 -05:00
Ryder Belserion e1de765040
[ci-skip] Update bug report 2023-01-10 14:29:59 -05:00
Ryder Belserion abbe1e0be8
[ci-skip] use rootProject.name 2023-01-10 14:12:51 -05:00
Ryder Belserion 20ca5b636a
[ci-skip] Github workflows hates these 2023-01-10 01:08:26 -05:00
Ryder Belserion 1130d3ee79
[ci-skip] Java version only accessible via project.extra not extra 2023-01-09 23:02:21 -05:00
Ryder Belserion 89d4f02982
[ci-skip] Move mover values to gradle.properties 2023-01-09 22:56:03 -05:00
Ryder Belserion 48d055d982
[ci-skip] Update README 2023-01-07 11:59:16 -05:00
Ryder Belserion 0c8b1552cf
The fun begins. 2023-01-07 02:27:10 -05:00
Ryder Belserion 4aa13288cd
Merge pull request #149 from Crazy-Crew/RyderBelserion-patch-1
Update FUNDING.yml
2022-11-30 16:38:35 -05:00
Ryder Belserion 812d5e7a61
Update FUNDING.yml
Signed-off-by: Ryder Belserion <52214219+RyderBelserion@users.noreply.github.com>
2022-11-30 16:36:48 -05:00
Ryder Belserion 9f00df433d
Update README.md
Signed-off-by: Ryder Belserion <52214219+RyderBelserion@users.noreply.github.com>
2022-11-27 16:25:08 -05:00
Ryder Belserion 41f7eaf960
Switch to kotlin completely & reset versioning 2022-11-05 00:58:22 -04:00
Ryder Belserion c2a33fb9cd
Update bug_report 2022-11-05 00:58:03 -04:00
Ryder Belserion 13f7374d0f
Remove old code 2022-11-05 00:57:48 -04:00
Ryder Belserion a6282a9d16
Update README 2022-11-05 00:57:33 -04:00
Ryder Belserion fdef68103d
Add misc things 2022-11-05 00:57:28 -04:00
Ryder Belserion c7879e8fb0
Forgot the end bracket 2022-10-11 23:40:56 -04:00
Ryder Belserion 8eebe32546
Merge pull request #148 from SirKillian/main
Updated items in categories
2022-10-11 20:43:08 -04:00
SirKillian 875fd25851 updated items in categories 2022-10-12 02:34:49 +02:00
Ryder Belserion 17584e2c4f
Soon 2022-10-11 16:52:11 -04:00
Ryder Belserion f468716aff
Remove 1.12.2 & below support! 2022-10-11 16:51:08 -04:00
Ryder Belserion fd9c396483
Only allow on 1.13+ 2022-10-11 16:47:35 -04:00
Ryder Belserion b76ea867e6
Remove all static & improve it 2022-10-11 16:46:43 -04:00
Ryder Belserion 134f4a5a08
Remove old code 2022-10-11 16:46:27 -04:00
Ryder Belserion 505e961ea8
Getter class 2022-10-11 16:46:19 -04:00
Ryder Belserion acbf1fb589
Add multiple currency boilerplate 2022-10-11 16:46:08 -04:00
Ryder Belserion a837010921
Add item builder & skull creator 2022-10-11 16:45:38 -04:00
Ryder Belserion 497c355163
Change base command 2022-10-11 16:45:29 -04:00
Ryder Belserion b82d66819f
Soft depend on vault 2022-10-11 16:45:24 -04:00
Ryder Belserion 73803ffd46
Update README 2022-10-11 16:45:15 -04:00
Ryder Belserion 305775abd3
Use paper 2022-10-11 16:45:09 -04:00
Ryder Belserion 764ae4e5e1
Convert to gradle 2022-10-11 16:42:50 -04:00
Ryder Belserion 6e9873715b
Rename files 2022-10-11 16:42:35 -04:00
Ryder Belserion b55e481f41
[ci-skip] Update 2022-09-07 18:54:01 -04:00
Ryder Belserion 1d1727818e
[ci-skip] Update 2022-08-30 22:47:06 -04:00
Ryder Belserion 5d9733ed7f
[ci-skip] open collective dead 2022-08-30 16:20:08 -04:00
Ryder Belserion 8a49e579c3
[ci-skip] Update .github 2022-08-30 14:48:13 -04:00
Ryder Belserion 70a514cb64
Update License. 2022-07-31 14:21:13 -04:00
Ryder Belserion 81994cfa6e Match naming scheme with other plugins. 2022-07-28 00:48:38 -04:00
Ryder Belserion c56c347ab5 1.19.1 update 2022-07-28 00:47:54 -04:00
Ryder Belserion 3180e7b1ba
Update README.md 2022-07-09 00:00:09 -04:00
Ryder Belserion 9b3a9c0807
Update README.md 2022-07-08 19:56:42 -04:00
Ryder Belserion 476001b296
Update LICENSE 2022-07-08 17:41:32 -04:00
Ryder Belserion 57f9ebd7d8 [ci-skip] Update README 2022-07-07 20:18:04 -04:00
Ryder Belserion a501ab5ff0 [ci-skip] Update README 2022-07-07 20:10:11 -04:00
Ryder Belserion 1b6e59735b Merge remote-tracking branch 'origin/master' 2022-06-23 12:37:41 -04:00
Ryder Belserion 872d47af9d Update versioning. 2022-06-23 12:36:40 -04:00
Ryder Belserion 32076ecb68
Update pom.xml 2022-06-16 14:18:47 -04:00
Ryder Belserion 884392cc4e
Skipped a version 2022-06-16 14:07:43 -04:00
Ryder Belserion 717dee1a3f
[ci-skip] Update README 2022-06-11 21:02:03 -04:00
Ryder Belserion e3f10c96ae Update path from me. to com. 2022-06-11 19:45:47 -04:00
Ryder Belserion a16abdbaf4 Version bump test. 2022-06-11 18:46:46 -04:00
Ryder Belserion f27867387e Update distribution management 2022-06-11 18:41:40 -04:00
Ryder Belserion 9f2672b4d4
Delete maven.yml 2022-06-10 23:58:48 -04:00
Ryder Belserion c817cb4261
Update maven.yml 2022-06-10 23:57:02 -04:00
Ryder Belserion aa67ec5555
Update maven.yml 2022-06-10 23:55:08 -04:00
Ryder Belserion 23d8e0d808
Update maven.yml 2022-06-10 23:42:59 -04:00
Ryder Belserion 2b5a7b24bf
Delete maven-publish.yml 2022-06-10 23:36:22 -04:00
Ryder Belserion b966ee7c68
Work? 2022-06-10 23:35:29 -04:00
Ryder Belserion 262b6bd970
Create maven.yml 2022-06-10 23:34:24 -04:00
Ryder Belserion c9a0e63346
oops 2022-06-10 23:31:59 -04:00
Ryder Belserion 9b8492873b
Update maven-publish.yml 2022-06-10 23:28:15 -04:00
Ryder Belserion f4f004db1c
Create maven-publish.yml 2022-06-10 23:26:35 -04:00
Ryder Belserion 9b90fb4760
Update README.md 2022-06-06 15:14:39 -04:00
BadBones 8d9ba73247 Grammer changes 2022-04-07 22:05:32 -04:00
BadBones 8ea1e39db8 Updated Spigot in POM 2022-04-07 22:05:26 -04:00
Ryder Belserion 685e1ddbb5
Update README.md 2022-03-08 19:03:21 +00:00
Ryder Belserion 4dc2e41a31
Update README.md 2022-03-07 14:45:15 +00:00
Ryder Belserion beb795da3d
Add in server invites. 2022-02-20 02:35:00 +00:00
Ryder Belserion 123ceced42
Added a notice to the plugin. 2022-02-12 19:03:29 +00:00
Hitosherizu 9efdbd59b6 Revert "Merge pull request #105 from RefusingsPaPa/master"
This reverts commit 8c4867971f.
2022-01-04 12:31:18 -05:00
BadBones69 9f884099d5
Merge pull request #120 from FearGames/master
Async save
2021-09-09 23:02:27 -04:00
Gabriele C 4c1f9d45a3 Merge branch 'badbones69-master' 2021-09-02 21:53:43 +02:00
Gabriele C 0cacf2b914 Resolve merge conflict 2021-09-02 21:53:35 +02:00
Hitosherizu acfa96be43
Merge pull request #135 from HexedHero/1.17
Bump MC version
2021-07-14 23:02:40 -05:00
Hitosherizu 8c4867971f
Merge pull request #105 from RefusingsPaPa/master
Made the plugin use UUIDs rather than names
2021-07-14 23:02:28 -05:00
HexedHero 6936083075 Bump MC version 2021-06-14 21:05:41 +01:00
BadBones69 3e78874a62 Version Bump 2021-03-27 02:44:56 -04:00
BadBones69 1749314fb8
Merge pull request #130 from HexedHero/runnables
Improve runnables
2021-03-27 02:42:25 -04:00
BadBones69 ba90084c4a Added Hex Color Support. 2021-03-27 01:33:01 -04:00
HexedHero 97ebfe21d1 Improve runnables
Don't make a new thread for every player join and only schedule the task
if its the correct name
2021-03-25 14:16:08 +00:00
BadBones69 2ec314f7fe Updated MC to 1.16.5. 2021-01-19 01:16:07 -05:00
Gabriele C ac4b06386d
Merge branch 'master' into master 2020-11-16 22:15:06 +01:00
BadBones69 186ac0f478 Updated MC version. 2020-11-08 01:02:00 -05:00
BadBones69 b4d4929be3
Merge pull request #123 from HexedHero/master
I forgot Netherite Shovel
2020-10-29 23:17:32 -04:00
HexedHero 7d98123dc2 I forgot Netherite Shovel 2020-10-29 21:22:12 +00:00
BadBones69 c644860f3c
Merge pull request #122 from HexedHero/master 2020-10-29 02:22:39 -04:00
HexedHero 78ad21fff9 Added Netherite armor/tools to categories 2020-10-29 02:41:38 +00:00
Gabriele C 57f91cd95f Fix async save on shutdown 2020-10-28 16:11:56 +01:00
Gabriele C f60b738248 Async save 2020-10-17 03:09:37 +02:00
Gabriele C 6a89e20094 Bump version, pom cleanup 2020-10-16 15:26:43 +02:00
BadBones69 4de44321cf Added 1.16.2 Support. 2020-08-18 00:48:40 -04:00
BadBones69 07ae647303 Fixed core issue of book errors.
Fixed:
- Writable and written books that contained illegal unicode that SnakeYAML (inside Spigot/Bukkit) could not save caused an big error. This fixes it by saving to a new Test-File.yml and checks if it was able to be saved and if not denies that book.
2020-06-08 01:30:56 -04:00
BadBones69 8aa9db1fcb Removed depends and Version Bump 2020-05-24 00:54:40 -04:00
BadBones69 4c01a0b4fb Removed Debug message. 2020-05-24 00:54:16 -04:00
BadBones69 a1c0086fe7 Fixed up the book checking code. 2020-05-24 00:30:18 -04:00
BuildTools c9bfa316b6 Made the plugin use UUIDs rather than names 2020-04-14 13:05:45 +01:00
70 changed files with 5211 additions and 3056 deletions

View File

@ -1,26 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug Report] "
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**Versions (please complete the following information):**
- Minecraft Server Version: [e.g. 1.8.8]
- Plugin Version: [e.g. 1.2.12]
*Do **NOT** say Latest use `/version crazyauctions` in the console.
**Pastebin any errors in console**
Link: https://pastebin.com/
**Issue**
Describe the issue you are having with the plugin.
**Screenshots**
If applicable, add screenshots to help explain your problem.

26
.gitignore vendored
View File

@ -1,12 +1,22 @@
build
.gradle
.idea
jars
\.idea/
common/build
paper/build
api/build
*.iml
common/.gradle
api/.gradle
paper/.gradle
*.class
paper/run
target/classes/
target/
\.DS_Store
!paper/run/config
!paper/run/spigot.yml
!paper/run/bukkit.yml
!paper/run/eula.txt
!paper/run/server.properties
!paper/run/plugins
!paper/run/ops.json

5
CHANGELOG.md Normal file
View File

@ -0,0 +1,5 @@
## Changes
* Updated the item builder, What does this mean?
* Custom Items are finally supported
* The item sections in the config.yml have the same capabilities as our other plugins.
* All lores, display names have placeholder api support.

22
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,22 @@
# Contributing to CrazyCrates
Contributions to the project are always welcome, Pull Requests do have some guidelines before being approved.
## You should always create the fork as a personal repository not in an organization.
Any pull request made by a fork in an organization prevents modifications. Everyone has their own way of doing things and rather asking you to change that. A personal fork lets com change the things
that we have a tick about.
If you do not use a personal fork, We have to manually merge your pull request which means it's marked as closed instead of merged.
## Requirements
* `git`
* Java 17 ( Adoptium is recommended )
Pull Requests must be labeled properly according to if it's a bug fix, a new feature or enhancements to the code base.
* `git checkout -b fix/your_fix`
* `git checkout -b feature/your_feature`
* `git checkout -b quality/your_enhancement`
* Commit your changes using `git commit -m 'your commit'`
* Push to your branch using `git push`
* Open a pull request to the `main` branch on our repository to add your change.
You must explain what your pull request is changing and if needed, Supply a video of your change as Pull Requests are a way to get feedback.

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 BadBones69
Copyright (c) 2016-2023 CrazyCrew
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

121
README.md
View File

@ -1,28 +1,101 @@
# Crazy Auctions
Source Code for Crazy Auctions
<br />
## Build Status:
[![Build Status](https://jenkins.badbones69.com/job/Crazy-Auctions/badge/icon)](https://jenkins.badbones69.com/job/Crazy-Auctions/)
## Latest Version:
[![Latest Version](https://img.shields.io/badge/Latest%20Version-1.2.12-blue)](https://github.com/badbones69/Crazy-Auctions/releases/latest)
<div align="center">
## Jenkins:
https://jenkins.badbones69.com/job/Crazy-Auctions/
## Nexus:
https://nexus.badbones69.com/#browse/browse:maven-releases:me%2Fbadbones69%2Fcrazyauctions
[![CrazyAuctions](https://raw.githubusercontent.com/RyderBelserion/Assets/main/crazycrew/webp/CrazyAuctionsBanner.webp)](https://modrinth.com/plugin/crazyauctions)
## Maven:
```xml
<repository>
<id>nexus</id>
<url>https://nexus.badbones69.com/repository/maven-releases/</url>
</repository>
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![GPU License][license-shield]][license-url]
[![Contact][discord-shield]][discord-url]
![CodeFactor][codefactor-shield]
<dependency>
<groupId>me.badbones69</groupId>
<artifactId>crazyauctions</artifactId>
<version>{Latest Version}</version>
</dependency>
```
![Paper](https://cdn.jsdelivr.net/gh/intergrav/devins-badges/assets/compact/supported/paper_vector.svg)
![Purpur](https://cdn.jsdelivr.net/gh/intergrav/devins-badges/assets/compact/supported/purpur_vector.svg)
<p align="center">
A crates plugin that offers quality crates with ease!
<br />
<a href="https://docs.crazycrew.us/crazyauctions/home"><strong>Explore the docs »</strong></a>
<br />
<br />
<a href="https://github.com/Crazy-Crew/CrazyAuctions/issues/new?assignees=ryderbelserion&labels=bug&projects=&template=bugs.yml&title=%5BBug+Report%5D%3A+">Report Bug</a>
·
<a href="https://github.com/Crazy-Crew/CrazyAuctions/issues/new?assignees=&labels=feature&template=feature_request.md&title=%5BFeature%5D+">Request Feature</a>
·
<a href="https://discord.gg/badbones-s-live-chat-182615261403283459">Get Support</a>
</p>
</div>
<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#roadmap">Roadmap</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
</ol>
</details>
### Resource Page
[![Hangar](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/compact/available/hangar_46h.png)](https://hangar.papermc.io/CrazyCrew/CrazyAuctions)
[![Modrinth](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/compact/available/modrinth_46h.png)](https://modrinth.com/user/plugin/CrazyAuctions)
## Getting Started
How to get started with contributing / maintaining your own version of CrazyAuctions!
### Prerequisites
A list of things necessary to make sure you can build CrazyAuctions properly.
* Intellij IDEA
* > https://www.jetbrains.com/idea/download/
* Gradle
### Installation
1. Clone the repo
```sh
git clone https://github.com/Crazy-Crew/CrazyAuctions.git
```
2. Open the repository using Intellij IDEA & wait until it finishes downloading/indexing.
3. Run the clean assemble task.
```gradle
./gradlew clean assemble
```
## Roadmap
Check our public [trello board](https://trello.com/b/bzQ5TwXo) for our current plans, any bugs and general tracking of the project progress.
## Contributing
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/yourfeature`)
3. Commit your Changes (`git commit -m 'your amazing feature.'`)
4. Push to the Branch (`git push`)
5. Open a Pull Request to the `main` branch to add your feature/fix.
## License
Distributed under the MIT License. See [`LICENSE`](/LICENSE) for more information.
[discord-shield]: https://img.shields.io/discord/182615261403283459.svg?style=flat&logo=appveyor
[discord-url]: https://discord.gg/badbones-s-live-chat-182615261403283459
[contributors-shield]: https://img.shields.io/github/contributors/Crazy-Crew/CrazyAuctions.svg?style=flat&logo=appveyor
[contributors-url]: https://github.com/Crazy-Crew/CrazyAuctions/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/Crazy-Crew/CrazyAuctions.svg?style=flat&logo=appveyor
[forks-url]: https://github.com/Crazy-Crew/CrazyAuctions/network/members
[stars-shield]: https://img.shields.io/github/stars/Crazy-Crew/CrazyAuctions.svg?style=flat&logo=appveyor
[stars-url]: https://github.com/Crazy-Crew/CrazyAuctions/stargazers
[issues-shield]: https://img.shields.io/github/issues/Crazy-Crew/CrazyAuctions.svg?style=flat&logo=appveyor
[issues-url]: https://github.com/Crazy-Crew/CrazyAuctions/issues
[license-shield]: https://img.shields.io/github/license/Crazy-Crew/CrazyAuctions.svg?style=flat&logo=appveyor
[license-url]: https://github.com/Crazy-Crew/CrazyAuctions/blob/master/LICENSE
[codefactor-shield]: https://img.shields.io/codefactor/grade/github/crazy-crew/CrazyAuctions/main?style=flat&logo=appveyor

40
build.gradle.kts Normal file
View File

@ -0,0 +1,40 @@
import org.gradle.kotlin.dsl.support.uppercaseFirstChar
plugins {
`root-plugin`
}
tasks {
assemble {
val jarsDir = File("$rootDir/jars")
doFirst {
delete(jarsDir)
jarsDir.mkdirs()
}
subprojects.filter { it.name == "paper" || it.name == "fabric" }.forEach { project ->
dependsOn(":${project.name}:build")
doLast {
runCatching {
val file = File("$jarsDir/${project.name.uppercaseFirstChar().lowercase()}")
file.mkdirs()
copy {
from(project.layout.buildDirectory.file("libs/${rootProject.name}-${project.version}.jar"))
into(file)
}
}.onSuccess {
// Delete to save space on jenkins.
delete(project.layout.buildDirectory.get())
delete(rootProject.layout.buildDirectory.get())
}.onFailure {
println("Failed to copy file out of build folder into jars directory: Likely does not exist.")
}
}
}
}
}

14
buildSrc/build.gradle.kts Normal file
View File

@ -0,0 +1,14 @@
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
implementation(libs.paperweight.userdev)
implementation(libs.publishing.modrinth)
implementation(libs.publishing.hangar)
}

View File

@ -0,0 +1,9 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
rootProject.name = "buildSrc"

View File

@ -0,0 +1,14 @@
plugins {
id("root-plugin")
}
val mcVersion = providers.gradleProperty("mcVersion").get()
val fabricVersion = providers.gradleProperty("version").get()
project.version = if (System.getenv("BUILD_NUMBER") != null) "$fabricVersion-${System.getenv("BUILD_NUMBER")}" else fabricVersion
tasks {
modrinth {
loaders.addAll("fabric")
}
}

View File

@ -0,0 +1,27 @@
plugins {
id("root-plugin")
}
repositories {
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.codemc.io/repository/maven-public/")
maven("https://repo.triumphteam.dev/snapshots/")
maven("https://repo.fancyplugins.de/releases/")
flatDir { dirs("libs") }
}
val mcVersion = providers.gradleProperty("mcVersion").get()
project.version = if (System.getenv("BUILD_NUMBER") != null) "${rootProject.version}-${System.getenv("BUILD_NUMBER")}" else rootProject.version
tasks {
modrinth {
loaders.addAll("paper", "purpur")
}
}

View File

@ -0,0 +1,93 @@
import io.papermc.hangarpublishplugin.model.Platforms
plugins {
id("io.papermc.hangar-publish-plugin")
id("com.modrinth.minotaur")
`java-library`
`maven-publish`
}
base {
archivesName.set(rootProject.name)
}
repositories {
maven("https://repo.crazycrew.us/snapshots/")
maven("https://repo.crazycrew.us/releases/")
maven("https://jitpack.io/")
mavenCentral()
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of("17"))
}
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
val directory = File("$rootDir/jars/${project.name.lowercase()}")
val mcVersion = providers.gradleProperty("mcVersion").get()
val isBeta: Boolean = providers.gradleProperty("isBeta").get().toBoolean()
val type = if (isBeta) "Beta" else "Release"
// Publish to hangar.papermc.io.
hangarPublish {
publications.register("plugin") {
version.set("${project.version}")
id.set(rootProject.name)
channel.set(type)
changelog.set(rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8))
apiKey.set(System.getenv("hangar_key"))
platforms {
register(Platforms.PAPER) {
jar.set(file("$directory/${rootProject.name}-${project.version}.jar"))
platformVersions.set(listOf(mcVersion))
}
}
}
}
modrinth {
versionType.set(type.lowercase())
autoAddDependsOn.set(false)
token.set(System.getenv("modrinth_token"))
projectId.set(rootProject.name.lowercase())
changelog.set(rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8))
versionName.set("${rootProject.name} ${project.version}")
versionNumber.set("${project.version}")
uploadFile.set("$directory/${rootProject.name}-${project.version}.jar")
gameVersions.add(mcVersion)
}
}

13
common/build.gradle.kts Normal file
View File

@ -0,0 +1,13 @@
plugins {
id("root-plugin")
}
dependencies {
compileOnlyApi(libs.bundles.adventure)
compileOnly(libs.cluster.api)
api(libs.configme) {
exclude(group = "org.yaml", module = "snakeyaml")
}
}

View File

@ -0,0 +1,53 @@
package com.ryderbelserion.crazyauctions;
import ch.jalu.configme.SettingsManager;
import ch.jalu.configme.SettingsManagerBuilder;
import ch.jalu.configme.resource.YamlFileResourceOptions;
import com.ryderbelserion.crazyauctions.platform.impl.Config;
import com.ryderbelserion.crazyauctions.platform.Server;
import java.io.File;
public class CrazyAuctions {
private final Server server;
private final SettingsManager config;
public CrazyAuctions(Server server) {
this.server = server;
// Create config files
YamlFileResourceOptions builder = YamlFileResourceOptions.builder().indentationSize(2).build();
this.config = SettingsManagerBuilder
.withYamlFile(new File(server.getFolder(), "config.yml"), builder)
.useDefaultMigrationService()
.configurationData(Config.class)
.create();
// Register provider.
CrazyProvider.register(this);
}
public void reload() {
// Reload the config.
this.config.reload();
}
public void disable() {
// Save the config.
this.config.save();
// Unregister provider.
CrazyProvider.unregister();
}
public Server getServer() {
return this.server;
}
public SettingsManager getConfig() {
return this.config;
}
}

View File

@ -0,0 +1,30 @@
package com.ryderbelserion.crazyauctions;
public final class CrazyProvider {
private static CrazyAuctions instance;
private CrazyProvider() {
throw new UnsupportedOperationException("This class cannot be instantiated");
}
public static CrazyAuctions get() {
if (instance == null) {
throw new IllegalStateException("CrazyAuctions is not loaded.");
}
return instance;
}
static void register(final CrazyAuctions instance) {
if (get() != null) {
return;
}
CrazyProvider.instance = instance;
}
static void unregister() {
CrazyProvider.instance = null;
}
}

View File

@ -0,0 +1,9 @@
package com.ryderbelserion.crazyauctions.platform;
import java.io.File;
public interface Server {
File getFolder();
}

View File

@ -0,0 +1,41 @@
package com.ryderbelserion.crazyauctions.platform.impl;
import ch.jalu.configme.Comment;
import ch.jalu.configme.SettingsHolder;
import ch.jalu.configme.configurationdata.CommentsConfiguration;
import ch.jalu.configme.properties.Property;
import org.jetbrains.annotations.NotNull;
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
public class Config implements SettingsHolder {
@Override
public void registerComments(@NotNull CommentsConfiguration conf) {
String[] header = {
"Support: https://discord.gg/badbones-s-live-chat-182615261403283459",
"Github: https://github.com/Crazy-Crew",
"",
"Issues: https://github.com/Crazy-Crew/CrazyAuctions/issues",
"Features: https://github.com/Crazy-Crew/CrazyAuctions/issues",
"",
"Sounds: https://jd.papermc.io/paper/1.20/org/bukkit/Sound.html",
"Enchantments: https://jd.papermc.io/paper/1.20/org/bukkit/enchantments/Enchantment.html"
};
conf.setComment("root", header);
}
@Comment("Whether you want CrazyAuctions to shut up or not.")
public static final Property<Boolean> verbose_logging = newProperty("root.verbose_logging", true);
@Comment({
"Sends anonymous statistics about how the plugin is used to bstats.org.",
"bstats is a service for plugin developers to find out how the plugin being used,",
"This information helps us figure out how to better improve the plugin."
})
public static final Property<Boolean> toggle_metrics = newProperty("root.toggle_metrics", true);
@Comment("The prefix that appears in front of messages.")
public static final Property<String> prefix = newProperty("root.prefix", "<dark_gray>[<blue>CrazyAuctions<dark_gray>]: ");
}

17
gradle.properties Normal file
View File

@ -0,0 +1,17 @@
org.gradle.jvmargs = '-Xmx3G'
org.gradle.caching = true
org.gradle.parallel = true
org.gradle.warning.mode = all
authors = ["Ryderbelserion, Badbones69"]
website = https://modrinth.com/plugin/crazyauctions
sources = https://github.com/Crazy-Crew/CrazyAuctions
issues = https://github.com/Crazy-Crew/CrazyAuctions/issues
group = com.badbones69.crazyauctions
description = Auction off items in style.
version = 1.4
apiVersion = 1.20
mcVersion = 1.20.4
isBeta = true

41
gradle/libs.versions.toml Normal file
View File

@ -0,0 +1,41 @@
[plugins]
run-paper = { id = "xyz.jpenilla.run-paper", version = "2.2.3" }
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
[versions]
kyori = "4.16.0"
bundle = "1.20.4-R0.1-SNAPSHOT"
cluster = "1.0-SNAPSHOT"
[libraries]
simple-yaml = { group = "com.github.Carleslc.Simple-YAML", name = "Simple-Yaml", version = "1.8.4" }
minimessage-api = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "kyori" }
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "kyori" }
itemsadder-api = { group = "com.github.LoneDev6", name = "api-itemsadder", version = "3.6.1" }
oraxen-api = { group = "io.th0rgal", name = "oraxen", version = "1.171.0" }
placeholder-api = { group = "me.clip", name = "placeholderapi", version = "2.11.5" }
head-database-api = { group = "com.arcaniax", name = "HeadDatabase-API", version = "1.3.1" }
paperweight-userdev = { group = "io.papermc.paperweight.userdev", name = "io.papermc.paperweight.userdev.gradle.plugin", version = "1.5.11" }
publishing-modrinth = { group = "com.modrinth.minotaur", name = "Minotaur", version = "2.8.7" }
publishing-hangar = { group = "io.papermc", name = "hangar-publish-plugin", version = "0.1.2" }
cluster-api = { group = "com.ryderbelserion.cluster", name = "api", version.ref = "cluster" }
cluster-paper = { group = "com.ryderbelserion.cluster", name = "paper", version.ref = "cluster" }
fancy-holograms = { group = "de.oliver", name = "FancyHolograms", version = "2.0.6" }
decent-holograms = { group = "com.github.decentsoftware-eu", name = "decentholograms", version = "2.8.6" }
triumph-cmds = { group = "dev.triumphteam", name = "triumph-cmd-bukkit", version = "2.0.0-ALPHA-9" }
triumph-gui = { group = "dev.triumphteam", name = "triumph-gui", version = "3.1.7" }
vault = { group = "com.github.MilkBowl", name = "VaultAPI", version = "1.7.1" }
metrics = { group = "org.bstats", name = "bstats-bukkit", version = "3.0.2" }
config-me = { group = "ch.jalu", name = "configme", version = "1.4.1" }
[bundles]
adventure = ["minimessage-api", "adventure-api"]
holograms = ["fancy-holograms", "decent-holograms"]
triumph = ["triumph-cmds", "triumph-gui"]

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

249
gradlew vendored Normal file
View File

@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

77
paper/build.gradle.kts Normal file
View File

@ -0,0 +1,77 @@
plugins {
`paper-plugin`
id("io.papermc.paperweight.userdev")
alias(libs.plugins.run.paper)
alias(libs.plugins.shadow)
}
repositories {
maven("https://repo.oraxen.com/releases/")
}
dependencies {
paperweight.paperDevBundle(libs.versions.bundle)
implementation(libs.metrics)
compileOnly(libs.placeholder.api)
compileOnly(libs.oraxen.api)
compileOnly(libs.vault)
compileOnly(fileTree("libs").include("*.jar"))
}
tasks {
assemble {
dependsOn(reobfJar)
}
runServer {
jvmArgs("-Dnet.kyori.ansi.colorLevel=truecolor")
defaultCharacterEncoding = Charsets.UTF_8.name()
downloadPlugins {
url("https://github.com/EssentialsX/Essentials/releases/download/2.20.1/EssentialsX-2.20.1.jar")
url("https://ci.lucko.me/job/TinyVault/lastSuccessfulBuild/artifact/build/libs/Vault.jar")
url("https://download.luckperms.net/1532/bukkit/loader/LuckPerms-Bukkit-5.4.119.jar")
}
minecraftVersion("1.20.4")
}
shadowJar {
listOf(
//"com.ryderbelserion.cluster",
//"dev.triumphteam.cmd",
//"dev.triumphteam.gui",
"org.bstats"
).forEach {
relocate(it, "libs.$it")
}
}
processResources {
val properties = hashMapOf(
"name" to rootProject.name,
"version" to project.version,
"group" to rootProject.group,
"description" to rootProject.description,
"apiVersion" to providers.gradleProperty("apiVersion").get(),
"authors" to providers.gradleProperty("authors").get(),
"website" to providers.gradleProperty("website").get()
)
inputs.properties(properties)
filesMatching("plugin.yml") {
expand(properties)
}
}
}

BIN
paper/libs/Cluster-6.5.jar Normal file

Binary file not shown.

32
paper/run/bukkit.yml Normal file
View File

@ -0,0 +1,32 @@
settings:
allow-end: false
warn-on-overload: false
permissions-file: permissions.yml
update-folder: update
plugin-profiling: false
connection-throttle: 4000
query-plugins: false
deprecated-verbose: default
shutdown-message: Server Closed
minimum-api: none
use-map-color-cache: true
spawn-limits:
monsters: 70
animals: 10
water-animals: 5
water-ambient: 20
water-underground-creature: 5
axolotls: 5
ambient: 15
chunk-gc:
period-in-ticks: 600
ticks-per:
animal-spawns: 400
monster-spawns: 1
water-spawns: 1
water-ambient-spawns: 1
water-underground-creature-spawns: 1
axolotl-spawns: 1
ambient-spawns: 1
autosave: 6000
aliases: now-in-commands.yml

View File

@ -0,0 +1,130 @@
# This is the global configuration file for Paper.
# As you can see, there's a lot to configure. Some options may impact gameplay, so use
# with caution, and make sure you know what each option does before configuring.
#
# If you need help with the configuration or have any questions related to Paper,
# join us in our Discord or check the docs page.
#
# The world configuration options have been moved inside
# their respective world folder. The files are named paper-world.yml
#
# Docs: https://docs.papermc.io/
# Discord: https://discord.gg/papermc
# Website: https://papermc.io/
_version: 29
block-updates:
disable-chorus-plant-updates: false
disable-mushroom-block-updates: false
disable-noteblock-updates: false
disable-tripwire-updates: false
chunk-loading-advanced:
auto-config-send-distance: true
player-max-concurrent-chunk-generates: 0
player-max-concurrent-chunk-loads: 0
chunk-loading-basic:
player-max-chunk-generate-rate: -1.0
player-max-chunk-load-rate: 100.0
player-max-chunk-send-rate: 75.0
chunk-system:
gen-parallelism: default
io-threads: -1
worker-threads: -1
collisions:
enable-player-collisions: true
send-full-pos-for-hard-colliding-entities: true
commands:
fix-target-selector-tag-completion: true
suggest-player-names-when-null-tab-completions: true
time-command-affects-all-worlds: false
console:
enable-brigadier-completions: true
enable-brigadier-highlighting: true
has-all-permissions: false
item-validation:
book:
author: 8192
page: 16384
title: 8192
book-size:
page-max: 2560
total-multiplier: 0.98
display-name: 8192
lore-line: 8192
resolve-selectors-in-books: false
logging:
deobfuscate-stacktraces: true
messages:
kick:
authentication-servers-down: <lang:multiplayer.disconnect.authservers_down>
connection-throttle: Connection throttled! Please wait before reconnecting.
flying-player: <lang:multiplayer.disconnect.flying>
flying-vehicle: <lang:multiplayer.disconnect.flying>
no-permission: <red>I'm sorry, but you do not have permission to perform this command.
Please contact the server administrators if you believe that this is in error.
use-display-name-in-quit-message: false
misc:
chat-threads:
chat-executor-core-size: -1
chat-executor-max-size: -1
compression-level: default
fix-entity-position-desync: true
load-permissions-yml-before-plugins: true
max-joins-per-tick: 5
region-file-cache-size: 256
strict-advancement-dimension-check: false
use-alternative-luck-formula: false
use-dimension-type-for-custom-spawners: false
packet-limiter:
all-packets:
action: KICK
interval: 7.0
max-packet-rate: 500.0
kick-message: <red><lang:disconnect.exceeded_packet_rate>
overrides:
ServerboundPlaceRecipePacket:
action: DROP
interval: 4.0
max-packet-rate: 5.0
player-auto-save:
max-per-tick: -1
rate: -1
proxies:
bungee-cord:
online-mode: false
proxy-protocol: false
velocity:
enabled: false
online-mode: false
secret: ''
scoreboards:
save-empty-scoreboard-teams: false
track-plugin-scoreboards: false
spam-limiter:
incoming-packet-threshold: 300
recipe-spam-increment: 1
recipe-spam-limit: 20
tab-spam-increment: 1
tab-spam-limit: 500
timings:
enabled: false
hidden-config-entries:
- database
- proxies.velocity.secret
history-interval: 300
history-length: 3600
server-name: Unknown Server
server-name-privacy: false
url: https://timings.aikar.co/
verbose: false
unsupported-settings:
allow-grindstone-overstacking: false
allow-headless-pistons: false
allow-permanent-block-break-exploits: false
allow-piston-duplication: false
allow-unsafe-end-portal-teleportation: false
compression-format: ZLIB
perform-username-validation: true
watchdog:
early-warning-delay: 10000
early-warning-every: 5000

View File

@ -0,0 +1,316 @@
# This is the world defaults configuration file for Paper.
# As you can see, there's a lot to configure. Some options may impact gameplay, so use
# with caution, and make sure you know what each option does before configuring.
#
# If you need help with the configuration or have any questions related to Paper,
# join us in our Discord or check the docs page.
#
# Configuration options here apply to all worlds, unless you specify overrides inside
# the world-specific config file inside each world folder.
#
# Docs: https://docs.papermc.io/
# Discord: https://discord.gg/papermc
# Website: https://papermc.io/
_version: 30
anticheat:
anti-xray:
enabled: false
engine-mode: 1
hidden-blocks:
- copper_ore
- deepslate_copper_ore
- gold_ore
- deepslate_gold_ore
- iron_ore
- deepslate_iron_ore
- coal_ore
- deepslate_coal_ore
- lapis_ore
- deepslate_lapis_ore
- mossy_cobblestone
- obsidian
- chest
- diamond_ore
- deepslate_diamond_ore
- redstone_ore
- deepslate_redstone_ore
- clay
- emerald_ore
- deepslate_emerald_ore
- ender_chest
lava-obscures: false
max-block-height: 64
replacement-blocks:
- stone
- oak_planks
- deepslate
update-radius: 2
use-permission: false
obfuscation:
items:
hide-durability: false
hide-itemmeta: false
hide-itemmeta-with-visual-effects: false
chunks:
auto-save-interval: default
delay-chunk-unloads-by: 10s
entity-per-chunk-save-limit:
arrow: -1
ender_pearl: -1
experience_orb: -1
fireball: -1
small_fireball: -1
snowball: -1
fixed-chunk-inhabited-time: -1
flush-regions-on-save: false
max-auto-save-chunks-per-tick: 24
prevent-moving-into-unloaded-chunks: false
collisions:
allow-player-cramming-damage: false
allow-vehicle-collisions: true
fix-climbing-bypassing-cramming-rule: false
max-entity-collisions: 8
only-players-collide: false
command-blocks:
force-follow-perm-level: true
permissions-level: 2
entities:
armor-stands:
do-collision-entity-lookups: true
tick: true
behavior:
allow-spider-world-border-climbing: true
baby-zombie-movement-modifier: 0.5
disable-chest-cat-detection: false
disable-creeper-lingering-effect: false
disable-player-crits: false
door-breaking-difficulty:
husk:
- HARD
vindicator:
- NORMAL
- HARD
zombie:
- HARD
zombie_villager:
- HARD
zombified_piglin:
- HARD
ender-dragons-death-always-places-dragon-egg: false
experience-merge-max-value: -1
mobs-can-always-pick-up-loot:
skeletons: false
zombies: false
nerf-pigmen-from-nether-portals: false
parrots-are-unaffected-by-player-movement: false
phantoms-do-not-spawn-on-creative-players: true
phantoms-only-attack-insomniacs: true
phantoms-spawn-attempt-max-seconds: 119
phantoms-spawn-attempt-min-seconds: 60
piglins-guard-chests: true
pillager-patrols:
disable: false
spawn-chance: 0.2
spawn-delay:
per-player: false
ticks: 12000
start:
day: 5
per-player: false
player-insomnia-start-ticks: 72000
should-remove-dragon: false
spawner-nerfed-mobs-should-jump: false
zombie-villager-infection-chance: default
zombies-target-turtle-eggs: true
entities-target-with-follow-range: false
markers:
tick: true
mob-effects:
immune-to-wither-effect:
wither: true
wither-skeleton: true
spiders-immune-to-poison-effect: true
undead-immune-to-certain-effects: true
sniffer:
boosted-hatch-time: default
hatch-time: default
spawning:
all-chunks-are-slime-chunks: false
alt-item-despawn-rate:
enabled: false
items:
cobblestone: 300
count-all-mobs-for-spawning: false
creative-arrow-despawn-rate: default
despawn-ranges:
ambient:
hard: 128
soft: 32
axolotls:
hard: 128
soft: 32
creature:
hard: 128
soft: 32
misc:
hard: 128
soft: 32
monster:
hard: 128
soft: 32
underground_water_creature:
hard: 128
soft: 32
water_ambient:
hard: 64
soft: 32
water_creature:
hard: 128
soft: 32
disable-mob-spawner-spawn-egg-transformation: false
duplicate-uuid:
mode: SAFE_REGEN
safe-regen-delete-range: 32
filter-bad-tile-entity-nbt-from-falling-blocks: true
filtered-entity-tag-nbt-paths:
- Pos
- Motion
- SleepingX
- SleepingY
- SleepingZ
iron-golems-can-spawn-in-air: false
monster-spawn-max-light-level: default
non-player-arrow-despawn-rate: default
per-player-mob-spawns: true
scan-for-legacy-ender-dragon: true
skeleton-horse-thunder-spawn-chance: default
slime-spawn-height:
slime-chunk:
maximum: 40.0
surface-biome:
maximum: 70.0
minimum: 50.0
spawn-limits:
ambient: -1
axolotls: -1
creature: -1
monster: -1
underground_water_creature: -1
water_ambient: -1
water_creature: -1
ticks-per-spawn:
ambient: -1
axolotls: -1
creature: -1
monster: -1
underground_water_creature: -1
water_ambient: -1
water_creature: -1
wandering-trader:
spawn-chance-failure-increment: 25
spawn-chance-max: 75
spawn-chance-min: 25
spawn-day-length: 24000
spawn-minute-length: 1200
wateranimal-spawn-height:
maximum: default
minimum: default
tracking-range-y:
animal: default
display: default
enabled: false
misc: default
monster: default
other: default
player: default
environment:
disable-explosion-knockback: false
disable-ice-and-snow: false
disable-teleportation-suffocation-check: false
disable-thunder: false
fire-tick-delay: 30
frosted-ice:
delay:
max: 40
min: 20
enabled: true
generate-flat-bedrock: false
max-block-ticks: 65536
max-fluid-ticks: 65536
nether-ceiling-void-damage-height: disabled
optimize-explosions: false
portal-create-radius: 16
portal-search-radius: 128
portal-search-vanilla-dimension-scaling: true
treasure-maps:
enabled: true
find-already-discovered:
loot-tables: default
villager-trade: false
water-over-lava-flow-speed: 5
feature-seeds:
generate-random-seeds-for-all: false
fishing-time-range:
maximum: 600
minimum: 100
fixes:
disable-unloaded-chunk-enderpearl-exploit: true
falling-block-height-nerf: disabled
fix-items-merging-through-walls: false
prevent-tnt-from-moving-in-water: false
split-overstacked-loot: true
tnt-entity-height-nerf: disabled
hopper:
cooldown-when-full: true
disable-move-event: false
ignore-occluding-blocks: false
lootables:
auto-replenish: false
max-refills: -1
refresh-max: 2d
refresh-min: 12h
reset-seed-on-fill: true
restrict-player-reloot: true
restrict-player-reloot-time: disabled
maps:
item-frame-cursor-limit: 128
item-frame-cursor-update-interval: 10
max-growth-height:
bamboo:
max: 16
min: 11
cactus: 3
reeds: 3
misc:
disable-end-credits: false
disable-relative-projectile-velocity: false
disable-sprint-interruption-on-attack: false
light-queue-size: 20
max-leash-distance: 10.0
redstone-implementation: VANILLA
shield-blocking-delay: 5
show-sign-click-command-failure-msgs-to-player: false
update-pathfinding-on-block-update: true
scoreboards:
allow-non-player-entities-on-scoreboards: true
use-vanilla-world-scoreboard-name-coloring: false
spawn:
allow-using-signs-inside-spawn-protection: false
keep-spawn-loaded: true
keep-spawn-loaded-range: 10
tick-rates:
behavior:
villager:
validatenearbypoi: -1
container-update: 1
dry-farmland: 1
grass-spread: 1
mob-spawner: 1
sensor:
villager:
secondarypoisensor: 40
wet-farmland: 1
unsupported-settings:
disable-world-ticking-when-empty: false
fix-invulnerable-end-crystal-exploit: true

3
paper/run/eula.txt Normal file
View File

@ -0,0 +1,3 @@
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
#Mon Oct 16 20:19:20 EDT 2023
eula=true

14
paper/run/ops.json Normal file
View File

@ -0,0 +1,14 @@
[
{
"uuid": "45123240-248b-44e3-93c9-5c89093ffaad",
"name": "Asruna",
"level": 4,
"bypassesPlayerLimit": false
},
{
"uuid": "64ccbf4e-87d2-490f-9370-8c4e53df9013",
"name": "Rukkhadevata",
"level": 4,
"bypassesPlayerLimit": false
}
]

View File

@ -0,0 +1,61 @@
#Minecraft server properties
#Sun Mar 24 11:23:50 EDT 2024
enable-jmx-monitoring=false
rcon.port=25575
level-seed=
gamemode=survival
enable-command-block=false
enable-query=false
generator-settings={}
enforce-secure-profile=true
level-name=world
motd=A test server
query.port=25565
pvp=true
generate-structures=true
max-chained-neighbor-updates=1000000
difficulty=peaceful
network-compression-threshold=256
max-tick-time=60000
require-resource-pack=false
use-native-transport=true
max-players=5
online-mode=true
enable-status=true
allow-flight=false
initial-disabled-packs=
broadcast-rcon-to-ops=false
view-distance=6
server-ip=
resource-pack-prompt=
allow-nether=false
server-port=25565
enable-rcon=false
sync-chunk-writes=false
resource-pack-id=
op-permission-level=4
prevent-proxy-connections=false
hide-online-players=false
resource-pack=
entity-broadcast-range-percentage=100
simulation-distance=10
rcon.password=
player-idle-timeout=0
debug=false
force-gamemode=false
rate-limit=0
hardcore=false
white-list=false
broadcast-console-to-ops=false
spawn-npcs=true
spawn-animals=true
log-ips=false
function-permission-level=2
initial-enabled-packs=vanilla
level-type=minecraft\:normal
text-filtering-config=
spawn-monsters=true
enforce-whitelist=false
spawn-protection=32
resource-pack-sha1=
max-world-size=29999984

178
paper/run/spigot.yml Normal file
View File

@ -0,0 +1,178 @@
# This is the main configuration file for Spigot.
# As you can see, there's tons to configure. Some options may impact gameplay, so use
# with caution, and make sure you know what each option does before configuring.
# For a reference for any variable inside this file, check out the Spigot wiki at
# http://www.spigotmc.org/wiki/spigot-configuration/
#
# If you need help with the configuration or have any questions related to Spigot,
# join us at the Discord or drop by our forums and leave a post.
#
# Discord: https://www.spigotmc.org/go/discord
# Forums: http://www.spigotmc.org/
settings:
debug: false
timeout-time: 60
restart-on-crash: false
restart-script: ./start.sh
save-user-cache-on-stop-only: false
moved-too-quickly-multiplier: 10.0
moved-wrongly-threshold: 0.0625
player-shuffle: 0
user-cache-size: 1000
netty-threads: 4
attribute:
maxHealth:
max: 2048.0
movementSpeed:
max: 2048.0
attackDamage:
max: 2048.0
log-villager-deaths: false
log-named-deaths: false
sample-count: 12
bungeecord: false
messages:
restart: Server is restarting
whitelist: You are not whitelisted on this server!
unknown-command: Unknown command. Type "/help" for help.
server-full: The server is full!
outdated-client: Outdated client! Please use {0}
outdated-server: Outdated server! I'm still on {0}
advancements:
disable-saving: true
disabled:
- minecraft:story/disabled
commands:
silent-commandblock-console: false
spam-exclusions:
- /skill
replace-commands:
- setblock
- summon
- testforblock
- tellraw
log: true
tab-complete: 0
send-namespaced: true
players:
disable-saving: false
world-settings:
default:
seed-trialchambers: 94251327
below-zero-generation-in-existing-chunks: true
hanging-tick-frequency: 100
dragon-death-sound-radius: 0
wither-spawn-sound-radius: 0
end-portal-sound-radius: 0
zombie-aggressive-towards-villager: true
entity-activation-range:
animals: 32
monsters: 32
raiders: 48
misc: 16
water: 16
villagers: 32
flying-monsters: 32
wake-up-inactive:
animals-max-per-tick: 4
animals-every: 1200
animals-for: 100
monsters-max-per-tick: 8
monsters-every: 400
monsters-for: 100
villagers-max-per-tick: 4
villagers-every: 600
villagers-for: 100
flying-monsters-max-per-tick: 8
flying-monsters-every: 200
flying-monsters-for: 100
villagers-work-immunity-after: 100
villagers-work-immunity-for: 20
villagers-active-for-panic: true
tick-inactive-villagers: true
ignore-spectators: false
seed-village: 10387312
seed-desert: 14357617
seed-igloo: 14357618
seed-jungle: 14357619
seed-swamp: 14357620
seed-monument: 10387313
seed-shipwreck: 165745295
seed-ocean: 14357621
seed-outpost: 165745296
seed-endcity: 10387313
seed-slime: 987234911
seed-nether: 30084232
seed-mansion: 10387319
seed-fossil: 14357921
seed-portal: 34222645
seed-ancientcity: 20083232
seed-trailruins: 83469867
seed-buriedtreasure: 10387320
seed-mineshaft: default
seed-stronghold: default
entity-tracking-range:
players: 48
animals: 48
monsters: 48
misc: 32
display: 128
other: 64
ticks-per:
hopper-transfer: 8
hopper-check: 1
hopper-amount: 1
hopper-can-load-chunks: false
max-tnt-per-tick: 100
max-tick-time:
tile: 50
entity: 50
hunger:
jump-walk-exhaustion: 0.05
jump-sprint-exhaustion: 0.2
combat-exhaustion: 0.1
regen-exhaustion: 6.0
swim-multiplier: 0.01
sprint-multiplier: 0.1
other-multiplier: 0.0
enable-zombie-pigmen-portal-spawns: true
thunder-chance: 100000
growth:
cactus-modifier: 100
cane-modifier: 100
melon-modifier: 100
mushroom-modifier: 100
pumpkin-modifier: 100
sapling-modifier: 100
beetroot-modifier: 100
carrot-modifier: 100
potato-modifier: 100
torchflower-modifier: 100
wheat-modifier: 100
netherwart-modifier: 100
vine-modifier: 100
cocoa-modifier: 100
bamboo-modifier: 100
sweetberry-modifier: 100
kelp-modifier: 100
twistingvines-modifier: 100
weepingvines-modifier: 100
cavevines-modifier: 100
glowberry-modifier: 100
pitcherplant-modifier: 100
mob-spawn-range: 8
simulation-distance: default
merge-radius:
item: 2.5
exp: 3.0
arrow-despawn-rate: 1200
trident-despawn-rate: 1200
view-distance: default
item-despawn-rate: 6000
nerf-spawner-mobs: false
verbose: false
config-version: 12
stats:
disable-saving: false
forced-stats: {}

View File

@ -0,0 +1,123 @@
package com.badbones69.crazyauctions;
import com.badbones69.crazyauctions.api.CrazyManager;
import com.badbones69.crazyauctions.api.FileManager;
import com.badbones69.crazyauctions.api.enums.Messages;
import com.badbones69.crazyauctions.api.support.PluginSupport;
import com.badbones69.crazyauctions.api.support.metrics.MetricsWrapper;
import com.badbones69.crazyauctions.commands.AuctionCommand;
import com.badbones69.crazyauctions.commands.AuctionTab;
import com.badbones69.crazyauctions.controllers.GuiListener;
import com.badbones69.crazyauctions.controllers.MarcoListener;
import com.badbones69.crazyauctions.currency.VaultSupport;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.util.Timer;
import java.util.TimerTask;
public class CrazyAuctions extends JavaPlugin {
@NotNull
public static CrazyAuctions get() {
return JavaPlugin.getPlugin(CrazyAuctions.class);
}
private Timer timer;
private FileManager fileManager;
private CrazyManager crazyManager;
private VaultSupport support;
private MetricsWrapper metrics;
@Override
public void onEnable() {
if (!PluginSupport.VAULT.isPluginEnabled()) {
getLogger().severe("Vault was not found so the plugin will now disable.");
getServer().getPluginManager().disablePlugin(this);
return;
}
this.timer = new Timer();
this.fileManager = new FileManager();
this.crazyManager = new CrazyManager();
this.fileManager.setup();
this.crazyManager.load();
getServer().getPluginManager().registerEvents(new GuiListener(), this);
getServer().getPluginManager().registerEvents(new MarcoListener(), this);
registerCommand(getCommand("crazyauctions"), new AuctionTab(), new AuctionCommand());
// Run a task every 5 seconds to update auctions.
TimerTask task = new TimerTask() {
@Override
public void run() {
getServer().getScheduler().runTask(get(), Methods::updateAuction);
}
};
this.timer.scheduleAtFixedRate(task, 20L, 5000L);
// Add new messages.
Messages.addMissingMessages();
// Enable vault support if enabled.
this.support = new VaultSupport();
support.loadVault();
// Create bstats instance.
this.metrics = new MetricsWrapper();
this.metrics.start();
}
private void registerCommand(PluginCommand pluginCommand, TabCompleter tabCompleter, CommandExecutor commandExecutor) {
if (pluginCommand != null) {
pluginCommand.setExecutor(commandExecutor);
if (tabCompleter != null) pluginCommand.setTabCompleter(tabCompleter);
}
}
@Override
public void onDisable() {
if (this.timer != null) this.timer.cancel();
if (this.crazyManager != null) this.crazyManager.unload();
}
@NotNull
public Timer getTimer() {
return this.timer;
}
public VaultSupport getSupport() {
return this.support;
}
public MetricsWrapper getMetrics() {
return this.metrics;
}
@NotNull
public CrazyManager getCrazyManager() {
return this.crazyManager;
}
@NotNull
public FileManager getFileManager() {
return this.fileManager;
}
public boolean isLogging() {
return true;
}
}

View File

@ -1,12 +1,9 @@
package me.badbones69.crazyauctions;
package com.badbones69.crazyauctions;
import me.badbones69.crazyauctions.api.FileManager;
import me.badbones69.crazyauctions.api.FileManager.Files;
import me.badbones69.crazyauctions.api.Messages;
import me.badbones69.crazyauctions.api.Version;
import me.badbones69.crazyauctions.api.events.AuctionExpireEvent;
import me.badbones69.crazyauctions.api.events.AuctionWinBidEvent;
import me.badbones69.crazyauctions.currency.CurrencyManager;
import com.badbones69.crazyauctions.api.FileManager.Files;
import com.badbones69.crazyauctions.api.enums.Messages;
import com.badbones69.crazyauctions.api.events.AuctionExpireEvent;
import com.badbones69.crazyauctions.api.events.AuctionWinBidEvent;
import org.bukkit.*;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
@ -14,17 +11,25 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Methods {
private final static CrazyAuctions plugin = CrazyAuctions.get();
private final static Pattern HEX_PATTERN = Pattern.compile("#[a-fA-F0-9]{6}");
public static Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions");
private static FileManager fileManager = FileManager.getInstance();
public static String color(String msg) {
return ChatColor.translateAlternateColorCodes('&', msg);
public static String color(String message) {
Matcher matcher = HEX_PATTERN.matcher(message);
StringBuilder buffer = new StringBuilder();
while (matcher.find()) {
matcher.appendReplacement(buffer, net.md_5.bungee.api.ChatColor.of(matcher.group()).toString());
}
return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
}
public static String getPrefix() {
@ -38,163 +43,13 @@ public class Methods {
public static String removeColor(String msg) {
return ChatColor.stripColor(msg);
}
public static ItemStack makeItem(String type, int amount) {
int ty = 0;
if (type.contains(":")) {
String[] b = type.split(":");
type = b[0];
ty = Integer.parseInt(b[1]);
}
Material m = Material.matchMaterial(type);
ItemStack item;
try {
item = new ItemStack(m, amount, (short) ty);
} catch (Exception e) {
if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1);
} else {
item = new ItemStack(Material.matchMaterial("STAINED_CLAY"), 1, (short) 14);
}
}
return item;
}
public static ItemStack makeItem(String type, int amount, String name) {
int ty = 0;
if (type.contains(":")) {
String[] b = type.split(":");
type = b[0];
ty = Integer.parseInt(b[1]);
}
Material m = Material.matchMaterial(type);
ItemStack item;
try {
item = new ItemStack(m, amount, (short) ty);
} catch (Exception e) {
if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1);
} else {
item = new ItemStack(Material.matchMaterial("STAINED_CLAY"), 1, (short) 14);
}
}
ItemMeta me = item.getItemMeta();
me.setDisplayName(color(name));
item.setItemMeta(me);
return item;
}
public static ItemStack makeItem(String type, int amount, String name, List<String> lore) {
ArrayList<String> l = new ArrayList<>();
int ty = 0;
if (type.contains(":")) {
String[] b = type.split(":");
type = b[0];
ty = Integer.parseInt(b[1]);
}
Material m = Material.matchMaterial(type);
ItemStack item;
try {
item = new ItemStack(m, amount, (short) ty);
} catch (Exception e) {
if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
item = new ItemStack(Material.matchMaterial("RED_TERRACOTTA"), 1);
} else {
item = new ItemStack(Material.matchMaterial("STAINED_CLAY"), 1, (short) 14);
}
}
ItemMeta me = item.getItemMeta();
me.setDisplayName(color(name));
for (String L : lore)
l.add(color(L));
me.setLore(l);
item.setItemMeta(me);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name) {
ItemStack item = new ItemStack(material, amount, (short) type);
ItemMeta m = item.getItemMeta();
m.setDisplayName(color(name));
item.setItemMeta(m);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name, List<String> lore) {
ArrayList<String> l = new ArrayList<>();
ItemStack item = new ItemStack(material, amount, (short) type);
ItemMeta m = item.getItemMeta();
m.setDisplayName(color(name));
for (String L : lore)
l.add(color(L));
m.setLore(l);
item.setItemMeta(m);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name, List<String> lore, Map<Enchantment, Integer> enchants) {
ItemStack item = new ItemStack(material, amount, (short) type);
ItemMeta m = item.getItemMeta();
m.setDisplayName(name);
m.setLore(lore);
item.setItemMeta(m);
item.addUnsafeEnchantments(enchants);
return item;
}
public static ItemStack addLore(ItemStack item, String i) {
ArrayList<String> lore = new ArrayList<>();
ItemMeta m = item.getItemMeta();
if (item.getItemMeta().hasLore()) {
lore.addAll(item.getItemMeta().getLore());
}
lore.add(i);
m.setLore(lore);
item.setItemMeta(m);
return item;
}
public static ItemStack addLore(ItemStack item, List<String> list) {
if (item != null && item.getType() != Material.AIR) {
ArrayList<String> lore = new ArrayList<>();
ItemMeta m = item.getItemMeta();
if (item.hasItemMeta() && item.getItemMeta().hasLore()) {
lore.addAll(item.getItemMeta().getLore());
}
for (String i : list)
lore.add(color(i));
m.setLore(lore);
item.setItemMeta(m);
}
return item;
}
public static Integer getVersion() {
String ver = Bukkit.getServer().getClass().getPackage().getName();
ver = ver.substring(ver.lastIndexOf('.') + 1);
ver = ver.replace("_", "").replace("R", "").replace("v", "");
return Integer.parseInt(ver);
}
@SuppressWarnings("deprecation")
public static ItemStack getItemInHand(Player player) {
if (getVersion() >= 191) {
return player.getInventory().getItemInMainHand();
} else {
return player.getItemInHand();
}
return player.getInventory().getItemInMainHand();
}
@SuppressWarnings("deprecation")
public static void setItemInHand(Player player, ItemStack item) {
if (getVersion() >= 191) {
player.getInventory().setItemInMainHand(item);
} else {
player.setItemInHand(item);
}
player.getInventory().setItemInMainHand(item);
}
public static boolean isInt(String s) {
@ -203,6 +58,7 @@ public class Methods {
} catch (NumberFormatException nfe) {
return false;
}
return true;
}
@ -212,6 +68,7 @@ public class Methods {
} catch (NumberFormatException nfe) {
return false;
}
return true;
}
@ -222,26 +79,18 @@ public class Methods {
return null;
}
}
@SuppressWarnings("deprecation")
public static OfflinePlayer getOfflinePlayer(String name) {
return Bukkit.getServer().getOfflinePlayer(name);
}
public static Location getLoc(Player player) {
return player.getLocation();
}
public static void runCMD(Player player, String CMD) {
player.performCommand(CMD);
}
public static boolean isOnline(String name) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
if (player.getName().equalsIgnoreCase(name)) {
return true;
}
}
return false;
}
@ -251,6 +100,7 @@ public class Methods {
return true;
}
}
p.sendMessage(Messages.NOT_ONLINE.getMessage());
return false;
}
@ -260,21 +110,21 @@ public class Methods {
player.sendMessage(Messages.NO_PERMISSION.getMessage());
return false;
}
return true;
}
public static boolean hasPermission(CommandSender sender, String perm) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (sender instanceof Player player) {
if (!player.hasPermission("crazyauctions." + perm)) {
player.sendMessage(Messages.NO_PERMISSION.getMessage());
return false;
} else {
return true;
}
} else {
return true;
}
return true;
}
public static List<ItemStack> getPage(List<ItemStack> list, Integer page) {
@ -286,6 +136,7 @@ public class Methods {
for (; index < endIndex; index++) {
if (index < list.size()) items.add(list.get(index));
}
for (; items.size() == 0; page--) {
if (page <= 0) break;
index = page * max - max;
@ -294,6 +145,7 @@ public class Methods {
if (index < list.size()) items.add(list.get(index));
}
}
return items;
}
@ -303,9 +155,11 @@ public class Methods {
int max = 45;
int index = page * max - max;
int endIndex = index >= list.size() ? list.size() - 1 : index + max;
for (; index < endIndex; index++) {
if (index < list.size()) items.add(list.get(index));
}
for (; items.size() == 0; page--) {
if (page <= 0) break;
index = page * max - max;
@ -314,6 +168,7 @@ public class Methods {
if (index < list.size()) items.add(list.get(index));
}
}
return items;
}
@ -342,6 +197,7 @@ public class Methods {
public static long convertToMill(String time) {
Calendar cal = Calendar.getInstance();
for (String i : time.split(" ")) {
if (i.contains("D") || i.contains("d")) {
cal.add(Calendar.DATE, Integer.parseInt(i.replace("D", "").replace("d", "")));
@ -356,6 +212,7 @@ public class Methods {
cal.add(Calendar.SECOND, Integer.parseInt(i.replace("S", "").replace("s", "")));
}
}
return cal.getTimeInMillis();
}
@ -369,6 +226,7 @@ public class Methods {
Calendar expireTime = Calendar.getInstance();
Calendar fullExpireTime = Calendar.getInstance();
boolean shouldSave = false;
if (data.contains("OutOfTime/Cancelled")) {
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
fullExpireTime.setTimeInMillis(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"));
@ -378,33 +236,41 @@ public class Methods {
}
}
}
if (data.contains("Items")) {
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
expireTime.setTimeInMillis(data.getLong("Items." + i + ".Time-Till-Expire"));
fullExpireTime.setTimeInMillis(data.getLong("Items." + i + ".Full-Time"));
if (cal.after(expireTime)) {
int num = 1;
for (; data.contains("OutOfTime/Cancelled." + num); num++) ;
if (data.getBoolean("Items." + i + ".Biddable") && !data.getString("Items." + i + ".TopBidder").equalsIgnoreCase("None") && CurrencyManager.getMoney(getPlayer(data.getString("Items." + i + ".TopBidder"))) >= data.getInt("Items." + i + ".Price")) {
if (data.getBoolean("Items." + i + ".Biddable") && !data.getString("Items." + i + ".TopBidder").equalsIgnoreCase("None") && plugin.getSupport().getMoney(getPlayer(data.getString("Items." + i + ".TopBidder"))) >= data.getInt("Items." + i + ".Price")) {
String winner = data.getString("Items." + i + ".TopBidder");
String seller = data.getString("Items." + i + ".Seller");
Long price = data.getLong("Items." + i + ".Price");
CurrencyManager.addMoney(getOfflinePlayer(seller), price);
CurrencyManager.removeMoney(getOfflinePlayer(winner), price);
plugin.getSupport().addMoney(getOfflinePlayer(seller), price);
plugin.getSupport().removeMoney(getOfflinePlayer(winner), price);
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Price%", getPrice(i, false));
placeholders.put("%price%", getPrice(i, false));
placeholders.put("%Player%", winner);
placeholders.put("%player%", winner);
if (isOnline(winner) && getPlayer(winner) != null) {
Player player = getPlayer(winner);
Bukkit.getPluginManager().callEvent(new AuctionWinBidEvent(player, data.getItemStack("Items." + i + ".Item"), price));
player.sendMessage(Messages.WIN_BIDDING.getMessage(placeholders));
}
if (isOnline(seller) && getPlayer(seller) != null) {
Player player = getPlayer(seller);
player.sendMessage(Messages.SOMEONE_WON_PLAYERS_BID.getMessage(placeholders));
}
data.set("OutOfTime/Cancelled." + num + ".Seller", winner);
data.set("OutOfTime/Cancelled." + num + ".Full-Time", fullExpireTime.getTimeInMillis());
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
@ -412,9 +278,11 @@ public class Methods {
} else {
String seller = data.getString("Items." + i + ".Seller");
Player player = getPlayer(seller);
if (isOnline(seller) && getPlayer(seller) != null) {
player.sendMessage(Messages.ITEM_HAS_EXPIRED.getMessage());
}
AuctionExpireEvent event = new AuctionExpireEvent(player, data.getItemStack("Items." + i + ".Item"));
Bukkit.getPluginManager().callEvent(event);
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
@ -422,16 +290,19 @@ public class Methods {
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
data.set("OutOfTime/Cancelled." + num + ".Item", data.getItemStack("Items." + i + ".Item"));
}
data.set("Items." + i, null);
shouldSave = true;
}
}
}
if (shouldSave) Files.DATA.saveFile();
}
public static String getPrice(String ID, Boolean Expired) {
long price = 0L;
if (Expired) {
if (Files.DATA.getFile().contains("OutOfTime/Cancelled." + ID + ".Price")) {
price = Files.DATA.getFile().getLong("OutOfTime/Cancelled." + ID + ".Price");
@ -441,7 +312,7 @@ public class Methods {
price = Files.DATA.getFile().getLong("Items." + ID + ".Price");
}
}
return String.valueOf(price);
}
}

View File

@ -0,0 +1,55 @@
package com.badbones69.crazyauctions.api;
import com.badbones69.crazyauctions.api.FileManager.Files;
import com.badbones69.crazyauctions.api.enums.ShopType;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
public class CrazyManager {
private boolean sellingEnabled;
private boolean biddingEnabled;
public void load() {
this.sellingEnabled = Files.CONFIG.getFile().getBoolean("Settings.Feature-Toggle.Selling", true);
this.biddingEnabled = Files.CONFIG.getFile().getBoolean("Settings.Feature-Toggle.Bidding", true);
}
public void unload() {
Files.DATA.saveFile();
}
public boolean isSellingEnabled() {
return sellingEnabled;
}
public boolean isBiddingEnabled() {
return biddingEnabled;
}
public ArrayList<ItemStack> getItems(Player player, ShopType type) {
FileConfiguration data = Files.DATA.getFile();
ArrayList<ItemStack> items = new ArrayList<>();
if (data.contains("Items")) {
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (data.getBoolean("Items." + i + ".Biddable")) {
if (type == ShopType.BID) {
items.add(data.getItemStack("Items." + i + ".Item").clone());
}
} else {
if (type == ShopType.SELL) {
items.add(data.getItemStack("Items." + i + ".Item").clone());
}
}
}
}
}
return items;
}
}

View File

@ -0,0 +1,505 @@
package com.badbones69.crazyauctions.api;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
public class FileManager {
@NotNull
private final CrazyAuctions plugin = CrazyAuctions.get();
private final HashMap<Files, File> files = new HashMap<>();
private final List<String> homeFolders = new ArrayList<>();
private final List<CustomFile> customFiles = new ArrayList<>();
private final HashMap<String, String> jarHomeFolders = new HashMap<>();
private final HashMap<String, String> autoGenerateFiles = new HashMap<>();
private final HashMap<Files, FileConfiguration> configurations = new HashMap<>();
/**
* Sets up the plugin and loads all necessary files.
*/
public FileManager setup() {
if (!this.plugin.getDataFolder().exists()) this.plugin.getDataFolder().mkdirs();
this.files.clear();
this.customFiles.clear();
this.configurations.clear();
// Loads all the normal static files.
for (Files file : Files.values()) {
File newFile = new File(this.plugin.getDataFolder(), file.getFileLocation());
if (this.plugin.isLogging()) this.plugin.getLogger().info("Loading the " + file.getFileName());
if (!newFile.exists()) {
try (InputStream jarFile = getClass().getResourceAsStream("/" + file.getFileJar())) {
File serverFile = new File(this.plugin.getDataFolder(), "/" + file.getFileLocation());
copyFile(jarFile, serverFile);
} catch (Exception exception) {
this.plugin.getLogger().log(Level.WARNING, "Failed to load file: " + file.getFileName(), exception);
continue;
}
}
this.files.put(file, newFile);
if (file.getFileName().endsWith(".yml")) this.configurations.put(file, YamlConfiguration.loadConfiguration(newFile));
if (this.plugin.isLogging()) this.plugin.getLogger().info("Successfully loaded " + file.getFileName());
}
// Starts to load all the custom files.
if (!this.homeFolders.isEmpty()) {
if (this.plugin.isLogging()) this.plugin.getLogger().info("Loading custom files.");
for (String homeFolder : this.homeFolders) {
File homeFile = new File(this.plugin.getDataFolder(), "/" + homeFolder);
if (homeFile.exists()) {
String[] list = homeFile.list();
if (list != null) {
for (String name : list) {
if (name.endsWith(".yml")) {
CustomFile file = new CustomFile(name, homeFolder);
if (file.exists()) {
this.customFiles.add(file);
if (this.plugin.isLogging()) this.plugin.getLogger().info("Loaded new custom file: " + homeFolder + "/" + name + ".");
}
}
}
}
} else {
homeFile.mkdir();
if (this.plugin.isLogging()) this.plugin.getLogger().info("The folder " + homeFolder + "/ was not found so it was created.");
for (String fileName : this.autoGenerateFiles.keySet()) {
if (this.autoGenerateFiles.get(fileName).equalsIgnoreCase(homeFolder)) {
homeFolder = this.autoGenerateFiles.get(fileName);
try (InputStream jarFile = getClass().getResourceAsStream((this.jarHomeFolders.getOrDefault(fileName, homeFolder)) + "/" + fileName)) {
File serverFile = new File(this.plugin.getDataFolder(), homeFolder + "/" + fileName);
copyFile(jarFile, serverFile);
if (fileName.toLowerCase().endsWith(".yml")) this.customFiles.add(new CustomFile(fileName, homeFolder));
if (this.plugin.isLogging()) this.plugin.getLogger().info("Created new default file: " + homeFolder + "/" + fileName + ".");
} catch (Exception exception) {
this.plugin.getLogger().log(Level.SEVERE, "Failed to create new default file: " + homeFolder + "/" + fileName + "!", exception);
}
}
}
}
}
if (this.plugin.isLogging()) this.plugin.getLogger().info("Finished loading custom files.");
}
return this;
}
/**
* Register a folder that has custom files in it. Make sure to have a "/" in front of the folder name.
* @param homeFolder The folder that has custom files in it.
*/
public FileManager registerCustomFilesFolder(String homeFolder) {
this.homeFolders.add(homeFolder);
return this;
}
/**
* Unregister a folder that has custom files in it. Make sure to have a "/" in front of the folder name.
* @param homeFolder The folder with custom files in it.
*/
public FileManager unregisterCustomFilesFolder(String homeFolder) {
this.homeFolders.remove(homeFolder);
return this;
}
/**
* Register a file that needs to be generated when it's home folder doesn't exist. Make sure to have a "/" in front of the home folder's name.
* @param fileName The name of the file you want to auto-generate when the folder doesn't exist.
* @param homeFolder The folder that has custom files in it.
*/
public FileManager registerDefaultGenerateFiles(String fileName, String homeFolder) {
this.autoGenerateFiles.put(fileName, homeFolder);
return this;
}
/**
* Register a file that needs to be generated when it's home folder doesn't exist. Make sure to have a "/" in front of the home folder's name.
* @param fileName The name of the file you want to auto-generate when the folder doesn't exist.
* @param homeFolder The folder that has custom files in it.
* @param jarHomeFolder The folder that the file is found in the jar.
*/
public FileManager registerDefaultGenerateFiles(String fileName, String homeFolder, String jarHomeFolder) {
this.autoGenerateFiles.put(fileName, homeFolder);
this.jarHomeFolders.put(fileName, jarHomeFolder);
return this;
}
/**
* Unregister a file that doesn't need to be generated when it's home folder doesn't exist. Make sure to have a "/" in front of the home folder's name.
* @param fileName The file that you want to remove from auto-generating.
*/
public FileManager unregisterDefaultGenerateFiles(String fileName) {
this.autoGenerateFiles.remove(fileName);
this.jarHomeFolders.remove(fileName);
return this;
}
/**
* Gets the file from the system.
* @return The file from the system.
*/
public FileConfiguration getFile(Files file) {
return this.configurations.get(file);
}
/**
* Get a custom file from the loaded custom files instead of a hardcoded one.
* This allows you to get custom files like Per player data files.
* @param name Name of the crate you want. (Without the .yml)
* @return The custom file you wanted otherwise if not found will return null.
*/
public CustomFile getFile(String name) {
for (CustomFile file : this.customFiles) {
if (file.getName().equalsIgnoreCase(name)) {
return file;
}
}
return null;
}
public void removeFile(String name) {
this.customFiles.remove(getFile(name));
}
public void addFile(String name, String folder) {
this.customFiles.add(new CustomFile(name, folder));
}
/**
* Saves the file from the loaded state to the file system.
*/
public void saveFile(Files file) {
try {
this.configurations.get(file).save(this.files.get(file));
} catch (IOException exception) {
this.plugin.getLogger().log(Level.SEVERE, "Could not save " + file.getFileName() + "!", exception);
}
}
/**
* Save a custom file.
* @param name The name of the custom file.
*/
public void saveFile(String name) {
CustomFile file = getFile(name);
if (file == null) {
if (this.plugin.isLogging()) this.plugin.getLogger().warning("The file " + name + ".yml could not be found!");
return;
}
try {
file.getFile().save(new File(this.plugin.getDataFolder(), file.getHomeFolder() + "/" + file.getFileName()));
if (this.plugin.isLogging()) this.plugin.getLogger().info("Successfully saved the " + file.getFileName() + ".");
} catch (Exception exception) {
this.plugin.getLogger().log(Level.SEVERE, "Could not save " + file.getFileName() + "!", exception);
}
}
/**
* Save a custom file.
*
* @param file The custom file you are saving.
*/
public void saveFile(CustomFile file) {
file.saveFile();
}
/**
* Overrides the loaded state file and loads the file systems file.
*/
public void reloadFile(Files file) {
if (file.getFileName().endsWith(".yml")) this.configurations.put(file, YamlConfiguration.loadConfiguration(this.files.get(file)));
}
/**
* Overrides the loaded state file and loads the file systems file.
*/
public void reloadFile(String name) {
CustomFile file = getFile(name);
if (file != null) {
try {
file.file = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "/" + file.getHomeFolder() + "/" + file.getFileName()));
if (this.plugin.isLogging()) this.plugin.getLogger().info("Successfully reloaded the " + file.getFileName() + ".");
} catch (Exception exception) {
this.plugin.getLogger().log(Level.SEVERE, "Could not reload the " + file.getFileName() + "!", exception);
}
} else {
if (this.plugin.isLogging()) this.plugin.getLogger().warning("The file " + name + ".yml could not be found!");
}
}
/**
* Overrides the loaded state file and loads the filesystems file.
*/
public void reloadFile(CustomFile file) {
file.reloadFile();
}
public void reloadAllFiles() {
for (Files file : Files.values()) {
file.reloadFile();
}
for (CustomFile file : this.customFiles) {
file.reloadFile();
}
}
public List<String> getAllCratesNames() {
List<String> files = new ArrayList<>();
String[] file = new File(this.plugin.getDataFolder(), "/crates").list();
if (file != null) {
for (String name : file) {
if (!name.endsWith(".yml")) continue;
files.add(name.replaceAll(".yml", ""));
}
}
return files;
}
/**
* Was found here: <a href="https://bukkit.org/threads/extracting-file-from-jar.16962">...</a>
*/
private void copyFile(InputStream in, File out) throws Exception {
try (InputStream fis = in; FileOutputStream fos = new FileOutputStream(out)) {
byte[] buf = new byte[1024];
int i;
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
}
}
public enum Files {
// ENUM_NAME("fileName.yml", "fileLocation.yml"),
// ENUM_NAME("fileName.yml", "newFileLocation.yml", "oldFileLocation.yml"),
CONFIG("config.yml", "config.yml"),
MESSAGES("messages.yml", "messages.yml"),
TEST_FILE("test-file.yml", "test-file.yml"),
DATA("data.yml", "data.yml");
private final String fileName;
private final String fileJar;
private final String fileLocation;
@NotNull
private final CrazyAuctions plugin = CrazyAuctions.get();
@NotNull
private final FileManager fileManager = this.plugin.getFileManager();
/**
* The files that the server will try and load.
* @param fileName The file name that will be in the plugin's folder.
* @param fileLocation The location the file in the plugin's folder.
*/
Files(String fileName, String fileLocation) {
this(fileName, fileLocation, fileLocation);
}
/**
* The files that the server will try and load.
* @param fileName The file name that will be in the plugin's folder.
* @param fileLocation The location of the file will be in the plugin's folder.
* @param fileJar The location of the file in the jar.
*/
Files(String fileName, String fileLocation, String fileJar) {
this.fileName = fileName;
this.fileLocation = fileLocation;
this.fileJar = fileJar;
}
/**
* Get the name of the file.
* @return The name of the file.
*/
public String getFileName() {
return this.fileName;
}
/**
* The location the jar it is at.
* @return The location in the jar the file is in.
*/
public String getFileLocation() {
return this.fileLocation;
}
/**
* Get the location of the file in the jar.
* @return The location of the file in the jar.
*/
public String getFileJar() {
return this.fileJar;
}
/**
* Gets the file from the system.
* @return The file from the system.
*/
public FileConfiguration getFile() {
return this.fileManager.getFile(this);
}
/**
* Saves the file from the loaded state to the file system.
*/
public void saveFile() {
this.fileManager.saveFile(this);
}
/**
* Overrides the loaded state file and loads the file systems file.
*/
public void reloadFile() {
if (this.getFileName().endsWith(".yml")) this.fileManager.reloadFile(this);
}
}
public static class CustomFile {
private final String name;
private final String fileName;
private final String homeFolder;
private FileConfiguration file;
@NotNull
private final CrazyAuctions plugin = CrazyAuctions.get();
/**
* A custom file that is being made.
* @param name Name of the file.
* @param homeFolder The home folder of the file.
*/
public CustomFile(String name, String homeFolder) {
this.name = name.replace(".yml", "");
this.fileName = name;
this.homeFolder = homeFolder;
if (new File(this.plugin.getDataFolder(), "/" + homeFolder).exists()) {
if (new File(this.plugin.getDataFolder(), "/" + homeFolder + "/" + name).exists()) {
this.file = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "/" + homeFolder + "/" + name));
} else {
this.file = null;
}
} else {
new File(this.plugin.getDataFolder(), "/" + homeFolder).mkdir();
if (this.plugin.isLogging()) this.plugin.getLogger().info("The folder " + homeFolder + "/ was not found so it was created.");
this.file = null;
}
}
/**
* Get the name of the file without the .yml part.
* @return The name of the file without the .yml.
*/
public String getName() {
return this.name;
}
/**
* Get the full name of the file.
* @return Full name of the file.
*/
public String getFileName() {
return this.fileName;
}
/**
* Get the name of the home folder of the file.
* @return The name of the home folder the files are in.
*/
public String getHomeFolder() {
return this.homeFolder;
}
/**
* Get the ConfigurationFile.
* @return The ConfigurationFile of this file.
*/
public FileConfiguration getFile() {
return this.file;
}
/**
* Check if the file actually exists in the file system.
* @return True if it does and false if it doesn't.
*/
public boolean exists() {
return this.file != null;
}
/**
* Save the custom file.
*/
public void saveFile() {
if (this.file != null) {
try {
this.file.save(new File(this.plugin.getDataFolder(), this.homeFolder + "/" + this.fileName));
if (this.plugin.isLogging()) plugin.getLogger().info("Successfully saved the " + this.fileName + ".");
} catch (Exception exception) {
this.plugin.getLogger().log(Level.WARNING, "Could not save " + this.fileName + "!", exception);
}
} else {
if (this.plugin.isLogging()) this.plugin.getLogger().warning("There was a null custom file that could not be found!");
}
}
/**
* Overrides the loaded state file and loads the filesystems file.
*/
public void reloadFile() {
if (this.file != null) {
try {
this.file = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "/" + this.homeFolder + "/" + this.fileName));
if (this.plugin.isLogging()) this.plugin.getLogger().info("Successfully reloaded the " + this.fileName + ".");
} catch (Exception exception) {
this.plugin.getLogger().log(Level.SEVERE, "Could not reload the " + this.fileName + "!", exception);
}
} else {
if (this.plugin.isLogging()) this.plugin.getLogger().warning("There was a null custom file that was not found!");
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
package me.badbones69.crazyauctions.api;
package com.badbones69.crazyauctions.api.enums;
import org.bukkit.Material;
import java.util.ArrayList;
public enum Category {
@ -15,20 +14,20 @@ public enum Category {
POTIONS("Potions", getPotions()),
BLOCKS("Blocks", getBlocks());
private String Name;
private ArrayList<Material> Items;
private final String name;
private final ArrayList<Material> items;
/**
* @param name Name of the Shop Type.
*/
private Category(String name, ArrayList<Material> items) {
this.Name = name;
this.Items = items;
this.name = name;
this.items = items;
}
/**
* @param name Name of the Type you want.
* @return Returns the Type as a Enum.
* @return Returns the Type as an Enum.
*/
public static Category getFromName(String name) {
for (Category type : Category.values()) {
@ -41,17 +40,10 @@ public enum Category {
private static ArrayList<Material> getArmor() {
ArrayList<Material> ma = new ArrayList<>();
if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
ma.add(Material.matchMaterial("GOLDEN_HELMET"));
ma.add(Material.matchMaterial("GOLDEN_CHESTPLATE"));
ma.add(Material.matchMaterial("GOLDEN_LEGGINGS"));
ma.add(Material.matchMaterial("GOLDEN_BOOTS"));
} else {
ma.add(Material.matchMaterial("GOLD_HELMET"));
ma.add(Material.matchMaterial("GOLD_CHESTPLATE"));
ma.add(Material.matchMaterial("GOLD_LEGGINGS"));
ma.add(Material.matchMaterial("GOLD_BOOTS"));
}
ma.add(Material.GOLDEN_HELMET);
ma.add(Material.GOLDEN_CHESTPLATE);
ma.add(Material.GOLDEN_LEGGINGS);
ma.add(Material.GOLDEN_BOOTS);
ma.add(Material.DIAMOND_HELMET);
ma.add(Material.DIAMOND_CHESTPLATE);
ma.add(Material.DIAMOND_LEGGINGS);
@ -68,36 +60,27 @@ public enum Category {
ma.add(Material.DIAMOND_CHESTPLATE);
ma.add(Material.DIAMOND_LEGGINGS);
ma.add(Material.DIAMOND_BOOTS);
ma.add(Material.NETHERITE_HELMET);
ma.add(Material.NETHERITE_CHESTPLATE);
ma.add(Material.NETHERITE_LEGGINGS);
ma.add(Material.NETHERITE_BOOTS);
return ma;
}
private static ArrayList<Material> getTools() {
ArrayList<Material> ma = new ArrayList<>();
if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
ma.add(Material.matchMaterial("WOODEN_PICKAXE"));
ma.add(Material.matchMaterial("WOODEN_AXE"));
ma.add(Material.matchMaterial("WOODEN_SHOVEL"));
ma.add(Material.matchMaterial("WOODEN_HOE"));
ma.add(Material.matchMaterial("GOLDEN_PICKAXE"));
ma.add(Material.matchMaterial("GOLDEN_AXE"));
ma.add(Material.matchMaterial("GOLDEN_SHOVEL"));
ma.add(Material.matchMaterial("GOLDEN_HOE"));
ma.add(Material.matchMaterial("STONE_SHOVEL"));
ma.add(Material.matchMaterial("IRON_SHOVEL"));
ma.add(Material.matchMaterial("DIAMOND_SHOVEL"));
} else {
ma.add(Material.matchMaterial("WOOD_PICKAXE"));
ma.add(Material.matchMaterial("WOOD_AXE"));
ma.add(Material.matchMaterial("WOOD_SPADE"));
ma.add(Material.matchMaterial("WOOD_HOE"));
ma.add(Material.matchMaterial("GOLD_PICKAXE"));
ma.add(Material.matchMaterial("GOLD_AXE"));
ma.add(Material.matchMaterial("GOLD_SPADE"));
ma.add(Material.matchMaterial("GOLD_HOE"));
ma.add(Material.matchMaterial("STONE_SPADE"));
ma.add(Material.matchMaterial("IRON_SPADE"));
ma.add(Material.matchMaterial("DIAMOND_SPADE"));
}
ma.add(Material.WOODEN_PICKAXE);
ma.add(Material.WOODEN_AXE);
ma.add(Material.WOODEN_SHOVEL);
ma.add(Material.WOODEN_HOE);
ma.add(Material.GOLDEN_PICKAXE);
ma.add(Material.GOLDEN_AXE);
ma.add(Material.GOLDEN_SHOVEL);
ma.add(Material.GOLDEN_HOE);
ma.add(Material.STONE_SHOVEL);
ma.add(Material.IRON_SHOVEL);
ma.add(Material.DIAMOND_SHOVEL);
ma.add(Material.STONE_PICKAXE);
ma.add(Material.IRON_PICKAXE);
ma.add(Material.DIAMOND_PICKAXE);
@ -107,22 +90,19 @@ public enum Category {
ma.add(Material.STONE_HOE);
ma.add(Material.IRON_HOE);
ma.add(Material.DIAMOND_HOE);
ma.add(Material.NETHERITE_PICKAXE);
ma.add(Material.NETHERITE_AXE);
ma.add(Material.NETHERITE_HOE);
ma.add(Material.NETHERITE_SHOVEL);
return ma;
}
private static ArrayList<Material> getWeapons() {
ArrayList<Material> ma = new ArrayList<>();
if (Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
ma.add(Material.matchMaterial("WOODEN_SWORD"));
ma.add(Material.matchMaterial("WOODEN_AXE"));
ma.add(Material.matchMaterial("GOLDEN_SWORD"));
ma.add(Material.matchMaterial("GOLDEN_AXE"));
} else {
ma.add(Material.matchMaterial("WOOD_SWORD"));
ma.add(Material.matchMaterial("WOOD_AXE"));
ma.add(Material.matchMaterial("GOLD_SWORD"));
ma.add(Material.matchMaterial("GOLD_AXE"));
}
ma.add(Material.GOLDEN_PICKAXE);
ma.add(Material.GOLDEN_AXE);
ma.add(Material.GOLDEN_SHOVEL);
ma.add(Material.GOLDEN_HOE);
ma.add(Material.STONE_SWORD);
ma.add(Material.IRON_SWORD);
ma.add(Material.DIAMOND_SWORD);
@ -130,6 +110,8 @@ public enum Category {
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);
ma.add(Material.BOW);
ma.add(Material.NETHERITE_SWORD);
ma.add(Material.NETHERITE_AXE);
return ma;
}
@ -146,12 +128,8 @@ public enum Category {
private static ArrayList<Material> getPotions() {
ArrayList<Material> ma = new ArrayList<>();
ma.add(Material.POTION);
if (Material.matchMaterial("SPLASH_POTION") != null) {
ma.add(Material.matchMaterial("SPLASH_POTION"));
}
if (Material.matchMaterial("LINGERING_POTION") != null) {
ma.add(Material.matchMaterial("LINGERING_POTION"));
}
ma.add(Material.SPLASH_POTION);
ma.add(Material.LINGERING_POTION);
return ma;
}
@ -179,11 +157,10 @@ public enum Category {
* @return Returns the type name as a string.
*/
public String getName() {
return Name;
return name;
}
public ArrayList<Material> getItems() {
return Items;
return items;
}
}

View File

@ -1,9 +1,8 @@
package me.badbones69.crazyauctions.api;
package com.badbones69.crazyauctions.api.enums;
import me.badbones69.crazyauctions.Methods;
import me.badbones69.crazyauctions.api.FileManager.Files;
import com.badbones69.crazyauctions.Methods;
import com.badbones69.crazyauctions.api.FileManager.Files;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@ -16,12 +15,12 @@ public enum Messages {
INVENTORY_FULL("Inventory-Full", "&cYour inventory is too full. Please open up some space to buy that."),
NO_PERMISSION("No-Permission", "&cYou do not have permission to use that command!"),
NOT_ONLINE("Not-Online", "&cThat player is not online at this time."),
DOSENT_HAVE_ITEM_IN_HAND("Doesnt-Have-Item-In-Hand", "&cYou must have an item in your hand."),
DOESNT_HAVE_ITEM_IN_HAND("Doesnt-Have-Item-In-Hand", "&cYou must have an item in your hand."),
NOT_A_NUMBER("Not-A-Number", "&c%arg% is not a number."),
GOT_ITEM_BACK("Got-Item-Back", "&7Your item has been returned."),
CANCELLED_ITEM("Cancelled-Item", "&7You have cancelled an item on the auction list, return your items with /ah expired."),
ITEM_HAS_EXPIRED("Item-Has-Expired", "&7An item you have in the Crazy Auctions has just expired."),
ADMIN_FORCE_CENCELLED("Admin-Force-Cancelled", "&7You have just force cancelled a sale."),
ADMIN_FORCE_CANCELLED("Admin-Force-Cancelled", "&7You have just force cancelled a sale."),
ADMIN_FORCE_CANCELLED_TO_PLAYER("Admin-Force-Cancelled-To-Player", "&cOne of your items was just force cancelled by an Admin."),
ITEM_DOESNT_EXIST("Item-Doesnt-Exist", "&cThat item isnt in the crazy auctions any more."),
MAX_ITEMS("Max-Items", "&cYou cant list any more items to the Crazy Auctions."),
@ -42,7 +41,6 @@ public enum Messages {
BID_MESSAGE("Bid-Msg", "&7You have just bid &a$%Bid% &7on that item."),
SELLING_DISABLED("Selling-Disabled", "&cThe selling option is disabled."),
BIDDING_DISABLED("Bidding-Disabled", "&cThe bidding option is disabled."),
CRAZYAUCTIONS_HELP("CrazyAuctions-Help", "&c/ah help"),
CRAZYAUCTIONS_VIEW("CrazyAuctions-View", "&c/ah view <player>"),
CRAZYAUCTIONS_SELL_BID("CrazyAuctions-Sell-Bid", "&c/ah sell/bid <price> [amount of items]"),
BOOK_NOT_ALLOWED("Book-Not-Allowed", "&cThat book is not able to be sold in this auction house!"),
@ -54,9 +52,8 @@ public enum Messages {
"&9/Ah Expired/Collect - &eView and manage your cancelled and expired items.",
"&9/Ah Listed - &eView and manage the items you are selling.",
"&9/Ah Help - &eView this help menu."));
private static FileManager fileManager = FileManager.getInstance();
private String path;
private final String path;
private String defaultMessage;
private List<String> defaultListMessage;

View File

@ -1,6 +1,6 @@
package me.badbones69.crazyauctions.api.enums;
package com.badbones69.crazyauctions.api.enums;
public enum CancelledReason {
public enum Reaons {
/**
* Cancelled by an administrator.

View File

@ -1,21 +1,21 @@
package me.badbones69.crazyauctions.api;
package com.badbones69.crazyauctions.api.enums;
public enum ShopType {
SELL("Sell"), BID("Bid");
private String name;
private final String name;
/**
* @param name name of the Shop Type.
*/
private ShopType(String name) {
ShopType(String name) {
this.name = name;
}
/**
* @param name name of the Type you want.
* @return Returns the Type as a Enum.
* @return Returns the Type as an Enum.
*/
public static ShopType getFromName(String name) {
for (ShopType type : ShopType.values()) {
@ -23,6 +23,7 @@ public enum ShopType {
return type;
}
}
return null;
}

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions.api.events;
package com.badbones69.crazyauctions.api.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@ -15,15 +15,16 @@ import org.bukkit.inventory.ItemStack;
public class AuctionBuyEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private Player player;
private long price;
private ItemStack item;
private final Player player;
private final long price;
private final ItemStack item;
/**
*
* @param player
* @param item
* @param price
* @param player The player who bought the item.
* @param item The item that was bought.
* @param price The price of the item.
*/
public AuctionBuyEvent(Player player, ItemStack item, long price) {
this.player = player;

View File

@ -1,6 +1,6 @@
package me.badbones69.crazyauctions.api.events;
package com.badbones69.crazyauctions.api.events;
import me.badbones69.crazyauctions.api.enums.CancelledReason;
import com.badbones69.crazyauctions.api.enums.Reaons;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@ -17,18 +17,20 @@ import org.bukkit.inventory.ItemStack;
public class AuctionCancelledEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final boolean isOnline;
private final ItemStack item;
private final Reaons reason;
private OfflinePlayer offlinePlayer;
private Player onlinePlayer;
private boolean isOnline;
private ItemStack item;
private CancelledReason reason;
/**
*
* @param offlinePlayer The player who's item is cancelled.
* @param offlinePlayer The player whose item is cancelled.
* @param item The item that is cancelled.
*/
public AuctionCancelledEvent(OfflinePlayer offlinePlayer, ItemStack item, CancelledReason reason) {
public AuctionCancelledEvent(OfflinePlayer offlinePlayer, ItemStack item, Reaons reason) {
this.offlinePlayer = offlinePlayer;
this.item = item;
this.isOnline = false;
@ -37,10 +39,10 @@ public class AuctionCancelledEvent extends Event {
/**
*
* @param onlinePlayer The player who's item is cancelled.
* @param onlinePlayer The player whose item is cancelled.
* @param item The item that is cancelled.
*/
public AuctionCancelledEvent(Player onlinePlayer, ItemStack item, CancelledReason reason) {
public AuctionCancelledEvent(Player onlinePlayer, ItemStack item, Reaons reason) {
this.onlinePlayer = onlinePlayer;
this.item = item;
this.isOnline = true;
@ -71,7 +73,7 @@ public class AuctionCancelledEvent extends Event {
return item;
}
public CancelledReason getReason() {
public Reaons getReason() {
return reason;
}

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions.api.events;
package com.badbones69.crazyauctions.api.events;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -16,14 +16,16 @@ import org.bukkit.inventory.ItemStack;
public class AuctionExpireEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final boolean isOnline;
private final ItemStack item;
private OfflinePlayer offlinePlayer;
private Player onlinePlayer;
private boolean isOnline;
private ItemStack item;
/**
*
* @param offlinePlayer The player who's item is expiring.
* @param offlinePlayer The player whose item is expiring.
* @param item The item that is expiring.
*/
public AuctionExpireEvent(OfflinePlayer offlinePlayer, ItemStack item) {
@ -34,7 +36,7 @@ public class AuctionExpireEvent extends Event {
/**
*
* @param onlinePlayer The player who's item is expiring.
* @param onlinePlayer The player whose item is expiring.
* @param item The item that is expiring.
*/
public AuctionExpireEvent(Player onlinePlayer, ItemStack item) {

View File

@ -1,6 +1,6 @@
package me.badbones69.crazyauctions.api.events;
package com.badbones69.crazyauctions.api.events;
import me.badbones69.crazyauctions.api.ShopType;
import com.badbones69.crazyauctions.api.enums.ShopType;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -16,17 +16,17 @@ import org.bukkit.inventory.ItemStack;
public class AuctionListEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private Player player;
private long price;
private ShopType shop;
private ItemStack item;
private final Player player;
private final long price;
private final ShopType shop;
private final ItemStack item;
/**
*
* @param player
* @param shop
* @param item
* @param price
* @param player The player who is listing the item.
* @param shop The shop type the item is being listed to.
* @param item The item being listed.
* @param price The price the item is being listed for.
*/
public AuctionListEvent(Player player, ShopType shop, ItemStack item, long price) {
this.player = player;

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions.api.events;
package com.badbones69.crazyauctions.api.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@ -12,15 +12,15 @@ import org.bukkit.inventory.ItemStack;
public class AuctionNewBidEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private Player player;
private long bid;
private ItemStack item;
private final Player player;
private final long bid;
private final ItemStack item;
/**
*
* @param player
* @param item
* @param bid
* @param player The player who placed the bid.
* @param item The item that was bid on.
* @param bid The amount of money that was bid.
*/
public AuctionNewBidEvent(Player player, ItemStack item, long bid) {
this.player = player;

View File

@ -1,4 +1,4 @@
package me.badbones69.crazyauctions.api.events;
package com.badbones69.crazyauctions.api.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@ -15,15 +15,15 @@ import org.bukkit.inventory.ItemStack;
public class AuctionWinBidEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private Player player;
private long bid;
private ItemStack item;
private final Player player;
private final long bid;
private final ItemStack item;
/**
*
* @param player
* @param item
* @param bid
* @param player The player who won the item.
* @param item The item that was won.
* @param bid The bid that was placed on the item.
*/
public AuctionWinBidEvent(Player player, ItemStack item, long bid) {
this.player = player;

View File

@ -0,0 +1,32 @@
package com.badbones69.crazyauctions.api.support;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
public enum PluginSupport {
DECENT_HOLOGRAMS("DecentHolograms"),
HOLOGRAPHIC_DISPLAYS("HolographicDisplays"),
VAULT("Vault"),
CMI("CMI"),
PLACEHOLDERAPI("PlaceholderAPI"),
ORAXEN("Oraxen"),
ITEMS_ADDER("ItemsAdder");
private final String name;
private final @NotNull CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
PluginSupport(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public boolean isPluginEnabled() {
return this.plugin.getServer().getPluginManager().isPluginEnabled(this.name);
}
}

View File

@ -0,0 +1,189 @@
package com.badbones69.crazyauctions.api.support;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Base64;
import java.util.UUID;
/**
* A library for the Bukkit API to create player skulls
* from names, base64 strings, and texture URLs.
* Does not use any NMS code, and should work across all versions.
*
* @author Dean B on 12/28/2016.
*/
public class SkullCreator {
private static final @NotNull CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
/**
* Creates a player skull with a UUID. 1.13 only.
*
* @param id The Player's UUID
* @return The head of the Player
*/
public static ItemStack itemFromUuid(UUID id) {
ItemStack item = getPlayerSkullItem();
return itemWithUuid(item, id);
}
/**
* Creates a player skull based on a UUID. 1.13 only.
*
* @param item The item to apply the name to
* @param id The Player's UUID
* @return The head of the Player
*/
public static ItemStack itemWithUuid(ItemStack item, UUID id) {
notNull(item, "item");
notNull(id, "id");
SkullMeta meta = (SkullMeta) item.getItemMeta();
meta.setOwningPlayer(plugin.getServer().getOfflinePlayer(id));
item.setItemMeta(meta);
return item;
}
/**
* Creates a player skull based on a Mojang server URL.
*
* @param url The URL of the Mojang skin
* @return The head associated with the URL
*/
public static ItemStack itemFromUrl(String url) {
ItemStack item = getPlayerSkullItem();
return itemWithUrl(item, url);
}
/**
* Creates a player skull based on a Mojang server URL.
*
* @param item The item to apply the skin to
* @param url The URL of the Mojang skin
* @return The head associated with the URL
*/
public static ItemStack itemWithUrl(ItemStack item, String url) {
notNull(item, "item");
notNull(url, "url");
return itemWithBase64(item, urlToBase64(url));
}
/**
* Creates a player skull based on a base64 string containing the link to the skin.
*
* @param base64 The base64 string containing the texture
* @return The head with a custom texture
*/
public static ItemStack itemFromBase64(String base64) {
ItemStack item = getPlayerSkullItem();
return itemWithBase64(item, base64);
}
/**
* Applies the base64 string to the ItemStack.
*
* @param item The ItemStack to put the base64 onto
* @param base64 The base64 string containing the texture
* @return The head with a custom texture
*/
public static ItemStack itemWithBase64(ItemStack item, String base64) {
notNull(item, "item");
notNull(base64, "base64");
UUID hashAsId = new UUID(base64.hashCode(), base64.hashCode());
return plugin.getServer().getUnsafe().modifyItemStack(item,
"{SkullOwner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + base64 + "\"}]}}}"
);
}
/**
* Sets the block to a skull with the given UUID.
*
* @param block The block to set
* @param id The player to set it to
*/
public static void blockWithUuid(Block block, UUID id) {
notNull(block, "block");
notNull(id, "id");
setBlockType(block);
((Skull) block.getState()).setOwningPlayer(Bukkit.getOfflinePlayer(id));
}
/**
* Sets the block to a skull with the given UUID.
*
* @param block The block to set
* @param url The mojang URL to set it to use
*/
public static void blockWithUrl(Block block, String url) {
notNull(block, "block");
notNull(url, "url");
blockWithBase64(block, urlToBase64(url));
}
/**
* Sets the block to a skull with the given UUID.
*
* @param block The block to set
* @param base64 The base64 to set it to use
*/
public static void blockWithBase64(Block block, String base64) {
notNull(block, "block");
notNull(base64, "base64");
UUID hashAsId = new UUID(base64.hashCode(), base64.hashCode());
String args = String.format(
"%d %d %d %s",
block.getX(),
block.getY(),
block.getZ(),
"{Owner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + base64 + "\"}]}}}"
);
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "data merge block " + args);
}
private static ItemStack getPlayerSkullItem() {
return new ItemStack(Material.PLAYER_HEAD);
}
private static void setBlockType(Block block) {
block.setType(Material.PLAYER_HEAD, false);
}
private static void notNull(Object instance, String name) {
if (instance == null) {
throw new NullPointerException(name + " should not be null!");
}
}
private static String urlToBase64(String url) {
URI actualUrl;
try {
actualUrl = new URI(url);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl + "\"}}}";
return Base64.getEncoder().encodeToString(toEncode.getBytes());
}
}

View File

@ -0,0 +1,36 @@
package com.badbones69.crazyauctions.api.support.metrics;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bstats.bukkit.Metrics;
import org.jetbrains.annotations.NotNull;
public class MetricsWrapper {
@NotNull
private final CrazyAuctions plugin = CrazyAuctions.get();
private Metrics metrics;
public void start() {
if (this.metrics != null) {
if (this.plugin.isLogging()) this.plugin.getLogger().warning("Metrics is already enabled.");
return;
}
this.metrics = new Metrics(this.plugin, 4624);
if (this.plugin.isLogging()) this.plugin.getLogger().fine("Metrics has been enabled.");
}
public void stop() {
if (this.metrics == null) {
if (this.plugin.isLogging()) this.plugin.getLogger().warning("Metrics isn't enabled so we do nothing.");
return;
}
this.metrics.shutdown();
this.metrics = null;
if (this.plugin.isLogging()) this.plugin.getLogger().fine("Metrics has been turned off.");
}
}

View File

@ -0,0 +1,522 @@
package com.badbones69.crazyauctions.commands;
import com.badbones69.crazyauctions.CrazyAuctions;
import com.badbones69.crazyauctions.Methods;
import com.badbones69.crazyauctions.api.CrazyManager;
import com.badbones69.crazyauctions.api.FileManager;
import com.badbones69.crazyauctions.api.FileManager.Files;
import com.badbones69.crazyauctions.api.enums.Category;
import com.badbones69.crazyauctions.api.enums.Messages;
import com.badbones69.crazyauctions.api.enums.ShopType;
import com.badbones69.crazyauctions.api.events.AuctionListEvent;
import com.badbones69.crazyauctions.controllers.GuiListener;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.jetbrains.annotations.NotNull;
import org.yaml.snakeyaml.error.YAMLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import java.util.logging.Level;
public class AuctionCommand implements CommandExecutor {
private final CrazyAuctions plugin = CrazyAuctions.get();
private final CrazyManager crazyManager = this.plugin.getCrazyManager();
private final FileManager fileManager = this.plugin.getFileManager();
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, String commandLabel, String[] args) {
FileConfiguration config = Files.CONFIG.getFile();
FileConfiguration data = Files.DATA.getFile();
if (args.length == 0) {
if (!(sender instanceof Player player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
if (config.contains("Settings.Category-Page-Opens-First")) {
if (config.getBoolean("Settings.Category-Page-Opens-First")) {
GuiListener.openCategories(player, ShopType.SELL);
return true;
}
}
if (crazyManager.isSellingEnabled()) {
GuiListener.openShop(player, ShopType.SELL, Category.NONE, 1);
} else if (crazyManager.isBiddingEnabled()) {
GuiListener.openShop(player, ShopType.BID, Category.NONE, 1);
} else {
player.sendMessage(Methods.getPrefix() + Methods.color("&cThe bidding and selling options are both disabled. Please contact the admin about this."));
}
return true;
} else {
switch (args[0].toLowerCase()) {
case "help" -> {
if (!Methods.hasPermission(sender, "access")) {
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
return true;
}
sender.sendMessage(Messages.HELP.getMessage());
return true;
}
case "test" -> {
if (!Methods.hasPermission(sender, "test")) {
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
return true;
}
int times = 1;
if (args.length >= 2) {
if (!Methods.isInt(args[1])) {
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Arg%", args[1]);
placeholders.put("%arg%", args[1]);
sender.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
return true;
}
times = Integer.parseInt(args[1]);
}
int price = 10;
int amount = 1;
ItemStack item = Methods.getItemInHand((Player) sender);
if (item != null && item.getType() != Material.AIR) {
// For testing as another player
String seller = "Test-Account";
for (int it = 1; it <= times; it++) {
int num = 1;
Random random = new Random();
for (; data.contains("Items." + num); num++) ;
data.set("Items." + num + ".Price", price);
data.set("Items." + num + ".Seller", seller);
if (args[0].equalsIgnoreCase("bid")) {
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time")));
} else {
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Sell-Time")));
}
data.set("Items." + num + ".Full-Time", Methods.convertToMill(config.getString("Settings.Full-Expire-Time")));
int id = random.nextInt(Integer.MAX_VALUE);
for (String i : data.getConfigurationSection("Items").getKeys(false))
if (data.getInt("Items." + i + ".StoreID") == id)
id = random.nextInt(Integer.MAX_VALUE);
data.set("Items." + num + ".StoreID", id);
data.set("Items." + num + ".Biddable", args[0].equalsIgnoreCase("Bid"));
data.set("Items." + num + ".TopBidder", "None");
ItemStack stack = item.clone();
stack.setAmount(amount);
data.set("Items." + num + ".Item", stack);
}
Files.DATA.saveFile();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Price%", String.valueOf(price));
placeholders.put("%price%", String.valueOf(price));
sender.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(placeholders));
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
Methods.setItemInHand((Player) sender, new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount() - amount);
}
} else {
sender.sendMessage(Messages.DOESNT_HAVE_ITEM_IN_HAND.getMessage());
}
}
case "reload" -> {
if (!Methods.hasPermission(sender, "reload")) {
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
return true;
}
this.fileManager.setup();
this.crazyManager.load();
sender.sendMessage(Messages.RELOAD.getMessage());
return true;
}
case "view" -> {
if (!Methods.hasPermission(sender, "view")) {
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
return true;
}
if (!(sender instanceof Player player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
if (args.length >= 2) {
GuiListener.openViewer(player, args[1], 1);
return true;
}
sender.sendMessage(Messages.CRAZYAUCTIONS_VIEW.getMessage());
return true;
}
case "expired", "collect" -> {
if (!Methods.hasPermission(sender, "access")) {
sender.sendMessage(Messages.NO_PERMISSION.getMessage());
return true;
}
if (!(sender instanceof Player player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
GuiListener.openPlayersExpiredList(player, 1);
return true;
}
case "listed" -> {
if (!Methods.hasPermission(sender, "access")) return true;
if (!(sender instanceof Player player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
GuiListener.openPlayersCurrentList(player, 1);
return true;
}
case "sell", "bid" -> {
if (!(sender instanceof Player player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
if (args.length >= 2) {
if (args[0].equalsIgnoreCase("sell")) {
if (!crazyManager.isSellingEnabled()) {
player.sendMessage(Messages.SELLING_DISABLED.getMessage());
return true;
}
if (!Methods.hasPermission(player, "sell")) return true;
}
if (args[0].equalsIgnoreCase("bid")) {
if (!crazyManager.isBiddingEnabled()) {
player.sendMessage(Messages.BIDDING_DISABLED.getMessage());
return true;
}
if (!Methods.hasPermission(player, "bid")) return true;
}
ItemStack item = Methods.getItemInHand(player);
int amount = item.getAmount();
if (args.length >= 3) {
if (!Methods.isInt(args[2])) {
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Arg%", args[2]);
placeholders.put("%arg%", args[2]);
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
return true;
}
amount = Integer.parseInt(args[2]);
if (amount <= 0) amount = 1;
if (amount > item.getAmount()) amount = item.getAmount();
}
if (!Methods.isLong(args[1])) {
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Arg%", args[1]);
placeholders.put("%arg%", args[1]);
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
return true;
}
if (Methods.getItemInHand(player).getType() == Material.AIR) {
player.sendMessage(Messages.DOESNT_HAVE_ITEM_IN_HAND.getMessage());
return false;
}
long price = Long.parseLong(args[1]);
if (args[0].equalsIgnoreCase("bid")) {
if (price < config.getLong("Settings.Minimum-Bid-Price")) {
player.sendMessage(Messages.BID_PRICE_TO_LOW.getMessage());
return true;
}
if (price > config.getLong("Settings.Max-Beginning-Bid-Price")) {
player.sendMessage(Messages.BID_PRICE_TO_HIGH.getMessage());
return true;
}
} else {
if (price < config.getLong("Settings.Minimum-Sell-Price")) {
player.sendMessage(Messages.SELL_PRICE_TO_LOW.getMessage());
return true;
}
if (price > config.getLong("Settings.Max-Beginning-Sell-Price")) {
player.sendMessage(Messages.SELL_PRICE_TO_HIGH.getMessage());
return true;
}
}
if (!player.hasPermission("crazyauctions.bypass")) {
int SellLimit = 0;
int BidLimit = 0;
for (PermissionAttachmentInfo permission : player.getEffectivePermissions()) {
String perm = permission.getPermission();
if (perm.startsWith("crazyauctions.sell.")) {
perm = perm.replace("crazyauctions.sell.", "");
if (Methods.isInt(perm)) {
if (Integer.parseInt(perm) > SellLimit) {
SellLimit = Integer.parseInt(perm);
}
}
}
if (perm.startsWith("crazyauctions.bid.")) {
perm = perm.replace("crazyauctions.bid.", "");
if (Methods.isInt(perm)) {
if (Integer.parseInt(perm) > BidLimit) {
BidLimit = Integer.parseInt(perm);
}
}
}
}
for (int i = 1; i < 100; i++) {
if (SellLimit < i) {
if (player.hasPermission("crazyauctions.sell." + i)) {
SellLimit = i;
}
}
if (BidLimit < i) {
if (player.hasPermission("crazyauctions.bid." + i)) {
BidLimit = i;
}
}
}
if (args[0].equalsIgnoreCase("sell")) {
if (crazyManager.getItems(player, ShopType.SELL).size() >= SellLimit) {
player.sendMessage(Messages.MAX_ITEMS.getMessage());
return true;
}
}
if (args[0].equalsIgnoreCase("bid")) {
if (crazyManager.getItems(player, ShopType.BID).size() >= BidLimit) {
player.sendMessage(Messages.MAX_ITEMS.getMessage());
return true;
}
}
}
if (config.getStringList("Settings.BlackList").contains(item.getType().getKey().getKey())) {
player.sendMessage(Messages.ITEM_BLACKLISTED.getMessage());
return true;
}
if (!config.getBoolean("Settings.Allow-Damaged-Items")) {
for (Material i : getDamageableItems()) {
if (item.getType() == i) {
if (item.getDurability() > 0) {
player.sendMessage(Messages.ITEM_DAMAGED.getMessage());
return true;
}
}
}
}
if (!allowBook(item)) {
player.sendMessage(Messages.BOOK_NOT_ALLOWED.getMessage());
return true;
}
String seller = player.getName();
int num = 1;
Random random = new Random();
for (; data.contains("Items." + num); num++) ;
data.set("Items." + num + ".Price", price);
data.set("Items." + num + ".Seller", seller);
if (args[0].equalsIgnoreCase("bid")) {
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time")));
} else {
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Sell-Time")));
}
data.set("Items." + num + ".Full-Time", Methods.convertToMill(config.getString("Settings.Full-Expire-Time")));
int id = random.nextInt(999999);
// Runs 3x to check for same ID.
for (String i : data.getConfigurationSection("Items").getKeys(false))
if (data.getInt("Items." + i + ".StoreID") == id) id = random.nextInt(Integer.MAX_VALUE);
for (String i : data.getConfigurationSection("Items").getKeys(false))
if (data.getInt("Items." + i + ".StoreID") == id) id = random.nextInt(Integer.MAX_VALUE);
for (String i : data.getConfigurationSection("Items").getKeys(false))
if (data.getInt("Items." + i + ".StoreID") == id) id = random.nextInt(Integer.MAX_VALUE);
data.set("Items." + num + ".StoreID", id);
ShopType type = ShopType.SELL;
if (args[0].equalsIgnoreCase("bid")) {
data.set("Items." + num + ".Biddable", true);
type = ShopType.BID;
} else {
data.set("Items." + num + ".Biddable", false);
}
data.set("Items." + num + ".TopBidder", "None");
ItemStack stack = item.clone();
stack.setAmount(amount);
data.set("Items." + num + ".Item", stack);
Files.DATA.saveFile();
this.plugin.getServer().getPluginManager().callEvent(new AuctionListEvent(player, type, stack, price));
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Price%", String.valueOf(price));
placeholders.put("%price%", String.valueOf(price));
player.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(placeholders));
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
Methods.setItemInHand(player, new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount() - amount);
}
return false;
}
sender.sendMessage(Messages.CRAZYAUCTIONS_SELL_BID.getMessage());
}
default -> {
sender.sendMessage(Methods.getPrefix("&cPlease do /crazyauctions help for more information."));
return true;
}
}
return true;
}
}
private ArrayList<Material> getDamageableItems() {
ArrayList<Material> ma = new ArrayList<>();
ma.add(Material.GOLDEN_HELMET);
ma.add(Material.GOLDEN_CHESTPLATE);
ma.add(Material.GOLDEN_LEGGINGS);
ma.add(Material.GOLDEN_BOOTS);
ma.add(Material.GOLDEN_HOE);
ma.add(Material.WOODEN_SWORD);
ma.add(Material.WOODEN_PICKAXE);
ma.add(Material.WOODEN_AXE);
ma.add(Material.WOODEN_SHOVEL);
ma.add(Material.WOODEN_HOE);
ma.add(Material.STONE_SHOVEL);
ma.add(Material.IRON_SHOVEL);
ma.add(Material.DIAMOND_SHOVEL);
ma.add(Material.CROSSBOW);
ma.add(Material.TRIDENT);
ma.add(Material.TURTLE_HELMET);
ma.add(Material.DIAMOND_HELMET);
ma.add(Material.DIAMOND_CHESTPLATE);
ma.add(Material.DIAMOND_LEGGINGS);
ma.add(Material.DIAMOND_BOOTS);
ma.add(Material.CHAINMAIL_HELMET);
ma.add(Material.CHAINMAIL_CHESTPLATE);
ma.add(Material.CHAINMAIL_LEGGINGS);
ma.add(Material.CHAINMAIL_BOOTS);
ma.add(Material.IRON_HELMET);
ma.add(Material.IRON_CHESTPLATE);
ma.add(Material.IRON_LEGGINGS);
ma.add(Material.IRON_BOOTS);
ma.add(Material.LEATHER_HELMET);
ma.add(Material.LEATHER_CHESTPLATE);
ma.add(Material.LEATHER_LEGGINGS);
ma.add(Material.LEATHER_BOOTS);
ma.add(Material.BOW);
ma.add(Material.STONE_SWORD);
ma.add(Material.IRON_SWORD);
ma.add(Material.DIAMOND_SWORD);
ma.add(Material.STONE_AXE);
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);
ma.add(Material.STONE_PICKAXE);
ma.add(Material.IRON_PICKAXE);
ma.add(Material.DIAMOND_PICKAXE);
ma.add(Material.STONE_AXE);
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);
ma.add(Material.STONE_HOE);
ma.add(Material.IRON_HOE);
ma.add(Material.DIAMOND_HOE);
ma.add(Material.FLINT_AND_STEEL);
ma.add(Material.ANVIL);
ma.add(Material.FISHING_ROD);
return ma;
}
private boolean allowBook(ItemStack item) {
if (item != null && item.hasItemMeta() && item.getItemMeta() instanceof BookMeta bookMeta) {
this.plugin.getLogger().info("Checking " + item.getType() + " for illegal unicode.");
FileConfiguration file = Files.TEST_FILE.getFile();
try {
file.set("Test", item);
Files.TEST_FILE.saveFile();
this.plugin.getLogger().info(item.getType() + " has passed unicode checks.");
} catch (YAMLException exception) {
this.plugin.getLogger().log(Level.SEVERE, item.getType() + " has failed unicode checks and has been denied.", exception);
return false;
}
return bookMeta.getPages().stream().mapToInt(String :: length).sum() < 2000;
}
return true;
}
}

View File

@ -0,0 +1,54 @@
package com.badbones69.crazyauctions.commands;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class AuctionTab implements TabCompleter {
private final CrazyAuctions plugin = CrazyAuctions.get();
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String commandLabel, String[] args) {
List<String> completions = new ArrayList<>();
if (args.length == 1) { // /voucher
if (hasPermission(sender, "access")) {
completions.add("help");
completions.add("collect");
completions.add("expired");
completions.add("listed");
}
if (hasPermission(sender, "test")) completions.add("test");
if (hasPermission(sender, "admin")) completions.add("reload");
if (hasPermission(sender, "view")) completions.add("view");
if (hasPermission(sender, "sell")) completions.add("sell");
if (hasPermission(sender, "bid")) completions.add("bid");
return StringUtil.copyPartialMatches(args[0], completions, new ArrayList<>());
} else if (args.length == 2) { // /crazyauctions arg0
switch (args[0].toLowerCase()) {
case "bid", "sell" -> completions.addAll(Arrays.asList("50", "100", "250", "500", "1000", "2500", "5000", "10000"));
case "view" -> completions.addAll(this.plugin.getServer().getOnlinePlayers().stream().map(Player::getName).toList());
}
return StringUtil.copyPartialMatches(args[1], completions, new ArrayList<>());
} else if (args.length == 3) { // /crazyauctions arg0 arg1
switch (args[0].toLowerCase()) {
case "bid", "sell" -> completions.addAll(Arrays.asList("1", "2", "4", "8", "10", "20", "40", "64"));
}
return StringUtil.copyPartialMatches(args[2], completions, new ArrayList<>());
}
return new ArrayList<>();
}
private boolean hasPermission(CommandSender sender, String node) {
return sender.hasPermission("crazyauctions." + node) || sender.hasPermission("crazyauctions.admin.*");
}
}

View File

@ -0,0 +1,22 @@
package com.badbones69.crazyauctions.controllers;
import com.badbones69.crazyauctions.api.FileManager.Files;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class MarcoListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPreCommand(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
boolean macro = Files.CONFIG.getFile().getBoolean("Settings.Patches.Macro-Dupe", true);
if (!macro) return;
if (!player.isOnline() || player.isDead()) event.setCancelled(true);
}
}

View File

@ -0,0 +1,45 @@
package com.badbones69.crazyauctions.currency;
import com.badbones69.crazyauctions.CrazyAuctions;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.jetbrains.annotations.NotNull;
public class VaultSupport {
private final CrazyAuctions plugin = CrazyAuctions.get();
private Economy vault = null;
public Economy getVault() {
return vault;
}
public void loadVault() {
RegisteredServiceProvider<Economy> serviceProvider = this.plugin.getServer().getServicesManager().getRegistration(Economy.class);
if (serviceProvider != null) vault = serviceProvider.getProvider();
}
public Long getMoney(@NotNull Player player) {
return (long) vault.getBalance(player);
}
public void removeMoney(@NotNull Player player, Long amount) {
vault.withdrawPlayer(player, amount);
}
public void removeMoney(@NotNull OfflinePlayer player, Long amount) {
vault.withdrawPlayer(player, amount);
}
public void addMoney(Player player, Long amount) {
vault.depositPlayer(player, amount);
}
public void addMoney(OfflinePlayer player, Long amount) {
vault.depositPlayer(player, amount);
}
}

View File

@ -10,18 +10,21 @@ Settings:
Bid-Time: 2m 30s #Time for each item that is biddable.
Full-Expire-Time: 10d #The full time the item is in the crazy auctions.
Bid-Winner-Time: 20d #The time the winner of a bid has to claim their prize.
Minimum-Sell-Price: 10 #Minimum amount you can sell a item for.
Max-Beginning-Sell-Price: 1000000 #Max amount you can sell a item for.
Minimum-Sell-Price: 10 #Minimum amount you can sell an item for.
Max-Beginning-Sell-Price: 1000000 #Max amount you can sell an item for.
Minimum-Bid-Price: 100 #Minimum starting bid.
Max-Beginning-Bid-Price: 1000000 #Maximum starting bid.
Allow-Damaged-Items: false #Allow items that have been damaged.
Category-Page-Opens-First: false #If set to true the categories page will open when they do /CA.
Category-Page-Opens-First: false #If set to true the categories' page will open when they do /CA.
Feature-Toggle: #Toggle if a feature is on or off.
Selling: true #Able to use the selling part of the auction house.
Bidding: true #Able to use the bidding part of the auction house.
Patches:
Macro-Dupe: true #Turn to false if you have an issue, but it should patch the bug.
Sounds:
Toggle: false #Disable the clicking sound.
Sound: 'CLICK' #Make sure if you use 1.8 or lower you use the 1.8 sound and 1.9 and up use 1.9 sounds. The default sound is 1.8.
Sold-Item-Sound: 'CLICK'
#Sounds are found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
GUISettings: #Settings for things in the gui.
SellingItemLore: #The lore on items that are being sold.
@ -140,19 +143,19 @@ Settings:
Toggle: true
Slot: 49
Name: '&6Previous Page'
Lore: {}
Lore: { }
Refesh: #The button for Refresh Page.
Item: 'SUNFLOWER'
Toggle: true
Slot: 50
Name: '&6Refresh Page'
Lore: {}
Lore: { }
NextPage: #The button for Next Page.
Item: 'PAPER'
Toggle: true
Slot: 51
Name: '&6Next Page'
Lore: {}
Lore: { }
Category1: #The button for Next Page.
Item: 'CHEST'
Toggle: true
@ -280,7 +283,7 @@ Settings:
Your-Item: #The item that shows when you try to buy/bid on your item.
Item: 'BARRIER'
Name: '&cYou Can''t Purchase Your Own Item.'
Cant-Afford: #The item that shows when you cant afford this item.
Cant-Afford: #The item that shows when you can't afford this item.
Item: 'BARRIER'
Name: '&cYou Can''t Afford This Item.'
Top-Bidder: #The item for when a player is already the top bidder.

View File

@ -0,0 +1,53 @@
name: '${name}'
main: '${group}.CrazyAuctions'
authors: ${authors}
version: '${version}'
api-version: '${apiVersion}'
description: '${description}'
website: '${website}'
softdepend: [Vault]
commands:
crazyauctions:
description: Opens the Crazy Auctions GUI.
aliases: [crazyauction, ah, ca]
permissions:
crazyauctions.access:
default: true
crazyauctions.test:
default: op
crazyauctions.view:
default: true
crazyauctions.reload:
default: op
crazyauctions.bypass:
default: false
crazyauctions.sell:
default: true
crazyauctions.bid:
default: true
crazyauctions.player.*:
default: false
children:
crazyauctions.bid: true
crazyauctions.sell: true
crazyauctions.access: true
crazyauctions.view: true
crazyauctions.admin:
default: false
children:
crazyauctions.test: true
crazyauctions.reload: true
crazyauctions.bypass: true

View File

@ -0,0 +1,2 @@
#!!DO NOT DELETE!!
#Used for unicode checking in books.

120
pom.xml
View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>me.badbones69</groupId>
<artifactId>crazyauctions</artifactId>
<version>1.2.13-SNAPSHOT</version>
<name>CrazyAuctions</name>
<properties>
<!--This is used to show the build number for jenkins.-->
<build.number/>
</properties>
<distributionManagement>
<repository>
<id>nexus</id>
<name>nexus releases</name>
<url>https://nexus.badbones69.com/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>nexus snapshots</name>
<url>https://nexus.badbones69.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>reserve-repo</id>
<url>https://dl.bintray.com/theneweconomy/java/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.tnemc</groupId>
<artifactId>Reserve</artifactId>
<version>0.1.0.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.name}[v${project.version}]</finalName>
<defaultGoal>clean install package</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!-- Set to java 8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Generates only the jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-jar</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<configuration>
<artifactSet>
<includes>
<include>me.badbones69:*</include>
</includes>
</artifactSet>
<!-- <outputFile>/Users/badbones/Desktop/Minecraft/Server/plugins/CrazyAuctions[v${project.version}].jar</outputFile>-->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

14
settings.gradle.kts Normal file
View File

@ -0,0 +1,14 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement {
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
gradlePluginPortal()
mavenCentral()
}
}
rootProject.name = "CrazyAuctions"
include(":paper")

View File

@ -1,478 +0,0 @@
package me.badbones69.crazyauctions;
import me.badbones69.crazyauctions.api.*;
import me.badbones69.crazyauctions.api.FileManager.Files;
import me.badbones69.crazyauctions.api.events.AuctionListEvent;
import me.badbones69.crazyauctions.controllers.GUI;
import me.badbones69.crazyauctions.controllers.Metrics;
import me.badbones69.crazyauctions.currency.Vault;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
public class Main extends JavaPlugin implements Listener {
public static FileManager fileManager = FileManager.getInstance();
public static CrazyAuctions crazyAuctions = CrazyAuctions.getInstance();
@Override
public void onEnable() {
fileManager.logInfo(true).setup(this);
crazyAuctions.loadCrazyAuctions();
Bukkit.getServer().getPluginManager().registerEvents(this, this);
Bukkit.getServer().getPluginManager().registerEvents(new GUI(), this);
Methods.updateAuction();
startCheck();
if (!Vault.setupEconomy()) {
saveDefaultConfig();
}
Messages.addMissingMessages();
new Metrics(this, 4624); //Starts up bStats
}
@Override
public void onDisable() {
int file = 0;
Bukkit.getScheduler().cancelTask(file);
Files.DATA.saveFile();
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLable, String[] args) {
if (commandLable.equalsIgnoreCase("CrazyAuctions") || commandLable.equalsIgnoreCase("CrazyAuction") || commandLable.equalsIgnoreCase("CA") || commandLable.equalsIgnoreCase("AH") || commandLable.equalsIgnoreCase("HDV")) {
if (args.length == 0) {
if (!Methods.hasPermission(sender, "Access")) return true;
if (!(sender instanceof Player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
Player player = (Player) sender;
if (Files.CONFIG.getFile().contains("Settings.Category-Page-Opens-First")) {
if (Files.CONFIG.getFile().getBoolean("Settings.Category-Page-Opens-First")) {
GUI.openCategories(player, ShopType.SELL);
return true;
}
}
if (crazyAuctions.isSellingEnabled()) {
GUI.openShop(player, ShopType.SELL, Category.NONE, 1);
} else if (crazyAuctions.isBiddingEnabled()) {
GUI.openShop(player, ShopType.BID, Category.NONE, 1);
} else {
player.sendMessage(Methods.getPrefix() + Methods.color("&cThe bidding and selling options are both disabled. Please contact the admin about this."));
}
return true;
}
if (args.length >= 1) {
if (args[0].equalsIgnoreCase("Help")) {// CA Help
if (!Methods.hasPermission(sender, "Access")) return true;
sender.sendMessage(Messages.HELP.getMessage());
return true;
}
if (args[0].equalsIgnoreCase("test")) {// CA test [times]
if (!Methods.hasPermission(sender, "test")) return true;
int times = 1;
if (args.length >= 2) {
if (!Methods.isInt(args[1])) {
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Arg%", args[1]);
placeholders.put("%arg%", args[1]);
sender.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
return true;
}
times = Integer.parseInt(args[1]);
}
int price = 10;
int amount = 1;
ItemStack item = Methods.getItemInHand((Player) sender);
if (item != null && item.getType() != Material.AIR) {
// For testing as another player
String seller = "Test-Account";
for (int it = 1; it <= times; it++) {
int num = 1;
Random r = new Random();
for (; Files.DATA.getFile().contains("Items." + num); num++) ;
Files.DATA.getFile().set("Items." + num + ".Price", price);
Files.DATA.getFile().set("Items." + num + ".Seller", seller);
if (args[0].equalsIgnoreCase("Bid")) {
Files.DATA.getFile().set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Bid-Time")));
} else {
Files.DATA.getFile().set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Sell-Time")));
}
Files.DATA.getFile().set("Items." + num + ".Full-Time", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Full-Expire-Time")));
int id = r.nextInt(Integer.MAX_VALUE);
for (String i : Files.DATA.getFile().getConfigurationSection("Items").getKeys(false))
if (Files.DATA.getFile().getInt("Items." + i + ".StoreID") == id) id = r.nextInt(Integer.MAX_VALUE);
Files.DATA.getFile().set("Items." + num + ".StoreID", id);
ShopType type = ShopType.SELL;
Files.DATA.getFile().set("Items." + num + ".Biddable", args[0].equalsIgnoreCase("Bid"));
Files.DATA.getFile().set("Items." + num + ".TopBidder", "None");
ItemStack I = item.clone();
I.setAmount(amount);
Files.DATA.getFile().set("Items." + num + ".Item", I);
}
Files.DATA.saveFile();
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Price%", price + "");
placeholders.put("%price%", price + "");
sender.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(placeholders));
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
Methods.setItemInHand((Player) sender, new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount() - amount);
}
} else {
sender.sendMessage(Messages.DOSENT_HAVE_ITEM_IN_HAND.getMessage());
}
return true;
}
if (args[0].equalsIgnoreCase("Reload")) {// CA Reload
if (!Methods.hasPermission(sender, "Admin")) return true;
fileManager.logInfo(true).setup(this);
crazyAuctions.loadCrazyAuctions();
sender.sendMessage(Messages.RELOAD.getMessage());
return true;
}
if (args[0].equalsIgnoreCase("View")) {// CA View <Player>
if (!Methods.hasPermission(sender, "View")) return true;
if (!(sender instanceof Player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
if (args.length >= 2) {
Player player = (Player) sender;
GUI.openViewer(player, args[1], 1);
return true;
}
sender.sendMessage(Messages.CRAZYAUCTIONS_VIEW.getMessage());
return true;
}
if (args[0].equalsIgnoreCase("Expired") || args[0].equalsIgnoreCase("Collect")) {// CA Expired
if (!Methods.hasPermission(sender, "Access")) return true;
if (!(sender instanceof Player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
Player player = (Player) sender;
GUI.openPlayersExpiredList(player, 1);
return true;
}
if (args[0].equalsIgnoreCase("Listed")) {// CA Listed
if (!Methods.hasPermission(sender, "Access")) return true;
if (!(sender instanceof Player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
Player player = (Player) sender;
GUI.openPlayersCurrentList(player, 1);
return true;
}
if (args[0].equalsIgnoreCase("Sell") || args[0].equalsIgnoreCase("Bid")) {// /CA Sell/Bid <Price> [Amount of Items]
if (!(sender instanceof Player)) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}
if (args.length >= 2) {
Player player = (Player) sender;
if (args[0].equalsIgnoreCase("Sell")) {
if (!crazyAuctions.isSellingEnabled()) {
player.sendMessage(Messages.SELLING_DISABLED.getMessage());
return true;
}
if (!Methods.hasPermission(player, "Sell")) return true;
}
if (args[0].equalsIgnoreCase("Bid")) {
if (!crazyAuctions.isBiddingEnabled()) {
player.sendMessage(Messages.BIDDING_DISABLED.getMessage());
return true;
}
if (!Methods.hasPermission(player, "Bid")) return true;
}
ItemStack item = Methods.getItemInHand(player);
int amount = item.getAmount();
if (args.length >= 3) {
if (!Methods.isInt(args[2])) {
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Arg%", args[2]);
placeholders.put("%arg%", args[2]);
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
return true;
}
amount = Integer.parseInt(args[2]);
if (amount <= 0) amount = 1;
if (amount > item.getAmount()) amount = item.getAmount();
}
if (!Methods.isLong(args[1])) {
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Arg%", args[1]);
placeholders.put("%arg%", args[1]);
player.sendMessage(Messages.NOT_A_NUMBER.getMessage(placeholders));
return true;
}
if (Methods.getItemInHand(player).getType() == Material.AIR) {
player.sendMessage(Messages.DOSENT_HAVE_ITEM_IN_HAND.getMessage());
return false;
}
long price = Long.parseLong(args[1]);
if (args[0].equalsIgnoreCase("Bid")) {
if (price < Files.CONFIG.getFile().getLong("Settings.Minimum-Bid-Price")) {
player.sendMessage(Messages.BID_PRICE_TO_LOW.getMessage());
return true;
}
if (price > Files.CONFIG.getFile().getLong("Settings.Max-Beginning-Bid-Price")) {
player.sendMessage(Messages.BID_PRICE_TO_HIGH.getMessage());
return true;
}
} else {
if (price < Files.CONFIG.getFile().getLong("Settings.Minimum-Sell-Price")) {
player.sendMessage(Messages.SELL_PRICE_TO_LOW.getMessage());
return true;
}
if (price > Files.CONFIG.getFile().getLong("Settings.Max-Beginning-Sell-Price")) {
player.sendMessage(Messages.SELL_PRICE_TO_HIGH.getMessage());
return true;
}
}
if (!player.hasPermission("crazyauctions.bypass")) {
int SellLimit = 0;
int BidLimit = 0;
for (PermissionAttachmentInfo permission : player.getEffectivePermissions()) {
String perm = permission.getPermission();
if (perm.startsWith("crazyauctions.sell.")) {
perm = perm.replace("crazyauctions.sell.", "");
if (Methods.isInt(perm)) {
if (Integer.parseInt(perm) > SellLimit) {
SellLimit = Integer.parseInt(perm);
}
}
}
if (perm.startsWith("crazyauctions.bid.")) {
perm = perm.replace("crazyauctions.bid.", "");
if (Methods.isInt(perm)) {
if (Integer.parseInt(perm) > BidLimit) {
BidLimit = Integer.parseInt(perm);
}
}
}
}
for (int i = 1; i < 100; i++) {
if (SellLimit < i) {
if (player.hasPermission("crazyauctions.sell." + i)) {
SellLimit = i;
}
}
if (BidLimit < i) {
if (player.hasPermission("crazyauctions.bid." + i)) {
BidLimit = i;
}
}
}
if (args[0].equalsIgnoreCase("Sell")) {
if (crazyAuctions.getItems(player, ShopType.SELL).size() >= SellLimit) {
player.sendMessage(Messages.MAX_ITEMS.getMessage());
return true;
}
}
if (args[0].equalsIgnoreCase("Bid")) {
if (crazyAuctions.getItems(player, ShopType.BID).size() >= BidLimit) {
player.sendMessage(Messages.MAX_ITEMS.getMessage());
return true;
}
}
}
for (String id : Files.CONFIG.getFile().getStringList("Settings.BlackList")) {
if (item.getType() == Methods.makeItem(id, 1).getType()) {
player.sendMessage(Messages.ITEM_BLACKLISTED.getMessage());
return true;
}
}
if (!Files.CONFIG.getFile().getBoolean("Settings.Allow-Damaged-Items")) {
for (Material i : getDamageableItems()) {
if (item.getType() == i) {
if (item.getDurability() > 0) {
player.sendMessage(Messages.ITEM_DAMAGED.getMessage());
return true;
}
}
}
}
if (!allowBook(item)) {
player.sendMessage(Messages.BOOK_NOT_ALLOWED.getMessage());
return true;
}
String seller = player.getName();
// For testing as another player
//String seller = "Test-Account";
int num = 1;
Random r = new Random();
for (; Files.DATA.getFile().contains("Items." + num); num++) ;
Files.DATA.getFile().set("Items." + num + ".Price", price);
Files.DATA.getFile().set("Items." + num + ".Seller", seller);
if (args[0].equalsIgnoreCase("Bid")) {
Files.DATA.getFile().set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Bid-Time")));
} else {
Files.DATA.getFile().set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Sell-Time")));
}
Files.DATA.getFile().set("Items." + num + ".Full-Time", Methods.convertToMill(Files.CONFIG.getFile().getString("Settings.Full-Expire-Time")));
int id = r.nextInt(999999);
// Runs 3x to check for same ID.
for (String i : Files.DATA.getFile().getConfigurationSection("Items").getKeys(false))
if (Files.DATA.getFile().getInt("Items." + i + ".StoreID") == id) id = r.nextInt(Integer.MAX_VALUE);
for (String i : Files.DATA.getFile().getConfigurationSection("Items").getKeys(false))
if (Files.DATA.getFile().getInt("Items." + i + ".StoreID") == id) id = r.nextInt(Integer.MAX_VALUE);
for (String i : Files.DATA.getFile().getConfigurationSection("Items").getKeys(false))
if (Files.DATA.getFile().getInt("Items." + i + ".StoreID") == id) id = r.nextInt(Integer.MAX_VALUE);
Files.DATA.getFile().set("Items." + num + ".StoreID", id);
ShopType type = ShopType.SELL;
if (args[0].equalsIgnoreCase("Bid")) {
Files.DATA.getFile().set("Items." + num + ".Biddable", true);
type = ShopType.BID;
} else {
Files.DATA.getFile().set("Items." + num + ".Biddable", false);
}
Files.DATA.getFile().set("Items." + num + ".TopBidder", "None");
ItemStack I = item.clone();
I.setAmount(amount);
System.out.println(I.toString().length());
Files.DATA.getFile().set("Items." + num + ".Item", I);
Files.DATA.saveFile();
Bukkit.getPluginManager().callEvent(new AuctionListEvent(player, type, I, price));
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Price%", price + "");
placeholders.put("%price%", price + "");
player.sendMessage(Messages.ADDED_ITEM_TO_AUCTION.getMessage(placeholders));
if (item.getAmount() <= 1 || (item.getAmount() - amount) <= 0) {
Methods.setItemInHand(player, new ItemStack(Material.AIR));
} else {
item.setAmount(item.getAmount() - amount);
}
return false;
}
sender.sendMessage(Messages.CRAZYAUCTIONS_SELL_BID.getMessage());
return true;
}
}
}
sender.sendMessage(Messages.CRAZYAUCTIONS_HELP.getMessage());
return false;
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
final Player player = e.getPlayer();
new BukkitRunnable() {
@Override
public void run() {
if (player.getName().equals("BadBones69")) {
player.sendMessage(Methods.getPrefix() + Methods.color("&7This server is running your Crazy Auctions Plugin. " + "&7It is running version &av" + Bukkit.getServer().getPluginManager().getPlugin("CrazyAuctions").getDescription().getVersion() + "&7."));
}
}
}.runTaskLater(this, 40);
}
private void startCheck() {
new BukkitRunnable() {
@Override
public void run() {
Methods.updateAuction();
}
}.runTaskTimer(this, 20, 5 * 20);
}
private ArrayList<Material> getDamageableItems() {
ArrayList<Material> ma = new ArrayList<>();
if (Version.isNewer(Version.v1_12_R1)) {
ma.add(Material.matchMaterial("GOLDEN_HELMET"));
ma.add(Material.matchMaterial("GOLDEN_CHESTPLATE"));
ma.add(Material.matchMaterial("GOLDEN_LEGGINGS"));
ma.add(Material.matchMaterial("GOLDEN_BOOTS"));
ma.add(Material.matchMaterial("WOODEN_SWORD"));
ma.add(Material.matchMaterial("WOODEN_AXE"));
ma.add(Material.matchMaterial("WOODEN_PICKAXE"));
ma.add(Material.matchMaterial("WOODEN_AXE"));
ma.add(Material.matchMaterial("WOODEN_SHOVEL"));
ma.add(Material.matchMaterial("STONE_SHOVEL"));
ma.add(Material.matchMaterial("IRON_SHOVEL"));
ma.add(Material.matchMaterial("DIAMOND_SHOVEL"));
ma.add(Material.matchMaterial("WOODEN_HOE"));
ma.add(Material.matchMaterial("GOLDEN_HOE"));
ma.add(Material.matchMaterial("CROSSBOW"));
ma.add(Material.matchMaterial("TRIDENT"));
ma.add(Material.matchMaterial("TURTLE_HELMET"));
} else {
ma.add(Material.matchMaterial("GOLD_HELMET"));
ma.add(Material.matchMaterial("GOLD_CHESTPLATE"));
ma.add(Material.matchMaterial("GOLD_LEGGINGS"));
ma.add(Material.matchMaterial("GOLD_BOOTS"));
ma.add(Material.matchMaterial("WOOD_SWORD"));
ma.add(Material.matchMaterial("WOOD_AXE"));
ma.add(Material.matchMaterial("WOOD_PICKAXE"));
ma.add(Material.matchMaterial("WOOD_AXE"));
ma.add(Material.matchMaterial("WOOD_SPADE"));
ma.add(Material.matchMaterial("STONE_SPADE"));
ma.add(Material.matchMaterial("IRON_SPADE"));
ma.add(Material.matchMaterial("DIAMOND_SPADE"));
ma.add(Material.matchMaterial("WOOD_HOE"));
ma.add(Material.matchMaterial("GOLD_HOE"));
}
ma.add(Material.DIAMOND_HELMET);
ma.add(Material.DIAMOND_CHESTPLATE);
ma.add(Material.DIAMOND_LEGGINGS);
ma.add(Material.DIAMOND_BOOTS);
ma.add(Material.CHAINMAIL_HELMET);
ma.add(Material.CHAINMAIL_CHESTPLATE);
ma.add(Material.CHAINMAIL_LEGGINGS);
ma.add(Material.CHAINMAIL_BOOTS);
ma.add(Material.IRON_HELMET);
ma.add(Material.IRON_CHESTPLATE);
ma.add(Material.IRON_LEGGINGS);
ma.add(Material.IRON_BOOTS);
ma.add(Material.LEATHER_HELMET);
ma.add(Material.LEATHER_CHESTPLATE);
ma.add(Material.LEATHER_LEGGINGS);
ma.add(Material.LEATHER_BOOTS);
ma.add(Material.BOW);
ma.add(Material.STONE_SWORD);
ma.add(Material.IRON_SWORD);
ma.add(Material.DIAMOND_SWORD);
ma.add(Material.STONE_AXE);
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);
ma.add(Material.STONE_PICKAXE);
ma.add(Material.IRON_PICKAXE);
ma.add(Material.DIAMOND_PICKAXE);
ma.add(Material.STONE_AXE);
ma.add(Material.IRON_AXE);
ma.add(Material.DIAMOND_AXE);
ma.add(Material.STONE_HOE);
ma.add(Material.IRON_HOE);
ma.add(Material.DIAMOND_HOE);
ma.add(Material.FLINT_AND_STEEL);
ma.add(Material.ANVIL);
ma.add(Material.FISHING_ROD);
return ma;
}
private boolean allowBook(ItemStack item) {
if (item.getType() == Material.WRITTEN_BOOK || item.getType() == getMaterial("WRITABLE_BOOK", "BOOK_AND_QUILL")) {
return item.toString().length() > 2000;
}
return true;
}
public Material getMaterial(String newMaterial, String oldMaterial) {
return Material.matchMaterial(Version.isNewer(Version.v1_12_R1) ? newMaterial : oldMaterial);
}
}

View File

@ -1,76 +0,0 @@
package me.badbones69.crazyauctions.api;
import me.badbones69.crazyauctions.api.FileManager.Files;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
public class CrazyAuctions {
private static CrazyAuctions instance = new CrazyAuctions();
private FileManager fileManager = FileManager.getInstance();
private Boolean sellingEnabled;
private Boolean biddingEnabled;
public static CrazyAuctions getInstance() {
return instance;
}
public void loadCrazyAuctions() {
if (Files.CONFIG.getFile().contains("Settings.Feature-Toggle.Selling")) {
this.sellingEnabled = Files.CONFIG.getFile().getBoolean("Settings.Feature-Toggle.Selling");
} else {
this.sellingEnabled = true;
}
if (Files.CONFIG.getFile().contains("Settings.Feature-Toggle.Bidding")) {
this.biddingEnabled = Files.CONFIG.getFile().getBoolean("Settings.Feature-Toggle.Bidding");
} else {
this.biddingEnabled = true;
}
}
public Boolean isSellingEnabled() {
return sellingEnabled;
}
public Boolean isBiddingEnabled() {
return biddingEnabled;
}
public ArrayList<ItemStack> getItems(Player player) {
FileConfiguration data = Files.DATA.getFile();
ArrayList<ItemStack> items = new ArrayList<>();
if (data.contains("Items")) {
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
items.add(data.getItemStack("Items." + i + ".Item").clone());
}
}
}
return items;
}
public ArrayList<ItemStack> getItems(Player player, ShopType type) {
FileConfiguration data = Files.DATA.getFile();
ArrayList<ItemStack> items = new ArrayList<>();
if (data.contains("Items")) {
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (data.getBoolean("Items." + i + ".Biddable")) {
if (type == ShopType.BID) {
items.add(data.getItemStack("Items." + i + ".Item").clone());
}
} else {
if (type == ShopType.SELL) {
items.add(data.getItemStack("Items." + i + ".Item").clone());
}
}
}
}
}
return items;
}
}

View File

@ -1,473 +0,0 @@
package me.badbones69.crazyauctions.api;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
/**
*
* @author BadBones69
* @version v1.0
*
*/
public class FileManager {
private static FileManager instance = new FileManager();
private Plugin plugin;
private String prefix = "";
private Boolean log = false;
private HashMap<Files, File> files = new HashMap<>();
private ArrayList<String> homeFolders = new ArrayList<>();
private ArrayList<CustomFile> customFiles = new ArrayList<>();
private HashMap<String, String> autoGenerateFiles = new HashMap<>();
private HashMap<Files, FileConfiguration> configurations = new HashMap<>();
public static FileManager getInstance() {
return instance;
}
/**
* Sets up the plugin and loads all necessary files.
* @param plugin The plugin this is getting loading for.
*/
public FileManager setup(Plugin plugin) {
prefix = "[" + plugin.getName() + "] ";
this.plugin = plugin;
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
files.clear();
customFiles.clear();
//Loads all the normal static files.
for (Files file : Files.values()) {
File newFile = new File(plugin.getDataFolder(), file.getFileLocation());
if (log) System.out.println(prefix + "Loading the " + file.getFileName());
if (!newFile.exists()) {
try {
String fileLocation = file.getFileLocation();
//Switch between 1.12.2- and 1.13+ config version.
if (file == Files.CONFIG) {
if (Version.getCurrentVersion().isOlder(Version.v1_13_R2)) {
fileLocation = "config1.12.2-Down.yml";
} else {
fileLocation = "config1.13-Up.yml";
}
}
File serverFile = new File(plugin.getDataFolder(), "/" + file.getFileLocation());
InputStream jarFile = getClass().getResourceAsStream("/" + fileLocation);
copyFile(jarFile, serverFile);
} catch (Exception e) {
if (log) System.out.println(prefix + "Failed to load " + file.getFileName());
e.printStackTrace();
continue;
}
}
files.put(file, newFile);
configurations.put(file, YamlConfiguration.loadConfiguration(newFile));
if (log) System.out.println(prefix + "Successfully loaded " + file.getFileName());
}
//Starts to load all the custom files.
if (homeFolders.size() > 0) {
if (log) System.out.println(prefix + "Loading custom files.");
for (String homeFolder : homeFolders) {
File homeFile = new File(plugin.getDataFolder(), "/" + homeFolder);
if (homeFile.exists()) {
String[] list = homeFile.list();
if (list != null) {
for (String name : list) {
if (name.endsWith(".yml")) {
CustomFile file = new CustomFile(name, homeFolder, plugin);
if (file.exists()) {
customFiles.add(file);
if (log) System.out.println(prefix + "Loaded new custom file: " + homeFolder + "/" + name + ".");
}
}
}
}
} else {
homeFile.mkdir();
if (log) System.out.println(prefix + "The folder " + homeFolder + "/ was not found so it was created.");
for (String fileName : autoGenerateFiles.keySet()) {
if (autoGenerateFiles.get(fileName).equalsIgnoreCase(homeFolder)) {
homeFolder = autoGenerateFiles.get(fileName);
try {
File serverFile = new File(plugin.getDataFolder(), homeFolder + "/" + fileName);
InputStream jarFile = getClass().getResourceAsStream(homeFolder + "/" + fileName);
copyFile(jarFile, serverFile);
if (fileName.toLowerCase().endsWith(".yml")) {
customFiles.add(new CustomFile(fileName, homeFolder, plugin));
}
if (log) System.out.println(prefix + "Created new default file: " + homeFolder + "/" + fileName + ".");
} catch (Exception e) {
if (log) System.out.println(prefix + "Failed to create new default file: " + homeFolder + "/" + fileName + "!");
e.printStackTrace();
}
}
}
}
}
if (log) System.out.println(prefix + "Finished loading custom files.");
}
return this;
}
/**
* Turn on the logger system for the FileManager.
* @param log True to turn it on and false for it to be off.
*/
public FileManager logInfo(Boolean log) {
this.log = log;
return this;
}
/**
* Check if the logger is logging in console.
* @return True if it is and false if it isn't.
*/
public Boolean isLogging() {
return log;
}
/**
* Register a folder that has custom files in it. Make sure to have a "/" in front of the folder name.
* @param homeFolder The folder that has custom files in it.
*/
public FileManager registerCustomFilesFolder(String homeFolder) {
homeFolders.add(homeFolder);
return this;
}
/**
* Unregister a folder that has custom files in it. Make sure to have a "/" in front of the folder name.
* @param homeFolder The folder with custom files in it.
*/
public FileManager unregisterCustomFilesFolder(String homeFolder) {
homeFolders.remove(homeFolder);
return this;
}
/**
* Register a file that needs to be generated when it's home folder doesn't exist. Make sure to have a "/" in front of the home folder's name.
* @param fileName The name of the file you want to auto-generate when the folder doesn't exist.
* @param homeFolder The folder that has custom files in it.
*/
public FileManager registerDefaultGenerateFiles(String fileName, String homeFolder) {
autoGenerateFiles.put(fileName, homeFolder);
return this;
}
/**
* Unregister a file that doesn't need to be generated when it's home folder doesn't exist. Make sure to have a "/" in front of the home folder's name.
* @param fileName The file that you want to remove from auto-generating.
*/
public FileManager unregisterDefaultGenerateFiles(String fileName) {
autoGenerateFiles.remove(fileName);
return this;
}
/**
* Gets the file from the system.
* @return The file from the system.
*/
public FileConfiguration getFile(Files file) {
return configurations.get(file);
}
/**
* Get a custom file from the loaded custom files instead of a hardcoded one.
* This allows you to get custom files like Per player data files.
* @param name Name of the crate you want. (Without the .yml)
* @return The custom file you wanted otherwise if not found will return null.
*/
public CustomFile getFile(String name) {
for (CustomFile file : customFiles) {
if (file.getName().toLowerCase().equalsIgnoreCase(name.toLowerCase())) {
return file;
}
}
return null;
}
/**
* Saves the file from the loaded state to the file system.
*/
public void saveFile(Files file) {
try {
configurations.get(file).save(files.get(file));
} catch (IOException e) {
System.out.println(prefix + "Could not save " + file.getFileName() + "!");
e.printStackTrace();
}
}
/**
* Save a custom file.
* @param name The name of the custom file.
*/
public void saveFile(String name) {
CustomFile file = getFile(name);
if (file != null) {
try {
file.getFile().save(new File(plugin.getDataFolder(), file.getHomeFolder() + "/" + file.getFileName()));
if (log) System.out.println(prefix + "Successfuly saved the " + file.getFileName() + ".");
} catch (Exception e) {
System.out.println(prefix + "Could not save " + file.getFileName() + "!");
e.printStackTrace();
}
} else {
if (log) System.out.println(prefix + "The file " + name + ".yml could not be found!");
}
}
/**
* Save a custom file.
* @param file The custom file you are saving.
* @return True if the file saved correct and false if there was an error.
*/
public Boolean saveFile(CustomFile file) {
return file.saveFile();
}
/**
* Overrides the loaded state file and loads the file systems file.
*/
public void reloadFile(Files file) {
configurations.put(file, YamlConfiguration.loadConfiguration(files.get(file)));
}
/**
* Overrides the loaded state file and loads the file systems file.
*/
public void reloadFile(String name) {
CustomFile file = getFile(name);
if (file != null) {
try {
file.file = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "/" + file.getHomeFolder() + "/" + file.getFileName()));
if (log) System.out.println(prefix + "Successfuly reload the " + file.getFileName() + ".");
} catch (Exception e) {
System.out.println(prefix + "Could not reload the " + file.getFileName() + "!");
e.printStackTrace();
}
} else {
if (log) System.out.println(prefix + "The file " + name + ".yml could not be found!");
}
}
/**
* Overrides the loaded state file and loads the filesystems file.
* @return True if it reloaded correct and false if the file wasn't found.
*/
public Boolean reloadFile(CustomFile file) {
return file.reloadFile();
}
/**
* Was found here: https://bukkit.org/threads/extracting-file-from-jar.16962
*/
private void copyFile(InputStream in, File out) throws Exception {
try (FileOutputStream fos = new FileOutputStream(out)) {
byte[] buf = new byte[1024];
int i;
while ((i = in.read(buf)) != -1) {
fos.write(buf, 0, i);
}
} finally {
if (in != null) {
in.close();
}
}
}
public enum Files {
//ENUM_NAME("FileName.yml", "FilePath.yml"),
CONFIG("config.yml", "config.yml"),
DATA("Data.yml", "Data.yml"),
MESSAGES("Messages.yml", "Messages.yml");
private String fileName;
private String fileLocation;
/**
* The files that the server will try and load.
* @param fileName The file name that will be in the plugin's folder.
* @param fileLocation The location the file is in while in the Jar.
*/
private Files(String fileName, String fileLocation) {
this.fileName = fileName;
this.fileLocation = fileLocation;
}
/**
* Get the name of the file.
* @return The name of the file.
*/
public String getFileName() {
return fileName;
}
/**
* The location the jar it is at.
* @return The location in the jar the file is in.
*/
public String getFileLocation() {
return fileLocation;
}
/**
* Gets the file from the system.
* @return The file from the system.
*/
public FileConfiguration getFile() {
return getInstance().getFile(this);
}
/**
* Saves the file from the loaded state to the file system.
*/
public void saveFile() {
getInstance().saveFile(this);
}
/**
* Overrides the loaded state file and loads the file systems file.
*/
public void relaodFile() {
getInstance().reloadFile(this);
}
}
public class CustomFile {
private String name;
private Plugin plugin;
private String fileName;
private String homeFolder;
private FileConfiguration file;
/**
* A custom file that is being made.
* @param name Name of the file.
* @param homeFolder The home folder of the file.
* @param plugin The plugin the files belong to.
*/
public CustomFile(String name, String homeFolder, Plugin plugin) {
this.name = name.replace(".yml", "");
this.plugin = plugin;
this.fileName = name;
this.homeFolder = homeFolder;
if (new File(plugin.getDataFolder(), "/" + homeFolder).exists()) {
if (new File(plugin.getDataFolder(), "/" + homeFolder + "/" + name).exists()) {
file = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "/" + homeFolder + "/" + name));
} else {
file = null;
}
} else {
new File(plugin.getDataFolder(), "/" + homeFolder).mkdir();
if (log) System.out.println(prefix + "The folder " + homeFolder + "/ was not found so it was created.");
file = null;
}
}
/**
* Get the name of the file without the .yml part.
* @return The name of the file without the .yml.
*/
public String getName() {
return name;
}
/**
* Get the full name of the file.
* @return Full name of the file.
*/
public String getFileName() {
return fileName;
}
/**
* Get the name of the home folder of the file.
* @return The name of the home folder the files are in.
*/
public String getHomeFolder() {
return homeFolder;
}
/**
* Get the plugin the file belongs to.
* @return The plugin the file belongs to.
*/
public Plugin getPlugin() {
return plugin;
}
/**
* Get the ConfigurationFile.
* @return The ConfigurationFile of this file.
*/
public FileConfiguration getFile() {
return file;
}
/**
* Check if the file actually exists in the file system.
* @return True if it does and false if it doesn't.
*/
public Boolean exists() {
return file != null;
}
/**
* Save the custom file.
* @return True if it saved correct and false if something went wrong.
*/
public Boolean saveFile() {
if (file != null) {
try {
file.save(new File(plugin.getDataFolder(), homeFolder + "/" + fileName));
if (log) System.out.println(prefix + "Successfuly saved the " + fileName + ".");
return true;
} catch (Exception e) {
System.out.println(prefix + "Could not save " + fileName + "!");
e.printStackTrace();
return false;
}
} else {
if (log) System.out.println(prefix + "There was a null custom file that could not be found!");
}
return false;
}
/**
* Overrides the loaded state file and loads the filesystems file.
* @return True if it reloaded correct and false if the file wasn't found or errored.
*/
public Boolean reloadFile() {
if (file != null) {
try {
file = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "/" + homeFolder + "/" + fileName));
if (log) System.out.println(prefix + "Successfuly reload the " + fileName + ".");
return true;
} catch (Exception e) {
System.out.println(prefix + "Could not reload the " + fileName + "!");
e.printStackTrace();
}
} else {
if (log) System.out.println(prefix + "There was a null custom file that was not found!");
}
return false;
}
}
}

View File

@ -1,126 +0,0 @@
package me.badbones69.crazyauctions.api;
import org.bukkit.Bukkit;
public enum Version {
TOO_OLD(-1),
v1_7_R1(171), v1_7_R2(172), v1_7_R3(173), v1_7_R4(174),
v1_8_R1(181), v1_8_R2(182), v1_8_R3(183),
v1_9_R1(191), v1_9_R2(192),
v1_10_R1(1101),
v1_11_R1(1111),
v1_12_R1(1121),
v1_13_R2(1132),
v1_14_R1(1141),
TOO_NEW(-2);
private static Version currentVersion;
private static Version latest;
private int versionInteger;
private Version(int versionInteger) {
this.versionInteger = versionInteger;
}
/**
*
* @return Get the server's Minecraft version.
*/
public static Version getCurrentVersion() {
if (currentVersion == null) {
String ver = Bukkit.getServer().getClass().getPackage().getName();
int v = Integer.parseInt(ver.substring(ver.lastIndexOf('.') + 1).replace("_", "").replace("R", "").replace("v", ""));
for (Version version : values()) {
if (version.getVersionInteger() == v) {
currentVersion = version;
break;
}
}
if (v > Version.getLatestVersion().getVersionInteger()) {
currentVersion = Version.getLatestVersion();
}
if (currentVersion == null) {
currentVersion = Version.TOO_NEW;
}
}
return currentVersion;
}
/**
* Get the latest version allowed by the Version class.
* @return The latest version.
*/
public static Version getLatestVersion() {
if (latest == null) {
Version v = Version.TOO_OLD;
for (Version version : values()) {
if (version.comparedTo(v) == 1) {
v = version;
}
}
return v;
} else {
return latest;
}
}
/**
*
* @return The server's minecraft version as an integer.
*/
public int getVersionInteger() {
return this.versionInteger;
}
/**
* This checks if the current version is older, newer, or is the checked version.
* @param version The version you are checking.
* @return -1 if older, 0 if the same, and 1 if newer.
*/
public int comparedTo(Version version) {
int result = -1;
int current = this.getVersionInteger();
int check = version.getVersionInteger();
if (current > check || check == -2) {// check is newer then current
result = 1;
} else if (current == check) {// check is the same as current
result = 0;
} else if (check == -1) {// check is older then current
result = -1;
}
return result;
}
/**
* Checks to see if the current version is newer then the checked version.
* @param version The version you are checking.
* @return True if newer then the checked version and false if the same or older.
*/
public static boolean isNewer(Version version) {
if (currentVersion == null) getCurrentVersion();
return currentVersion.versionInteger > version.versionInteger || currentVersion.versionInteger == -2;
}
/**
* Checks to see if the current version is the same as the checked version.
* @param version The version you are checking.
* @return True if both the current and checked version is the same and false if otherwise.
*/
public static boolean isSame(Version version) {
if (currentVersion == null) getCurrentVersion();
return currentVersion.versionInteger == version.versionInteger;
}
/**
* Checks to see if the current version is older then the checked version.
* @param version The version you are checking.
* @return True if older then the checked version and false if the same or newer.
*/
public static boolean isOlder(Version version) {
if (currentVersion == null) getCurrentVersion();
return currentVersion.versionInteger < version.versionInteger || currentVersion.versionInteger == -1;
}
}

View File

@ -1,719 +0,0 @@
package me.badbones69.crazyauctions.controllers;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
/**
* bStats collects some data for plugin authors.
* <p>
* Check out https://bStats.org/ to learn more about bStats!
*/
public class Metrics {
static {
// You can use the property to disable the check in your test environment
if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) {
// Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
final String defaultPackage = new String(
new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'});
final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
// We want to make sure nobody just copy & pastes the example and use the wrong package names
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
}
}
}
// The version of this bStats class
public static final int B_STATS_VERSION = 1;
// The url to which the data is sent
private static final String URL = "https://bStats.org/submitData/bukkit";
// Is bStats enabled on this server?
private boolean enabled;
// Should failed requests be logged?
private static boolean logFailedRequests;
// Should the sent data be logged?
private static boolean logSentData;
// Should the response text be logged?
private static boolean logResponseStatusText;
// The uuid of the server
private static String serverUUID;
// The plugin
private final Plugin plugin;
// The plugin id
private final int pluginId;
// A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>();
/**
* Class constructor.
*
* @param plugin The plugin which stats should be submitted.
* @param pluginId The id of the plugin.
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
*/
public Metrics(Plugin plugin, int pluginId) {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null!");
}
this.plugin = plugin;
this.pluginId = pluginId;
// Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
File configFile = new File(bStatsFolder, "config.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
// Check if the config file exists
if (!config.isSet("serverUuid")) {
// Add default values
config.addDefault("enabled", true);
// Every server gets it's unique random id.
config.addDefault("serverUuid", UUID.randomUUID().toString());
// Should failed request be logged?
config.addDefault("logFailedRequests", false);
// Should the sent data be logged?
config.addDefault("logSentData", false);
// Should the response text be logged?
config.addDefault("logResponseStatusText", false);
// Inform the server owners about bStats
config.options().header(
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
"To honor their work, you should not disable it.\n" +
"This has nearly no effect on the server performance!\n" +
"Check out https://bStats.org/ to learn more :)"
).copyDefaults(true);
try {
config.save(configFile);
} catch (IOException ignored) { }
}
// Load the data
enabled = config.getBoolean("enabled", true);
serverUUID = config.getString("serverUuid");
logFailedRequests = config.getBoolean("logFailedRequests", false);
logSentData = config.getBoolean("logSentData", false);
logResponseStatusText = config.getBoolean("logResponseStatusText", false);
if (enabled) {
boolean found = false;
// Search for all other bStats Metrics classes to see if we are the first one
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
found = true; // We aren't the first
break;
} catch (NoSuchFieldException ignored) { }
}
// Register our service
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
if (!found) {
// We are the first!
startSubmitting();
}
}
}
/**
* Checks if bStats is enabled.
*
* @return Whether bStats is enabled or not.
*/
public boolean isEnabled() {
return enabled;
}
/**
* Adds a custom chart.
*
* @param chart The chart to add.
*/
public void addCustomChart(CustomChart chart) {
if (chart == null) {
throw new IllegalArgumentException("Chart cannot be null!");
}
charts.add(chart);
}
/**
* Starts the Scheduler which submits our data every 30 minutes.
*/
private void startSubmitting() {
final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (!plugin.isEnabled()) { // Plugin was disabled
timer.cancel();
return;
}
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
Bukkit.getScheduler().runTask(plugin, () -> submitData());
}
}, 1000 * 60 * 5, 1000 * 60 * 30);
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
// WARNING: Just don't do it!
}
/**
* Gets the plugin specific data.
* This method is called using Reflection.
*
* @return The plugin specific data.
*/
public JsonObject getPluginData() {
JsonObject data = new JsonObject();
String pluginName = plugin.getDescription().getName();
String pluginVersion = plugin.getDescription().getVersion();
data.addProperty("pluginName", pluginName); // Append the name of the plugin
data.addProperty("id", pluginId); // Append the id of the plugin
data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin
JsonArray customCharts = new JsonArray();
for (CustomChart customChart : charts) {
// Add the data of the custom charts
JsonObject chart = customChart.getRequestJsonObject();
if (chart == null) { // If the chart is null, we skip it
continue;
}
customCharts.add(chart);
}
data.add("customCharts", customCharts);
return data;
}
/**
* Gets the server specific data.
*
* @return The server specific data.
*/
private JsonObject getServerData() {
// Minecraft specific data
int playerAmount;
try {
// Around MC 1.8 the return type was changed to a collection from an array,
// This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
} catch (Exception e) {
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
}
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
String bukkitVersion = Bukkit.getVersion();
String bukkitName = Bukkit.getName();
// OS/Java specific data
String javaVersion = System.getProperty("java.version");
String osName = System.getProperty("os.name");
String osArch = System.getProperty("os.arch");
String osVersion = System.getProperty("os.version");
int coreCount = Runtime.getRuntime().availableProcessors();
JsonObject data = new JsonObject();
data.addProperty("serverUUID", serverUUID);
data.addProperty("playerAmount", playerAmount);
data.addProperty("onlineMode", onlineMode);
data.addProperty("bukkitVersion", bukkitVersion);
data.addProperty("bukkitName", bukkitName);
data.addProperty("javaVersion", javaVersion);
data.addProperty("osName", osName);
data.addProperty("osArch", osArch);
data.addProperty("osVersion", osVersion);
data.addProperty("coreCount", coreCount);
return data;
}
/**
* Collects the data and sends it afterwards.
*/
private void submitData() {
final JsonObject data = getServerData();
JsonArray pluginData = new JsonArray();
// Search for all other bStats Metrics classes to get their plugin data
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
if (plugin instanceof JsonObject) {
pluginData.add((JsonObject) plugin);
} else { // old bstats version compatibility
try {
Class<?> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
jsonStringGetter.setAccessible(true);
String jsonString = (String) jsonStringGetter.invoke(plugin);
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
pluginData.add(object);
}
} catch (ClassNotFoundException e) {
// minecraft version 1.14+
if (logFailedRequests) {
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e);
}
}
}
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
}
} catch (NoSuchFieldException ignored) { }
}
data.add("plugins", pluginData);
// Create a new thread for the connection to the bStats server
new Thread(() -> {
try {
// Send the data
sendData(plugin, data);
} catch (Exception e) {
// Something went wrong! :(
if (logFailedRequests) {
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
}
}
}).start();
}
/**
* Sends the data to the bStats server.
*
* @param plugin Any plugin. It's just used to get a logger instance.
* @param data The data to send.
* @throws Exception If the request failed.
*/
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
if (data == null) {
throw new IllegalArgumentException("Data cannot be null!");
}
if (Bukkit.isPrimaryThread()) {
throw new IllegalAccessException("This method must not be called from the main thread!");
}
if (logSentData) {
plugin.getLogger().info("Sending data to bStats: " + data);
}
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
// Compress the data to save bandwidth
byte[] compressedData = compress(data.toString());
// Add headers
connection.setRequestMethod("POST");
connection.addRequestProperty("Accept", "application/json");
connection.addRequestProperty("Connection", "close");
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
// Send data
connection.setDoOutput(true);
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
outputStream.write(compressedData);
}
StringBuilder builder = new StringBuilder();
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
builder.append(line);
}
}
if (logResponseStatusText) {
plugin.getLogger().info("Sent data to bStats and received response: " + builder);
}
}
/**
* Gzips the given String.
*
* @param str The string to gzip.
* @return The gzipped String.
* @throws IOException If the compression failed.
*/
private static byte[] compress(final String str) throws IOException {
if (str == null) {
return null;
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
gzip.write(str.getBytes(StandardCharsets.UTF_8));
}
return outputStream.toByteArray();
}
/**
* Represents a custom chart.
*/
public static abstract class CustomChart {
// The id of the chart
final String chartId;
/**
* Class constructor.
*
* @param chartId The id of the chart.
*/
CustomChart(String chartId) {
if (chartId == null || chartId.isEmpty()) {
throw new IllegalArgumentException("ChartId cannot be null or empty!");
}
this.chartId = chartId;
}
private JsonObject getRequestJsonObject() {
JsonObject chart = new JsonObject();
chart.addProperty("chartId", chartId);
try {
JsonObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
chart.add("data", data);
} catch (Throwable t) {
if (logFailedRequests) {
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
}
return null;
}
return chart;
}
protected abstract JsonObject getChartData() throws Exception;
}
/**
* Represents a custom simple pie.
*/
public static class SimplePie extends CustomChart {
private final Callable<String> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimplePie(String chartId, Callable<String> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObject getChartData() throws Exception {
JsonObject data = new JsonObject();
String value = callable.call();
if (value == null || value.isEmpty()) {
// Null = skip the chart
return null;
}
data.addProperty("value", value);
return data;
}
}
/**
* Represents a custom advanced pie.
*/
public static class AdvancedPie extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObject getChartData() throws Exception {
JsonObject data = new JsonObject();
JsonObject values = new JsonObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
continue; // Skip this invalid
}
allSkipped = false;
values.addProperty(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.add("values", values);
return data;
}
}
/**
* Represents a custom drilldown pie.
*/
public static class DrilldownPie extends CustomChart {
private final Callable<Map<String, Map<String, Integer>>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
super(chartId);
this.callable = callable;
}
@Override
public JsonObject getChartData() throws Exception {
JsonObject data = new JsonObject();
JsonObject values = new JsonObject();
Map<String, Map<String, Integer>> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean reallyAllSkipped = true;
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
JsonObject value = new JsonObject();
boolean allSkipped = true;
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
value.addProperty(valueEntry.getKey(), valueEntry.getValue());
allSkipped = false;
}
if (!allSkipped) {
reallyAllSkipped = false;
values.add(entryValues.getKey(), value);
}
}
if (reallyAllSkipped) {
// Null = skip the chart
return null;
}
data.add("values", values);
return data;
}
}
/**
* Represents a custom single line chart.
*/
public static class SingleLineChart extends CustomChart {
private final Callable<Integer> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SingleLineChart(String chartId, Callable<Integer> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObject getChartData() throws Exception {
JsonObject data = new JsonObject();
int value = callable.call();
if (value == 0) {
// Null = skip the chart
return null;
}
data.addProperty("value", value);
return data;
}
}
/**
* Represents a custom multi line chart.
*/
public static class MultiLineChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObject getChartData() throws Exception {
JsonObject data = new JsonObject();
JsonObject values = new JsonObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
continue; // Skip this invalid
}
allSkipped = false;
values.addProperty(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.add("values", values);
return data;
}
}
/**
* Represents a custom simple bar chart.
*/
public static class SimpleBarChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObject getChartData() throws Exception {
JsonObject data = new JsonObject();
JsonObject values = new JsonObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
for (Map.Entry<String, Integer> entry : map.entrySet()) {
JsonArray categoryValues = new JsonArray();
categoryValues.add(new JsonPrimitive(entry.getValue()));
values.add(entry.getKey(), categoryValues);
}
data.add("values", values);
return data;
}
}
/**
* Represents a custom advanced bar chart.
*/
public static class AdvancedBarChart extends CustomChart {
private final Callable<Map<String, int[]>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
super(chartId);
this.callable = callable;
}
@Override
protected JsonObject getChartData() throws Exception {
JsonObject data = new JsonObject();
JsonObject values = new JsonObject();
Map<String, int[]> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, int[]> entry : map.entrySet()) {
if (entry.getValue().length == 0) {
continue; // Skip this invalid
}
allSkipped = false;
JsonArray categoryValues = new JsonArray();
for (int categoryValue : entry.getValue()) {
categoryValues.add(new JsonPrimitive(categoryValue));
}
values.add(entry.getKey(), categoryValues);
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.add("values", values);
return data;
}
}
}

View File

@ -1,118 +0,0 @@
package me.badbones69.crazyauctions.currency;
import me.badbones69.crazyauctions.api.FileManager.Files;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
public enum CurrencyManager { // Currency Manager
VAULT("Vault", "Money");
private String pluginName, name;
/**
* @param pluginname
* name of the Plugin.
* @param name
* name of the Currency.
*/
private CurrencyManager(String pluginname, String name) {
this.pluginName = pluginname;
this.name = name;
}
/**
* @param name
* name of the Type you want.
* @return Returns the Currency as a Enum.
*/
public static CurrencyManager getFromName(String name) {
for (CurrencyManager type : CurrencyManager.values()) {
if (type.getPluginName().equalsIgnoreCase(name)) {
return type;
}
}
return null;
}
/**
*
* @param player
* Player you want the currency from.
* @return Returns the amount they have of the currency
*/
public static Long getMoney(Player player) {
return Vault.getMoney(player);
}
/**
*
* @param player
* Player you want the currency from.
* @param amount
* The amount you want to take.
*/
public static void removeMoney(Player player, Long amount) {
Vault.removeMoney(player, amount);
}
/**
*
* @param player
* Player you want the currency from.
* @param amount
* The amount you want to take.
*/
public static void removeMoney(OfflinePlayer player, Long amount) {
Vault.removeMoney(player, amount);
}
/**
*
* @param player
* Player you want the currency from.
* @param amount
* The amount you want to add.
*/
public static void addMoney(Player player, Long amount) {
Vault.addMoney(player, amount);
}
/**
*
* @param player
* Player you want the currency from.
* @param amount
* The amount you want to add.
*/
public static void addMoney(OfflinePlayer player, Long amount) {
Vault.addMoney(player, amount);
}
/**
* @return Returns the Currency name as a string.
*/
public String getName() {
return name;
}
/**
* @return Returns the Currency name as a string.
*/
public String getPluginName() {
return pluginName;
}
/**
*
* @return Returns true if the server has the plugin.
*/
public Boolean hasPlugin() {
if (Bukkit.getServer().getPluginManager().getPlugin(pluginName) != null) {
return Files.CONFIG.getFile().getBoolean("Settings.Currencies." + pluginName + ".Enabled");
}
return false;
}
}

View File

@ -1,57 +0,0 @@
package me.badbones69.crazyauctions.currency;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
public class Vault {
public static Economy econ = null;
public static EconomyResponse r;
public static boolean hasVault() {
return Bukkit.getServer().getPluginManager().getPlugin("Vault") != null;
}
public static boolean setupEconomy() {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
return econ != null;
}
public static Long getMoney(Player player) {
if (player != null) {
try {
return (long) econ.getBalance(player);
} catch (NullPointerException ignore) {
}
}
return 0L;
}
public static void removeMoney(Player player, Long amount) {
econ.withdrawPlayer(player, amount);
}
public static void removeMoney(OfflinePlayer player, Long amount) {
econ.withdrawPlayer(player, amount);
}
public static void addMoney(Player player, Long amount) {
econ.depositPlayer(player, amount);
}
public static void addMoney(OfflinePlayer player, Long amount) {
econ.depositPlayer(player, amount);
}
}

View File

@ -1,304 +0,0 @@
Settings:
Prefix: '&7[&4Crazy &bAuctions&7]: ' #Prefix of when you get Crazy Auctions Messages.
GUIName: '&4Crazy &bAuctions&8' #Name of the Main GUI.
Players-Current-Items: '&8Your Current Listings' #The Name of the Player Current Items GUI.
Cancelled/Expired-Items: '&8Cancelled/Expired Listings' #Name of the Canceled/Expired GUI.
Buying-Item: '&8Purchase Item: Are You Sure?' #Name of the Buying GUI.
Bidding-On-Item: '&8You Are Bidding On This Item.' #Name of the Bidding GUI.
Categories: '&8Categories' #Name of the Category GUI.
Sell-Time: 2d #The time that each item will sell for.
Bid-Time: 2m 30s #Time for each item that is biddable.
Full-Expire-Time: 10d #The full time the item is in the crazy auctions.
Bid-Winner-Time: 20d #The time the winner of a bid has to claim their prize.
Minimum-Sell-Price: 10 #Minimum amount you can sell a item for.
Max-Beginning-Sell-Price: 1000000 #Max amount you can sell a item for.
Minimum-Bid-Price: 100 #Minimum starting bid.
Max-Beginning-Bid-Price: 1000000 #Maximum starting bid.
Allow-Damaged-Items: False #Allow items that have been damaged.
Category-Page-Opens-First: False #If set to true the categories page will open when they do /CA.
Feature-Toggle: #Toggle if a feature is on or off.
Selling: true #Able to use the selling part of the auction house.
Bidding: true #Able to use the bidding part of the auction house.
Sounds:
Toggle: False #Disable the clicking sound.
Sound: 'CLICK' #Make sure if you use 1.8 or lower you use the 1.8 sound and 1.9 and up use 1.9 sounds. The default sound is 1.8.
#1.8 sounds are found here: http://badbones69.com/javadocs/1.8.8/org/bukkit/Sound.html
#1.9 sounds are found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
GUISettings: #Settings for things in the gui.
SellingItemLore: #The lore on items that are being sold.
- '&7-------------------------'
- '&aClick here to purchase.'
- ''
- '&9Price: &e$%price%'
- '&9Seller: &e%seller%'
- '&7-------------------------'
CurrentLore: #Lore on items that are in your current items GUI.
- '&7-------------------------'
- '&aClick here to cancel.'
- ''
- '&9Price: &e$%price%'
- '&9Expire: &e%time%'
- '&7-------------------------'
Cancelled/ExpiredLore: #Lore on items that are in your canceled/expired GUI.
- '&7-------------------------'
- '&aClick here to return to you.'
- ''
- '&9Full Expire: &e%time%'
- '&7-------------------------'
Bidding: #Lore on Bidding Items.
- '&7-------------------------'
- '&aClick here to bid.'
- ''
- '&9Seller: &e%seller%'
- '&9Current Bid: &e$%topbid%'
- '&9Top Bidder: &e%topbidder%'
- '&9Time Left: &e%time%'
- '&7-------------------------'
Category-Settings:
Armor:
Item: '315'
Toggle: true
Slot: 11
Name: '&6&lArmor'
Lore:
- '&7This category contains all'
- '&7armor that is currently being sold.'
Weapons:
Item: '283'
Toggle: true
Slot: 12
Name: '&6&lWeapons'
Lore:
- '&7This category contains all'
- '&7weapons that are currently being sold.'
Tools:
Item: '285'
Toggle: true
Slot: 13
Name: '&6&lTools'
Lore:
- '&7This category contains all'
- '&7tools that are currently being sold.'
Food:
Item: '322'
Toggle: true
Slot: 14
Name: '&6&lFood'
Lore:
- '&7This category contains all'
- '&7food that is currently being sold.'
Potions:
Item: '373:8227'
Toggle: true
Slot: 15
Name: '&6&lPotions'
Lore:
- '&7This category contains all'
- '&7potions that are currently being sold.'
Blocks:
Item: '2'
Toggle: true
Slot: 16
Name: '&6&lBlocks'
Lore:
- '&7This category contains all'
- '&7blocks that are currently being sold.'
Other:
Item: '371'
Toggle: true
Slot: 17
Name: '&6&lOthers'
Lore:
- '&7This category contains all the'
- '&7other items currently being sold.'
None:
Item: '166'
Toggle: true
Slot: 23
Name: '&6&lNone'
Lore:
- '&7This category contains all'
- '&7items currently being sold.'
OtherSettings: #Other Settings for the GUIs.
SellingItems: #The button for your current items.
Item: '264' #The item that this button is.
Toggle: true #If the item is in the gui or not.
Slot: 46 #The slot it is in. I recommend not changing these. If you do make sure they are still in the bottom row.
Name: '&6Items You are Selling' #Name of the item.
Lore: #Lore of the item.
- '&aClick here to view all the items you'
- '&aare currently selling on the auction.'
Cancelled/ExpiredItems: #The button for Canceled/Expired Items.
Item: '394'
Toggle: true
Slot: 47
Name: '&6Collect Expired / Canceled Items'
Lore:
- '&aClick here to view and collect all of the'
- '&aitems you have canceled or has expired.'
PreviousPage: #The button for Previous Page.
Item: '339'
Toggle: true
Slot: 49
Name: '&6Previous Page'
Lore: {}
Refesh: #The button for Refresh Page.
Item: '175'
Toggle: true
Slot: 50
Name: '&6Refresh Page'
Lore: {}
NextPage: #The button for Next Page.
Item: '339'
Toggle: true
Slot: 51
Name: '&6Next Page'
Lore: {}
Category1: #The button for Next Page.
Item: '54'
Toggle: true
Slot: 52
Name: '&6Categories'
Lore:
- '&bCurrent Category: &6%category%'
- '&aWant to see items in specific categories?'
- '&aClick here to see all categories of items.'
Category2: #The button for Next Page.
Item: '54'
Toggle: true
Slot: 48
Name: '&6Categories'
Lore:
- '&bCurrent Category: &6%category%'
- '&aWant to see items in specific categories?'
- '&aClick here to see all categories of items.'
Bidding/Selling: #Switch between Bidding and Selling.
Selling:
Item: '341'
Toggle: true
Slot: 53
Name: '&6Currently looking at items being sold.'
Lore:
- '&7&l(&6&l!&7&l) &7Click here to see items'
- '&7that you can bid on.'
Bidding:
Item: '378'
Toggle: true
Slot: 53
Name: '&6Currently looking at items that can be bid on.'
Lore:
- '&7&l(&6&l!&7&l) &7Click here to see items'
- '&7that you can buy at a price.'
WhatIsThis: #The info on all the Books buttons.
SellingShop: #The Book in the main shop.
Item: '340'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
Lore:
- '&aThis is the crazy auctions, here you can'
- '&aput items for sale, and buy items'
- '&athat others have put for sale.'
- ''
- '&aThe auction is also a great place to make'
- '&amoney by selling items that others'
- '&amay be interested in buying.'
BiddingShop: #The Book in the main shop.
Item: '340'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
Lore:
- '&aThis is the crazy auctions, here you can'
- '&aput items for sale, and bid on items'
- '&athat others have put for sale.'
- ''
- '&aThe bidding auction is also a great place to'
- '&amake money by bidding off items that others'
- '&amay be interested in bidding on.'
CurrentItems: #The Book in the Current items GUI.
Item: '340'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
Lore:
- '&aThese are your current listings, all of'
- '&athe items you currenty have listed on'
- '&acrazy auctions are displayed here.'
- ''
- '&aYou can cancel and view your listings'
- '&aexpire time here.'
Cancelled/ExpiredItems: #The Book in the Canceled/Expired Items GUI.
Item: '340'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
Lore:
- '&aThis page houses all of your cancelled and'
- '&aexpired items, when a listings is cancelled'
- '&aor expires you will be able to return that'
- '&aitem back to you from this menu.'
- ''
- '&aJust click on the item and if you have enough'
- '&ainventory space you will receive that item.'
Viewing: #The Book in the Viewing Items GUI.
Item: '340'
Toggle: true
Slot: 50
Name: '&6What Is This Page?'
Lore:
- '&aThis page shows all the items that'
- '&aa player has currently on the bidding'
- '&aand selling market. You can quickly see'
- '&awhat a specific player is selling.'
Categories: #The Book in the Viewing Items GUI.
Item: '340'
Toggle: true
Slot: 54
Name: '&6What Is This Page?'
Lore:
- '&aThis page shows all the categories'
- '&athat you can choose from. When you click'
- '&aa category it will open the gui with only'
- '&aitems that belong to that category.'
Back: #The Back Buttons.
Item: '339'
Slot: 46
Name: '&6Back'
Return: #The Return Buttons.
Item: '390'
Slot: 50
Name: '&6Return All'
Lore:
- '&aClick here to return all cancelled'
- '&aand expired items to your inventory.'
Confirm: #The Confirm Buttons.
Item: '160:5'
Name: '&aConfirm'
Cancel: #The Cancel Buttons.
Item: '160:14'
Name: '&cCancel'
Your-Item: #The item that shows when you try to buy/bid on your item.
Item: '166'
Name: '&cYou Can''t Purchase Your Own Item.'
Cant-Afford: #The item that shows when you cant afford this item.
Item: '166'
Name: '&cYou Can''t Afford This Item.'
Top-Bidder: #The item for when a player is already the top bidder.
Item: '166'
Name: '&cYou are already the top bidder.'
Bidding: #The item in the middle when bidding on an item.
Item: '160:15'
Name: '&7Bidding'
Lore:
- '&7<--&aAdd &cRemove&7-->'
- '&9Your Current Bid: &e$%bid%'
- '&9Current Top Bid: &e$%topbid%'
Bid: #The button for when you want to confirm your bid.
Item: '160:3'
Name: '&bBid Now'
Lore:
- '&7Click here to Bid Now.'
BlackList:
- '7'
- '120'

View File

@ -1,12 +0,0 @@
name: CrazyAuctions
author: BadBones69
main: me.badbones69.crazyauctions.Main
website: https://www.spigotmc.org/resources/authors/badbones69.9719/
version: ${version}${build.number}
depend: [Vault]
api-version: 1.13
description: A plugin to auction off items globally.
commands:
ca:
description: Opens the Crazy Auctions GUI.
aliases: [crazyauction, crazyauctions, ah, hdv]