Compare commits

...

374 Commits

Author SHA1 Message Date
XAP3Y
690ac0e6bf CI trigger
All checks were successful
Build CommandPanels plugin / Build-latest-jar (push) Successful in 5m33s
2024-12-22 21:15:18 +01:00
XAP3Y
86aecb856a bungee command support 2024-12-22 21:14:13 +01:00
rockyhawk64
e58adfa9f5 3.21.4.4 2024-12-07 15:36:32 +11:00
rockyhawk64
5473206adf 3.21.4.3 2024-11-14 17:35:38 +11:00
RockyHawk
aced7b6243
Merge pull request #331 from OakLoaf/latest
Made panel downloads from editor async
2024-11-09 12:17:27 +11:00
OakLoaf
98a02f2408 Updated JeffMedia repository 2024-10-28 13:37:08 +00:00
Oak
5f5db64255 Made panel download from editor async 2024-10-20 17:50:31 +01:00
rockyhawk64
9975b2f76a 3.21.4.2 2024-09-27 15:49:58 +10:00
rockyhawk64
768b2a6de9 3.21.4.0 2024-08-23 13:44:21 +10:00
rockyhawk64
8b518e3cb7 3.21.4.0 2024-08-15 22:09:24 +10:00
RockyHawk
372a9c0e86
Merge pull request #321 from TinyTank800/latest
Additional placeholders - name-slot, lore-slot AND hasnoperm=
2024-08-15 13:43:26 +10:00
TinyTank800
3034ecd8f3 Partial attempt at minimessage for everything and placeholders for item slots. 2024-08-13 20:05:10 -07:00
rockyhawk64
15766dca58 3.21.3.4 2024-08-11 12:10:33 +10:00
TinyTank800
42e61009db hasnoperm= addition. If player does not have perm, continue. 2024-08-09 11:02:59 -07:00
TinyTank800
f068a61596 %cp-name-slot% %cp-lore-slot% additions. Useful for has section checks. Lore is formatted with \n as the spacer. 2024-08-09 10:53:50 -07:00
rockyhawk64
a27360f8ff 3.21.3.3 2024-08-07 17:58:28 +10:00
rockyhawk64
6f2a39d613 3.21.3.2 2024-07-11 10:30:51 +10:00
rockyhawk64
6c390a98f2 3.21.3.1 2024-06-21 17:49:33 +10:00
rockyhawk64
9aa6a64f1e 3.21.3.0 2024-06-17 14:46:02 +10:00
rockyhawk64
a8663e41a7 NBT Improvements 2024-06-16 21:36:21 +10:00
rockyhawk64
843ba8b393 3.21.2.5 Jitpack 2024-06-14 15:00:30 +10:00
rockyhawk64
2bc6259e41 3.21.2.5 2024-05-26 12:21:35 +10:00
rockyhawk64
44e4c5831e 3.21.2.4 2024-05-24 13:15:12 +10:00
rockyhawk64
724d5039c0 3.21.2.3 2024-05-21 14:32:26 +10:00
rockyhawk64
558ab7d7b5 3.21.2.3 2024-05-21 14:15:04 +10:00
rockyhawk64
d35517af76 3.21.2.3 2024-05-21 14:06:04 +10:00
rockyhawk64
2b354a62f7 animated titles
set-data math fix
tokenpaywall fix
2024-05-12 21:17:02 +10:00
rockyhawk64
64bc5f8f60 jitpack 2024-05-10 20:59:59 +10:00
rockyhawk64
d1645d6bbb 3.21.2.2 2024-05-10 14:44:41 +10:00
RockyHawk
ad25df283f
Merge pull request #317 from rockyhawk64/1.8.8_TO_1.20.4
3.21.2.1
2024-05-08 23:05:43 +10:00
rockyhawk64
43d1b221b5 3.21.2.1 2024-05-08 22:25:41 +10:00
rockyhawk64
43dbaafc94 recursive nbt 2024-05-07 22:16:47 +10:00
rockyhawk64
47aabb03b2 converted to new itempaywall 2024-05-07 21:51:31 +10:00
rockyhawk64
f3e9e023e6 bug fixes 2024-05-07 21:25:28 +10:00
rockyhawk64
df03148d84 compatibility update 2024-05-07 19:16:26 +10:00
rockyhawk64
b8ee48a384 3.20.1.1 2024-05-05 16:27:40 +10:00
RockyHawk
016d67f7c8
Merge pull request #314 from TinyTank800/1.8.8_TO_1.12.2
CRITICAL HOT FIX 1.8-1.12
2024-05-05 15:53:18 +10:00
TinyTank800
66944ab903
Update GenUtils.java
CRITICAL FIX
2024-05-04 20:40:05 -07:00
rockyhawk64
fe32486b0b 3.20.1.0 #5 2024-04-12 20:05:10 +10:00
rockyhawk64
ed1b30c6f6 3.20.1.0 #4 2024-04-12 10:02:09 +10:00
rockyhawk64
3e9c40c160 3.20.1.0 #3 2024-04-11 01:13:32 +10:00
rockyhawk64
e163347f7d 3.20.1.0 #2 2024-04-11 00:22:22 +10:00
rockyhawk64
abafd085aa 3.20.1.0 2024-04-10 21:29:11 +10:00
RockyHawk
53dafd8f69
Merge pull request #307 from TinyTank800/master
Fixes to mmo= paywalls, multipaywalls, minor changes to item-paywall=
2024-04-10 20:23:53 +10:00
TinyTank800
1ae3b62463 Updated github issue options. 2024-04-06 21:15:28 -07:00
TinyTank800
e5cef06194 Fix for Half on mmo= paywall=, multipaywall w/custom items, added IGNORENBT to item-paywall=. 2024-04-06 21:11:19 -07:00
rockyhawk64
24a72b82dd 3.20.0.3 2024-04-06 16:14:57 +11:00
RockyHawk
68591c7a11
Merge pull request #304 from TinyTank800/master
Fix for %cp-material-slot% and legacy ids.
2024-04-06 15:52:06 +11:00
TinyTank800
6c558177ec Fix for block placement error legacy versions. 2024-04-05 20:15:34 -07:00
TinyTank800
10dc42ac3c Fix for %cp-material-slot% and legacy ids. 2024-04-05 20:00:27 -07:00
RockyHawk
6138ef1e2d
Merge pull request #298 from TinyTank800/master
Hasperm null fix
2024-02-17 09:00:03 +11:00
TinyTank800
1830c900db Fix for null players inside hasperm. Returns false on null. 2024-02-16 08:27:35 -08:00
TinyTank800
6551246c7a Fix for null players inside hasperm. Returns false on null. 2024-02-16 08:22:18 -08:00
rockyhawk64
deab494c45 3.20.0.2 2024-02-16 16:53:19 +11:00
RockyHawk
41383140b5
Merge pull request #297 from TinyTank800/master
Multiple fixes to hotbar items.
2024-02-16 16:46:49 +11:00
TinyTank800
7dadce2fd7 Fix for block placing with hotbar item and offhand slots. 2024-02-15 20:36:39 -08:00
TinyTank800
388c7d7a4b Fix for death event and hotbar items removing inventory drops. 2024-02-15 20:18:03 -08:00
rockyhawk64
c48779291d 3.20.0.1 2024-02-11 11:59:05 +11:00
RockyHawk
b88a5d62a9
Merge pull request #295 from TinyTank800/master
Disabled /cpg nbt auto grabber as its causing issues.
2024-02-11 11:52:46 +11:00
TinyTank800
21737bb99c Disabled /cpg nbt auto grabber as its causing issues. 2024-02-10 09:22:40 -08:00
rockyhawk64
b47857cb14 Move shaded dependencies 2024-02-04 22:44:22 +11:00
rockyhawk64
1cf7d0a4e0 3.20.0.0 2024-02-04 15:59:19 +11:00
RockyHawk
614a9c77d5
Merge pull request #293 from TinyTank800/master
Additions, QOL changes, Fixes...
2024-02-04 09:43:22 +11:00
TinyTank800
7525db4bf2 Fix to nbt placeholder and new nbt return value of "" instead of null 2024-02-03 13:15:51 -08:00
TinyTank800
d842ddff30 Misc fixes 2024-02-03 13:00:46 -08:00
TinyTank800
6bfbe3338a Updated NBT system using NBTAPI. Rocky will need to update pom.xml 2024-02-03 12:43:46 -08:00
TinyTank800
569a8172b9 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/me/rockyhawk/commandpanels/commands/Commandpanelsupdate.java
#	src/me/rockyhawk/commandpanels/completetabs/UpdateTabComplete.java
2024-02-03 12:39:02 -08:00
TinyTank800
b512d94624 Refresh/update command added. Used for refreshing a player open panel/s 2024-02-03 12:36:09 -08:00
TinyTank800
1b71947d13 Refresh/update command added. Used for refreshing a player open panel/s 2024-02-03 12:34:15 -08:00
TinyTank800
acca60a4fa
Merge branch 'rockyhawk64:master' into master 2024-02-03 12:19:20 -08:00
TinyTank800
0b5b776eb0 Give item amount added 2024-02-03 11:18:28 -08:00
rockyhawk64
b1e91b7616 3.19.2.1 2024-02-03 21:02:55 +11:00
TinyTank800
b9ca25eed6 Fix for double parsed commands. 2024-02-02 23:15:07 -08:00
TinyTank800
056c547605 Item-paywall fix for 1.8 2024-02-02 21:16:29 -08:00
TinyTank800
4da33349a5 Fix for unclosable and leaving. 2024-02-02 18:05:50 -08:00
TinyTank800
31cea874c0 Addition of %cp-potion-slot% 2024-02-02 17:38:24 -08:00
rockyhawk64
41ba7f31e7 Merge remote-tracking branch 'origin/master' 2024-01-30 19:19:14 +11:00
rockyhawk64
1f71e26b4d 3.19.2.0 2024-01-30 19:18:54 +11:00
RockyHawk
5d0dd09e5b
Update README.md 2024-01-29 16:28:03 +11:00
rockyhawk64
d210e016b0 Pull request fixes, updater fixes & Metrics removal 2024-01-21 20:35:58 +11:00
RockyHawk
2236f07eec
Merge pull request #289 from TinyTank800/master
Auto grab for Enchanted: list
2024-01-21 20:27:12 +11:00
TinyTank800
67019348bb Merge remote-tracking branch 'origin/master' 2024-01-20 11:14:08 -08:00
TinyTank800
06c30c018d Auto grab enchant names for enchanted: list using /cpg 2024-01-20 11:13:45 -08:00
RockyHawk
912d79c9de
Merge pull request #288 from TinyTank800/master
enchant= and setcustomdata= additions.
2024-01-19 17:55:43 +11:00
TinyTank800
819ebc4592
Merge branch 'rockyhawk64:master' into master 2024-01-18 21:31:53 -08:00
TinyTank800
336190f071 enchant= and setcustomdata= added. Please edit error handling. 2024-01-18 21:31:23 -08:00
RockyHawk
39ee2a6b21
Merge pull request #286 from TinyTank800/master
Quality of life changes.
2024-01-13 16:01:44 +11:00
RockyHawk
2aced6e917
Merge pull request #285 from TheLonelyWolf1/master
Implement toggle for disabling the Import Command.
2024-01-13 16:00:43 +11:00
TinyTank800
60e24fd45f cps= Value auto grab for any head using /cpg 2024-01-12 16:19:43 -08:00
TinyTank800
c10919da43 Added potion type/stats auto grab for /cpg 2024-01-12 15:16:07 -08:00
TinyTank800
74d9aa1d8a Added removeItem again just because website is not updated yet. 2024-01-12 14:42:56 -08:00
TinyTank800
fad0e1fa39 Added Replace method to ISGREATER so commas are supported. 2024-01-12 14:29:24 -08:00
TheLonelyWolf
b2b04906b8 Implement toggle for disabling the Import Command.
The toggle is currently set to disable the feature on default configuration.
2024-01-11 12:05:29 +01:00
rockyhawk64
5dee0f8a93 3.19.1.7 2023-11-03 17:23:36 +11:00
rockyhawk64
0f0d5dca84 3.19.1.6 2023-10-31 19:49:49 +11:00
rockyhawk64
277fe46859 3.19.1.5 2023-10-08 11:06:57 +11:00
rockyhawk64
02b2422de0 3.19.1.4 2023-10-04 18:55:28 +11:00
rockyhawk64
e8a5dbc1cd 3.19.1.3 2023-10-04 18:50:07 +11:00
RockyHawk
0de82db750
Merge pull request #269 from TheLonelyWolf1/master
Fix Error with Custom Heads on 1.20.2
2023-10-04 18:43:00 +11:00
TheLonelyWolf
13ceeb43a1 Fix Error with Custom Heads on 1.20.2 2023-10-03 12:32:53 +02:00
rockyhawk64
f384bec035 3.19.1.3 2023-08-16 18:06:47 +10:00
rockyhawk64
27648b7642 3.19.1.2 patch 2 2023-08-14 14:40:57 +10:00
rockyhawk64
d9fb7080f4 3.19.1.2 patch 1 2023-08-13 16:34:12 +10:00
rockyhawk64
b5d3a9b5c6 3.19.1.2 2023-08-03 15:43:48 +10:00
rockyhawk64
ac721b0770 3.19.1.1 2023-07-19 16:33:44 +10:00
rockyhawk64
81f1f611dd 3.19.1.0 2023-07-16 09:50:15 +10:00
rockyhawk64
3d24f93d84 3.19.1.0 2023-07-14 16:51:33 +10:00
rockyhawk64
d43fcfa1b1 3.19.1.0 2023-07-13 19:50:28 +10:00
rockyhawk64
7961db8520 3.19.1.0 2023-07-13 19:49:18 +10:00
rockyhawk64
8e022869af 3.19.1.0 2023-07-13 09:25:15 +10:00
rockyhawk64
b4109fa071 3.19.1.0 2023-07-13 08:29:12 +10:00
rockyhawk64
02dc119a65 3.19.1.0 2023-07-13 08:29:00 +10:00
rockyhawk64
a1fbb3aca4 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	resource/plugin.yml
2023-07-13 08:21:44 +10:00
rockyhawk64
ec32f96c2a 3.19.1.0 2023-07-13 08:21:36 +10:00
RockyHawk
605d332e78
Update plugin.yml 2023-07-13 07:52:05 +10:00
RockyHawk
228ccec717
Merge pull request #263 from jman13378/jman13378-patch-1
Added some new features
2023-07-13 07:38:24 +10:00
RockyHawk
394b27604c
Merge branch 'master' into jman13378-patch-1 2023-07-13 07:38:15 +10:00
RockyHawk
8d7c1cd6e8
Merge pull request #262 from TheLonelyWolf1/master
Added ArmorTrim Option and other changes
2023-07-13 07:30:31 +10:00
RockyHawk
351bd14053
Merge pull request #258 from ajh123/master
Made `example middle two` compatible with newish placeholder math.
2023-07-13 07:27:28 +10:00
jman13378
3f2c6187bb Adds hasperm= 2023-07-11 12:50:46 -04:00
jman13378
f93e126260 Adds multi-paywall 2023-07-11 12:37:23 -04:00
TheLonelyWolf
8a176ed18b Combine two if-statements to hopefully pass code checks 2023-07-11 18:13:48 +02:00
jman13378
840bd53d66 added some more tab completion stuff 2023-07-10 00:35:53 -04:00
jman13378
69b650bc41 Changed soem internal messages and updated the issues 2023-07-09 03:47:44 -04:00
jman13378
ff61588559 Add extensive tab completion to /cp and /cpdata 2023-07-09 01:28:50 -04:00
jman13378
a9919eb705 Add extensive tab completion to /cp and /cpdata 2023-07-09 01:20:28 -04:00
jman13378
48367ae177 Merge https://github.com/jman13378/CommandPanels into HEAD 2023-07-06 23:10:35 -04:00
jman13378
a13717234d Remove non essentions 2023-07-06 23:09:42 -04:00
Jonathan
ca27f9bd07
Merge branch 'rockyhawk64:master' into jman13378-patch-1 2023-07-06 22:58:43 -04:00
jman13378
b91ba6403e Added open-on-first-login 2023-07-06 22:55:47 -04:00
jman13378
04d344eef2 e 2023-07-05 14:43:11 -04:00
TheLonelyWolf
e4c2adc822 Added ArmorTrim Option and other changes
- Update Code to newer VotingPlugin API
- Update Spigot API to 1.20-R0.1-SNAPSHOT
- Add ArmorTrim Option for Item Settings
2023-06-30 17:31:54 +02:00
rockyhawk64
fff7fd4226 3.19.0.3 2023-06-06 00:16:01 +10:00
ajh123
824a091fb0 Fixed eam middle two. 2023-05-23 19:41:31 +01:00
rockyhawk64
4333a9903f 3.19.0.2 2023-05-20 15:50:32 +10:00
rockyhawk64
edc59529ed Merge remote-tracking branch 'origin/master' 2023-05-02 15:22:19 +10:00
rockyhawk64
131065eca3 3.19.0.1 2023-05-02 15:22:15 +10:00
RockyHawk
6d7e0a6844
Update README.md 2023-04-30 13:30:20 +10:00
rockyhawk64
bc998407a2 Merge remote-tracking branch 'origin/master' 2023-04-30 13:22:06 +10:00
rockyhawk64
3712dc76ff 3.19.0.0 2023-04-30 13:22:01 +10:00
RockyHawk
c7167337ef
Update README.md 2023-04-30 13:01:52 +10:00
RockyHawk
9b68021a7c
Update README.md 2023-04-30 12:56:46 +10:00
RockyHawk
39cf3de5ef
Merge pull request #255 from TinyTank800/master
Added custom model data to item-paywall=
2023-04-27 11:03:04 +10:00
RockyHawk
4670a9e846
Update README.md 2023-04-27 09:53:11 +10:00
RockyHawk
86a318c424
Update README.md 2023-04-26 22:31:45 +10:00
RockyHawk
5f4eb1a324
Update README.md 2023-04-26 22:29:19 +10:00
TinyTank800
55dd00656f Added NOCUSTOMDATA to item-paywall= and the sell='s 2023-04-07 11:25:39 -07:00
TinyTank800
a0760da81a Fixed item paywall id checks. 2023-04-05 18:09:35 -07:00
TinyTank800
5f30c6edcb Added custom-data: to the sellall= and sell= 2023-04-05 17:49:34 -07:00
TinyTank800
5b15f59e53 Added custom model data to item-paywall= 2023-04-03 11:40:27 -07:00
rockyhawk64
88151d2613 3.18.6.2 2023-03-30 19:03:06 +11:00
RockyHawk
6c4b14b1e7
Merge pull request #253 from TinyTank800/master
Addition of sell-all= tag
2023-03-30 17:19:41 +11:00
RockyHawk
978c745d00
Merge pull request #254 from TheLonelyWolf1/master
Added Config-Option to enable MiniMessage-CommandTag on Non-Paper forks + Warning
2023-03-30 16:47:13 +11:00
TheLonelyWolf
317d9e4663 Added Config-Option to enable MiniMessage-CommandTag on Non-Paper forks.
Added Warning on Startup for using that option, but can be disabled if desired
2023-03-29 19:48:12 +02:00
TinyTank800
49e1ae849f Addition of sell-all= tag Format: sell-all= <Per Item Cashback> <Item> [enchanted:KNOCKBACK:1] [potion:JUMP] 2023-03-28 20:51:18 -07:00
rockyhawk64
cd0db76df3 3.18.6.1 2023-03-28 17:19:57 +11:00
rockyhawk64
7eca5d2451 3.18.6.1 2023-03-28 17:01:26 +11:00
RockyHawk
aa8722513f
Merge pull request #251 from TinyTank800/master
Changes to sell= and item-paywall=
2023-03-28 16:55:12 +11:00
TinyTank800
7daab7a5b7
Merge branch 'rockyhawk64:master' into master 2023-03-27 22:51:09 -07:00
TinyTank800
a68176e83c
Changes to item-paywall= and sell=
Added the ability to sell= and item-paywall= items at an amount over 64.
2023-03-27 22:49:00 -07:00
RockyHawk
a1b6d9c9fa
Merge pull request #250 from TinyTank800/master
Added CustomData to panel generation using /cpg
2023-03-28 15:19:26 +11:00
TinyTank800
1738be4950
Added customdata
Added custom data check to the panel generation allowing automatic setup for custom resource items. This was added inside the itemcreation file and requires 1.14 or above to work.
2023-03-27 20:31:48 -07:00
TinyTank800
bb08202e7b
Oops 2023-03-27 20:30:06 -07:00
TinyTank800
ed9f8865a5
Added CustomData
CustomData addition inside the itemcreation file which allows customdata to be added on panel generation.
2023-03-27 20:29:21 -07:00
rockyhawk64
ac50e7976e 3.18.6.0 2023-03-23 15:33:10 +11:00
rockyhawk64
781c771827 3.18.5.1 2023-03-17 15:01:53 +11:00
rockyhawk64
07ee65796b 3.18.5.0 2023-03-17 12:30:14 +11:00
RockyHawk
206a80ea34
Merge pull request #247 from jman13378/jman13378-patch-1
broadcast command tag
2023-03-16 17:35:42 +11:00
Jonathan
69ee3e9050
Fixes some issues with the code 2023-03-13 13:30:50 -04:00
Jonathan
2f098308a7
Adds the command tags broadcast= and broadcast-perm= 2023-03-12 22:26:04 -04:00
Jonathan
fb774cefef
Adds the command tags broadcast= and broadcast-perm= 2023-03-12 22:22:50 -04:00
Jonathan
6ae6851174
Adds the command tags broadcast= and broadcast-perm= 2023-03-12 22:21:17 -04:00
rockyhawk64
d74d0b7051 3.18.4.1 2023-03-05 10:36:06 +11:00
rockyhawk64
24e1b3b6e4 3.18.4.0 2023-02-08 17:29:01 +11:00
RockyHawk
f3744a2bf7
Merge pull request #243 from jman13378/jman13378-patch-1
Double paywall send
2022-12-27 22:14:14 +11:00
Jonathan
3efb59b5ba
Create Placeholders.java 2022-12-19 13:57:12 -05:00
Jonathan
6b02153ce1
Delete Placeholders.java 2022-12-19 13:56:39 -05:00
Jonathan
0a5ac5314d
Update CommandTags.java 2022-12-19 13:49:28 -05:00
TheLonelyWolf1
3b100b7072
Merge pull request #239 from TheLonelyWolf1/master
Add PAPI and %cp-args%
2022-12-19 19:42:07 +01:00
TheLonelyWolf
b05ed2877f Add PAPI and %cp-args%
Adds PAPI Placeholder parsing to most if not all "Purchase"-related success/failure messages of CP
Adds %cp-args% parsing to most if not all "Purchase"-related success/failure messages of CP
2022-12-10 12:49:32 +01:00
TheLonelyWolf1
b0c4f64890
Merge pull request #238 from TheLonelyWolf1/master
Add newest CP-Version to Github Issue-Templates
2022-12-10 11:51:14 +01:00
TheLonelyWolf
f7ac2338bc Add newest CP-Version to Github Issue-Templates 2022-12-10 11:47:47 +01:00
rockyhawk64
c313dda282 Merge remote-tracking branch 'origin/master' 2022-11-25 17:56:34 +11:00
rockyhawk64
9da157a1fa 3.18.3.0 2022-11-25 17:56:28 +11:00
TheLonelyWolf1
209332e7b1
Merge pull request #233 from jman13378/jman13378-patch-1
added new releases to issue templates
2022-11-11 09:26:38 +01:00
jman13378
9f5c6bff63
Update need-help.yml 2022-10-30 15:52:16 -04:00
jman13378
f80fd1207f
Update bug_report.yml 2022-10-30 15:51:02 -04:00
rockyhawk64
6ed1b170f6 3.18.2.0 2022-10-27 09:29:46 +11:00
RockyHawk
b3662984f9
Merge pull request #230 from TheLonelyWolf1/master
Add force-server= CommandTag
2022-10-06 18:29:12 +11:00
rockyhawk64
94dadb97fd 3.18.1.4 2022-10-06 18:21:20 +11:00
rockyhawk64
659f545bc9 Merge remote-tracking branch 'origin/master' 2022-10-04 12:49:36 +11:00
rockyhawk64
efd8fdb3dd 3.18.1.3 2022-10-04 12:49:30 +11:00
TheLonelyWolf
3851ed4505 Add force-server= Bungeetag 2022-09-01 19:16:09 +02:00
RockyHawk
43e8f329ae
Merge pull request #229 from jman13378/jman13378-patch-1
New issue templates
2022-08-21 19:32:23 +10:00
jman13378
9614460fe5
Update need-help.yml 2022-08-20 23:08:08 -04:00
jman13378
4f91c0250c
Update need-help.yml 2022-08-20 23:07:24 -04:00
jman13378
d9e80a61ed
Update and rename need-help.md to need-help.yml 2022-08-20 23:07:06 -04:00
jman13378
afdc5b8b1c
Update feature_request.yml 2022-08-20 23:02:16 -04:00
jman13378
fe4a300d5b
Update feature_request.yml 2022-08-20 23:01:37 -04:00
jman13378
01bc7b9cbb
Rename feature_request.md to feature_request.yml 2022-08-20 23:01:00 -04:00
jman13378
ff25b03e04
Update feature_request.md 2022-08-20 23:00:50 -04:00
jman13378
a941a72f0b
Update and rename bug_report.md to bug_report.yml 2022-08-20 22:54:10 -04:00
rockyhawk64
b07cc32dce Merge remote-tracking branch 'origin/master' 2022-08-15 14:57:53 +10:00
rockyhawk64
57864c13d5 3.18.1.2 2022-08-15 14:57:48 +10:00
RockyHawk
73c97ce96b
Merge pull request #218 from TheLonelyWolf1/master
Add Serversoftware to Bugreport-Template
2022-08-02 14:06:08 +10:00
TheLonelyWolf1
414dfd9eb0
Merge branch 'rockyhawk64:master' into master 2022-07-18 13:41:11 +02:00
TheLonelyWolf1
95d23fc060
Add Serversoftware
Add "Serversoftware" to the details which we want the users to fill in their bug-report.
2022-07-18 13:40:58 +02:00
rockyhawk64
39b3e5917a 3.18.1.1 2022-07-07 15:32:16 +10:00
rockyhawk64
17168ef241 3.18.1.1 2022-07-01 11:19:00 +10:00
rockyhawk64
5032e5f218 3.18.1.0 2022-06-30 13:09:19 +10:00
RockyHawk
a429a38e4a
Merge pull request #210 from TheLonelyWolf1/master
Paywall-Message-Toggles | Remove Space after Tag | Use Tag provided by Main Class
2022-06-30 10:30:03 +10:00
TheLonelyWolf
9a621f98e0 Use Tag provided by the Main Class in CommandPanelsReload & add Togglevalues to config 2022-06-18 22:49:37 +02:00
TheLonelyWolf
f4ff0631d1 Add Toggles to Paywall Messages & use Tag provided by the Main Class 2022-06-18 22:39:46 +02:00
TheLonelyWolf
575c574a66 Remove hardcoded Space after Plugin Tag 2022-06-18 22:37:56 +02:00
rockyhawk64
5fa746950b 3.18.0.0 2022-06-17 15:40:38 +10:00
RockyHawk
b1c285149a
Merge pull request #207 from TheLonelyWolf1/master
Added MiniMessage Support as CommandTag
2022-06-17 14:51:57 +10:00
TheLonelyWolf
3d49d7281e Fix Failing Checks for PR 2022-06-16 12:20:54 +02:00
TheLonelyWolf
ace7691b7f Added MiniMessage Support as CommandTag
- CommandTags: minimessage=

Tested with: 1.19, 1.18, 1.16
DISCLAIMER: Only works on Paper 1.18 or newer!
2022-06-14 20:24:42 +02:00
rockyhawk64
8a1fe8c082 3.17.5.0 2022-06-13 14:21:01 +10:00
RockyHawk
0e3bd95b2d
Merge pull request #206 from TheLonelyWolf1/master
Added CoinsAPI Support
2022-06-13 14:15:39 +10:00
TheLonelyWolf
13efb6afe5 Added CoinsAPI Support
- Placeholders: %cp-coins-balance%
- CommandTags: coinbuycommand= , coinpaywall=, coinbuy=, coinsell=

Tested with: 1.19, 1.18, 1.17, 1.16, 1.15, 1.14, 1.13, 1.12
2022-06-11 12:53:32 +02:00
rockyhawk64
3033f42c9a 3.17.5.0 2022-05-24 18:16:00 +10:00
rockyhawk64
b3c3c5c0f2 3.17.4.3 2022-05-11 13:12:04 +10:00
rockyhawk64
a97337be43 3.17.4.3 2022-05-05 12:25:25 +10:00
rockyhawk64
082e6cd924 3.17.4.2 2022-04-28 13:56:41 +10:00
rockyhawk64
f1717d2deb 3.17.4.1 2022-04-28 00:43:51 +10:00
rockyhawk64
f35e96138d 3.17.4.0 2022-04-01 12:45:20 +11:00
rockyhawk64
d01d54fe43 3.17.3.1 2022-02-07 11:38:56 +11:00
rockyhawk64
ef819bc34f 3.17.3.0 2022-01-26 10:33:26 +11:00
rockyhawk64
a4943de958 3.17.2.2 2021-12-21 19:09:56 +11:00
rockyhawk64
284a5c7adc 3.17.2.1 2021-11-28 21:23:36 +11:00
rockyhawk64
e5a79ce937 3.17.2.1 2021-11-28 21:21:37 +11:00
rockyhawk64
b51fc7740d 3.17.2.0 2021-11-24 10:33:50 +11:00
RockyHawk
d27becbc10
Merge pull request #178 from TheLonelyWolf1/master
Fix bug with the delay-Tag | Add Custom No-Permission Messages | Input-Limit
2021-11-24 10:27:30 +11:00
TheLonelyWolf1
ca2664c6e7
Add Max.Character Message and Config
Add the default Max.Character Message and the limit-config
2021-11-20 15:22:04 +01:00
TheLonelyWolf1
39e505d8c8
Add Max.Character Input
Add the option to limit the length of the Input given by the Player
2021-11-20 15:20:11 +01:00
TheLonelyWolf1
10c9825776
Fix failing checks
Use opposite operator instead of negating the whole expression with a logic complement operator.
2021-11-20 13:17:21 +01:00
TheLonelyWolf1
d5149ad961
Custom No-Permission Messages
Add the option to have panel-only no-permission messages
2021-11-20 13:06:32 +01:00
TheLonelyWolf1
638700c961
Fix bug with the delay-Tag
This commit should fix the bug with the delay-tag not only deleting the first number.
2021-11-15 20:46:13 +01:00
rockyhawk64
1cb26d35f3 3.17.1.5 2021-10-24 14:49:09 +11:00
rockyhawk64
156e5ccb83 3.17.1.4 2021-09-29 03:09:14 +10:00
rockyhawk64
2bb57a42f5 3.17.1.3 2021-09-27 16:51:29 +10:00
rockyhawk64
3996a39dba 3.17.1.2 2021-09-19 15:21:00 +10:00
rockyhawk64
6a5019195e 3.17.1.1 2021-09-07 19:46:50 +10:00
rockyhawk64
fa33ffa1f8 3.17.1.0 2021-09-07 11:45:10 +10:00
rockyhawk64
64211d80be 3.17.0.0 2021-09-06 12:48:25 +10:00
rockyhawk64
bbb7f0bf55 3.16.3.2 2021-08-20 19:14:32 +10:00
rockyhawk64
e5f143f919 3.16.3.2 2021-08-20 19:14:05 +10:00
rockyhawk64
c2becfb961 Merge remote-tracking branch 'origin/master' 2021-08-11 20:54:52 +10:00
rockyhawk64
d55008e18c 3.16.3.1 2021-08-11 20:54:43 +10:00
RockyHawk
c345671eb6
Merge pull request #154 from TheLonelyWolf1/master
Add xp-points-paywall=
2021-08-10 17:01:27 +10:00
RockyHawk
5542a1f0f2
Update CommandTags.java 2021-08-10 17:00:49 +10:00
RockyHawk
d0c8939a35
Update Utils.java 2021-08-10 17:00:08 +10:00
rockyhawk64
b9854fa6e9 3.16.3.0 2021-08-10 16:55:51 +10:00
RockyHawk
9857a2d4fb
Merge branch 'master' into master 2021-08-10 16:48:13 +10:00
rockyhawk64
cc49f52396 3.16.3.0 2021-08-10 16:40:26 +10:00
rockyhawk64
ca5ac7151c 3.16.3.0 2021-08-10 16:32:00 +10:00
TheLonelyWolf1
7e4609efbf
Add xp-points-paywall= Messages 2021-08-06 16:28:21 +02:00
TheLonelyWolf1
f9d3b9780c
Add xp-points-paywall= 2021-08-06 16:27:22 +02:00
TheLonelyWolf1
3d85050e0f
Add xp-points-paywall= Functions
Add Functions used by the new CommandTag: `xp-points-paywall=`
2021-08-06 16:22:43 +02:00
rockyhawk64
3ca6fde19e 3.16.2.5 2021-07-29 20:38:31 +10:00
rockyhawk64
9dc1f1bacb 3.16.2.4 2021-07-18 11:29:37 +10:00
rockyhawk64
6aa3593a3f 3.16.2.3 2021-07-15 21:22:17 +10:00
rockyhawk64
c3274d7193 3.16.2.2 2021-07-15 19:29:35 +10:00
rockyhawk64
5a28956c8f 3.16.2.1 2021-07-14 21:51:20 +10:00
rockyhawk64
84c83affab 3.16.2.0 2021-07-14 17:53:48 +10:00
rockyhawk64
5dc197696f 3.16.1.1 2021-07-13 23:39:16 +10:00
rockyhawk64
e7b7872294 3.16.1.0 2021-07-13 20:05:30 +10:00
rockyhawk64
c26f8b2037 3.16.0.1 2021-07-08 19:03:29 +10:00
rockyhawk64
7cd8d6b49c 3.16.0.0 2021-07-07 20:58:12 +10:00
rockyhawk64
87a5765fd6 3.15.7.1 2021-07-04 18:15:39 +10:00
rockyhawk64
a88ffc13b4 3.15.7.0 2021-07-04 09:58:13 +10:00
rockyhawk64
8f6a222f15 3.15.7.0 2021-07-03 17:41:21 +10:00
rockyhawk64
27e233c4ec 3.15.6.2 2021-06-18 19:11:23 +10:00
rockyhawk64
27d59ccde5 3.15.6.1 2021-06-14 10:43:50 +10:00
rockyhawk64
a2f84d4f72 3.15.5.6 2021-06-07 13:16:57 +10:00
rockyhawk64
08691c557f 3.15.5.6 2021-06-01 16:48:35 +10:00
rockyhawk64
52600fe347 3.15.5.5 2021-05-26 11:51:50 +10:00
rockyhawk64
9d6a15bd87 v3.15.5.4 2021-05-17 21:57:08 +10:00
rockyhawk64
b87e7d8df1 v3.15.5.3 2021-05-17 20:34:12 +10:00
rockyhawk64
d0f28a11a5 v3.15.5.3 2021-05-17 20:03:46 +10:00
rockyhawk64
58af388ab0 v3.15.5.2 2021-05-10 19:44:14 +10:00
rockyhawk64
529eed9aa9 v3.15.5.2 2021-05-10 19:44:02 +10:00
rockyhawk64
c728262b9e v3.15.5.1 2021-05-05 10:14:21 +10:00
rockyhawk64
c01133ac81 v3.15.5.0 2021-05-04 18:53:34 +10:00
rockyhawk64
46a7dd13b4 3.15.4.0 #2 2021-04-03 12:32:10 +11:00
rockyhawk64
1a42ecfb02 3.15.4.0 2021-04-02 19:49:03 +11:00
rockyhawk64
b26a880b00 v3.15.3.1 2021-03-18 09:54:18 +11:00
rockyhawk64
6c0655e6e9 v3.15.3.0 2021-03-08 15:19:22 +11:00
rockyhawk64
19d18d10d4 v3.15.2.4 2021-02-07 11:28:05 +11:00
rockyhawk64
9f776c4161 v3.15.2.3 2021-02-06 23:26:19 +11:00
rockyhawk64
82931e03ea readme 2021-02-01 08:48:04 +11:00
rockyhawk64
0e1bd610ea v3.15.2.2 2021-01-31 19:51:44 +11:00
rockyhawk64
ed89e63d57 v3.15.2.1 2021-01-29 21:55:14 +11:00
rockyhawk64
45b9e4f8f3 v3.15.2.0 #2 2021-01-28 20:39:07 +11:00
rockyhawk64
be3e887362 v3.15.2.0 2021-01-28 20:13:22 +11:00
rockyhawk64
9dd653f1bb v3.15.1.3 2021-01-22 16:37:25 +11:00
rockyhawk64
3dc7758bc2 v3.15.1.2 2021-01-15 22:47:22 +11:00
rockyhawk64
b26164ee26 v3.15.1.1 2021-01-11 22:16:31 +11:00
rockyhawk64
e71f2bf52d v3.15.1.0 2021-01-11 21:10:11 +11:00
rockyhawk64
b5e8898b66 readme update 2021-01-11 16:11:15 +11:00
rockyhawk64
46eaa0ae34 readme update 2021-01-11 15:52:14 +11:00
rockyhawk64
2a64d83138 v3.15.0.1 2021-01-11 15:28:24 +11:00
rockyhawk64
afa91269cd v3.15.0.0 2021-01-11 03:14:24 +11:00
rockyhawk64
be52c1fa9d v3.14.6.0 2021-01-08 22:47:37 +11:00
rockyhawk64
4682cfec08 v3.14.5.3 2021-01-07 09:50:21 +11:00
rockyhawk64
3349b2aed9 v3.14.5.2 2021-01-06 21:21:42 +11:00
rockyhawk64
fed849f02f v3.14.5.1 2021-01-05 22:22:37 +11:00
rockyhawk64
e2b09581a4 v3.14.5.0 2021-01-04 16:48:41 +11:00
rockyhawk64
aabdd8a839 v3.14.4.6 #2 2021-01-04 10:30:15 +11:00
rockyhawk64
2fb64f9eb4 v3.14.4.6 2021-01-04 09:30:21 +11:00
rockyhawk64
da29469afe v3.14.4.5 2020-12-30 20:56:24 +11:00
rockyhawk64
ccface1e98 add full stops to bug reports & spigot page heading. 2020-12-29 22:22:24 +11:00
rockyhawk64
2652704a9d v3.14.4.4 2020-12-29 21:59:36 +11:00
rockyhawk64
f630b180fb v3.14.4.3 2020-12-29 19:13:54 +11:00
rockyhawk64
6a82798728 v3.14.4.2 #2 2020-12-27 20:53:01 +11:00
rockyhawk64
d594054c60 v3.14.4.2 2020-12-26 22:31:54 +11:00
rockyhawk64
9a1fd4033c v3.14.4.1 2020-12-25 21:59:52 +11:00
rockyhawk64
b003353e3a v3.14.4.0 2020-12-25 17:37:43 +11:00
rockyhawk64
f6aec68a1b v3.14.3.0 2020-12-23 20:38:46 +11:00
rockyhawk64
39ae5ff9fe v3.14.2.6 2020-12-21 13:07:35 +11:00
rockyhawk64
f7f1737115 readme update 2020-12-21 10:54:49 +11:00
rockyhawk64
d3b8d4f5d1 readme update 2020-12-21 10:53:48 +11:00
rockyhawk64
39ba798621 readme update 2020-12-21 10:52:57 +11:00
rockyhawk64
5f9a852b41 v3.14.2.5 2020-12-15 22:15:22 +11:00
rockyhawk64
45909f3b28 v3.14.2.4 2020-12-15 19:28:35 +11:00
rockyhawk64
99833c01d4 v3.14.2.3 2020-12-14 21:16:46 +11:00
rockyhawk64
a0d84c3120 readme update 2020-12-12 20:09:30 +11:00
rockyhawk64
9b3a880f77 Merge remote-tracking branch 'origin/master' 2020-12-12 18:40:49 +11:00
rockyhawk64
0620207ea1 v3.14.2.2 2020-12-12 18:40:40 +11:00
RockyHawk
d2233c8ecb
Create CODE_OF_CONDUCT.md 2020-12-11 19:59:08 +11:00
RockyHawk
de8987923e
Create LICENSE 2020-12-11 19:57:45 +11:00
RockyHawk
7fc3c7ab91
Merge pull request #85 from rockyhawk64/fireFerry-update-readme
Update README.md
2020-12-11 19:39:40 +11:00
fireFerry
1144b7baf1
Update README.md 2020-12-10 10:39:32 +01:00
rockyhawk64
00152786e0 v3.14.2.1 2020-12-08 12:23:37 +11:00
rockyhawk64
16fc049660 v3.14.2.0 2020-12-08 11:38:03 +11:00
rockyhawk64
e8c3d434cf v1.14.1.5 2020-12-07 22:49:22 +11:00
rockyhawk64
7b59112ed4 v3.14.1.4 2020-12-07 20:36:01 +11:00
rockyhawk64
2d55159924 v3.14.1.3 2020-12-05 23:38:12 +11:00
rockyhawk64
25f3fcf999 V3.14.1.2 2020-12-04 18:00:11 +11:00
rockyhawk64
ab214f1143 v3.14.1.1 2020-12-04 11:03:03 +11:00
rockyhawk64
e3872e11b8 v3.14.1.1 2020-12-04 11:02:33 +11:00
rockyhawk64
808b27ef8b v3.14.1.0 2020-12-03 00:53:19 +11:00
rockyhawk64
689a8cb0a6 v3.14.0.1 2020-11-27 17:38:12 +11:00
rockyhawk64
6226c146f8 v3.14.0.0 2020-11-20 18:53:48 +11:00
rockyhawk64
c5074bcd6b v3.13.1.1 2020-11-13 15:36:08 +11:00
rockyhawk64
d48bbbda51 v3.13.2 2020-11-13 15:32:28 +11:00
rockyhawk64
b6afddae20 v3.13.1 2020-11-13 13:58:21 +11:00
rockyhawk64
b72dcb4956 Update v3.13.0 2020-11-10 20:52:42 +11:00
rockyhawk64
d44c72a68b Fixes v3.12.6 2020-10-27 11:20:31 +11:00
rockyhawk64
0201b7b7cb v3.12.5 2020-10-19 15:40:32 +11:00
rockyhawk64
b8ed22a094 Merge remote-tracking branch 'origin/master' 2020-10-16 16:05:40 +11:00
rockyhawk64
8a84ceac33 3.12.4 Fixes 2020-10-16 16:05:33 +11:00
fireFerry
dfcce44024
Merge pull request #71 from rockyhawk64/revert-69-fireFerry-update-templates
Revert "Addition of new template"
2020-10-13 12:05:09 +02:00
fireFerry
c3242a7550
Revert "Addition of new template" 2020-10-13 12:04:50 +02:00
fireFerry
29bd67302d
Merge pull request #69 from rockyhawk64/fireFerry-update-templates
Addition of new template
2020-10-13 07:18:58 +02:00
fireFerry
30e58ed9fa
Update feature_request_server.md 2020-10-11 22:49:38 +02:00
fireFerry
310f00530a
Rename need-help.md to need_help.md 2020-10-11 22:48:23 +02:00
fireFerry
7ad0e7fede
Create feature_request_server.md 2020-10-11 22:47:45 +02:00
fireFerry
f54f58751e
Update feature_request.md 2020-10-11 22:41:30 +02:00
rockyhawk64
8cb27f4957 Merge remote-tracking branch 'origin/master' 2020-10-07 18:31:38 +11:00
rockyhawk64
65250e8a53 v3.12.3 Fixes 2020-10-07 18:31:31 +11:00
RockyHawk
7b55fa9fb8
Merge pull request #67 from itsaderm/patch-1
Patch 1
2020-10-07 11:05:53 +11:00
Adam L
13c797197e
Merge pull request #1 from itsaderm/itsaderm-patch-1
Update README.md
2020-10-06 20:35:01 +01:00
Adam L
b677f86392
Update README.md 2020-10-06 20:34:49 +01:00
Adam L
f6ada4bb7d
Cleaned up readme, made it easier to read 2020-10-06 20:33:18 +01:00
rockyhawk64
21bb0913be v3.12.2 Fixes 2020-10-07 03:16:49 +11:00
rockyhawk64
b87a45130e 3.12.1 Fixes 2020-10-05 23:09:10 +11:00
rockyhawk64
5104d8e93f v3.12.0 2020-09-30 11:43:19 +10:00
BuildTools
5e5b4a723c 3.11.2 Fixes 2020-09-21 19:12:20 +10:00
rockyhawk64
b789328985 Legacy Fixes v3.11.1 2020-09-12 09:39:45 +10:00
rockyhawk64
401ea967ea Update v3.11.0 2020-09-10 21:01:51 +10:00
rockyhawk64
44dc044fe5 fixes v3.10.5 2020-09-06 21:27:51 +10:00
rockyhawk64
41a2e29777 3.10.4 Fixes 2020-09-03 22:39:25 +10:00
165 changed files with 11003 additions and 6422 deletions

View File

@ -0,0 +1,30 @@
name: Build CommandPanels plugin
run-name: Build CommandPanels plugin
on: [push]
jobs:
Build-latest-jar:
runs-on: ubuntu-latest
steps:
- name: Build | Prepare packages
run: |
apt update; apt-get install software-properties-common -y
wget -O- https://apt.corretto.aws/corretto.key | apt-key add -
add-apt-repository 'deb https://apt.corretto.aws stable main'
apt-get update; apt-get install -y maven java-21-amazon-corretto-jdk
- name: Setup git
run: |
git config --global user.name "Radim Lipovčan"
git config --global user.email "radim@lipovcan.cz"
- name: Check out repository code
uses: actions/checkout@v4
- name: Build | Maven clean build
run: |
mvn clean install && ls -lah && ls */ -lah && ls */* -lah&& ls */*/* -lah
- name: Push | Create release
uses: https://git.lipovcan.cz/Upstream/gitea-release-action.git@v1
with:
files: |-
target/CommandPanels-DEV.jar
- name: Push | Old FTP way to gitea.lipovcan.cz:8081
run: |
curl --insecure --user username:mypass -T ./target/CommandPanels-DEV.jar ftp://192.168.10.133:/

View File

@ -1,42 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug'
assignees: ''
---
### Have you checked the [wiki](https://rockyhawk99.gitbook.io/rockyhawk-wiki/commandpanels/wiki) page to see if there is a solution for your bug?
Yes/No
### Have you looked at the [Current bugs project](https://github.com/rockyhawk64/CommandPanels/projects/6) to see if your bug is listed there?
Yes/No
### Have you asked for help in the [Discord Server](https://discord.com/invite/eUWBWh7)? *(Or got redirected to a Github issue here)*
Yes/No
### Did you search the [issue tracker](https://github.com/rockyhawk64/CommandPanels/issues?q=is%3Aissue) for a similar problem?
Yes/No
### Describe the bug
A clear and concise description of what the bug is.
### To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
### Expected behavior
A clear and concise description of what you expected to happen.
### Screenshots/videos
If applicable, add screenshots or videos to help explain your problem.
### Versions:
- Minecraft: [e.g. 1.16]
- CommandPanels: [e.g. 3.2.0]
### Additional context/Panel files
Add any other context or about the problem here. Please also send you're panel in question. We only accept [pastebin](https://pastebin.com/) links.

177
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,177 @@
name: Bug Report
description: File a bug report
labels: ["bug"]
body:
- type: checkboxes
id: searched
attributes:
label: Terms
options:
- label: "Have you checked the [wiki](https://rockyhawk99.gitbook.io/rockyhawk-wiki/commandpanels/wiki) page to see if there is a solution for your bug?"
required: true
- label: "Have you looked at the [Current bugs project](https://github.com/rockyhawk64/CommandPanels/projects/6) to see if your bug is listed there?"
required: true
- label: Have you asked for help in the [Discord Server](https://discord.com/invite/eUWBWh7)? (Or got redirected to a Github issue here)
required: true
- label: Did you search the [issue tracker](https://github.com/rockyhawk64/CommandPanels/issues?q=is%3Aissue) for a similar problem?
required: true
- type: dropdown
id: server_version
attributes:
label: What server version are you running?
options:
- 1.7
- 1.8
- 1.9
- 1.10
- 1.11
- 1.12
- 1.13
- 1.14
- 1.15
- 1.16
- 1.17
- 1.18
- 1.19
- 1.20
validations:
required: true
- type: dropdown
id: commandpanels_version
attributes:
label: What CommandPanels version are you using?
options:
- latest
- 3.20.0.3
- 3.20.0.2
- 3.20.0.1
- 3.19.0.3
- 3.19.0.2
- 3.19.0.1
- 3.19.0.0
- 3.18.6.2
- 3.18.6.1
- 3.18.6.0
- 3.18.5.1
- 3.18.5.0
- 3.18.4.1
- 3.18.4.0
- 3.18.3.0
- 3.18.2.0
- 3.18.1.4
- 3.18.1.3
- 3.18.1.2
- 3.18.1.1
- 3.18.1.0
- 3.18.0.0
- 3.17.5.0
- 3.17.4.3
- 3.17.4.2
- 3.17.4.1
- 3.17.4.0
- 3.17.3.1
- Any other version
validations:
required: true
- type: dropdown
id: server_software
attributes:
label: What server software are you running?
options:
- PaperMC
- Purpur
- Spigot
- CraftBukkit
- Glowstone
- Magma
- Mohist
- WaterFall
- BungeeCord
- Velocity
- Travertine
- Other
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: What happened?
description: A clear and concise description of what the bug is.
placeholder: Tell us what you see!
placeholder: "Example: I can't interact with custom furniture if I'm in my own claim"
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce the issue
description: Describe how to reproduce the issue step by step
placeholder: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
id: expected_behavior
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
placeholder: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
id: logs
attributes:
label: Error (optional)
description: Please copy and paste any error you got (this will be automatically formatted into code).
render: shell
placeholder: "|
[17:10:16 ERROR]: Could not pass event PlayerInteractEvent to CommandPanels v3.18.1.1
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[server1.jar:git-PaperSpigot-f6b10d47]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[server1.jar:git-PaperSpigot-f6b10d47]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server1.jar:git-PaperSpigot-f6b10d47]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) ~[server1.jar:git-PaperSpigot-f6b10d47]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:502) ~[server1.jar:git-PaperSpigot-f6b10d47]
at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:228) ~[server1.jar:git-PaperSpigot-f6b10d47]
at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:195) ~[server1.jar:git-PaperSpigot-f6b10d47]
at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:191) ~[server1.jar:git-PaperSpigot-f6b10d47]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:721) ~[server1.jar:git-PaperSpigot-f6b10d47]
at net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:52) ~[server1.jar:git-PaperSpigot-f6b10d47]
at net.minecraft.server.v1_8_R3.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:1) ~[server1.jar:git-PaperSpigot-f6b10d47]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) ~[server1.jar:git-PaperSpigot-f6b10d47]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_292]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_292]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) ~[server1.jar:git-PaperSpigot-f6b10d47]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:741) ~[server1.jar:git-PaperSpigot-f6b10d47]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:366) ~[server1.jar:git-PaperSpigot-f6b10d47]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:680) ~[server1.jar:git-PaperSpigot-f6b10d47]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:583) ~[server1.jar:git-PaperSpigot-f6b10d47]
at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_292] Caused by: java.lang.NullPointerException
at me.rockyhawk.commandpanels.panelblocks.PanelBlockOnClick.onInteract(PanelBlockOnClick.java:23) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[server1.jar:git-PaperSpigot-f6b10d47]
... 19 more"
- type: textarea
id: configuration_files
attributes:
label: Other files, you can drag and drop them here to upload. (optional)
description: Drag and drop your files here.
- type: textarea
id: screenshots
attributes:
label: Screenshots/Videos (you can drag and drop files or paste links)
description: If applicable, add screenshots to help explain your problem (you can drag and drop files or paste links).
- type: markdown
attributes:
value: |
## Thanks for taking the time to fill out this bug report!

View File

@ -1,28 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'enhancement'
assignees: ''
---
### Have you checked the [wiki](https://rockyhawk99.gitbook.io/rockyhawk-wiki/commandpanels/wiki) page to see if your suggestion is already added?
Yes/No
### Have you checked the [issue tracker](https://github.com/rockyhawk64/CommandPanels/issues?q=is%3Aissue) to see if your suggestion was already submitted and denied?
Yes/No
### Have you asked if the feature already exists in the [Discord Server](https://discord.com/invite/eUWBWh7)? *(Or got redirected to a Github issue here)*
Yes/No
### Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
### Describe the solution you'd like
A clear and concise description of what you want to happen.
### Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
### Additional context
Add any other context or screenshots about the feature request here.

View File

@ -0,0 +1,46 @@
name: Feature request
description: Suggest an idea for this project
labels: ["enhancement"]
body:
- type: checkboxes
id: searched
attributes:
label: Terms
options:
- label: "Have you checked the [wiki](https://rockyhawk99.gitbook.io/rockyhawk-wiki/commandpanels/wiki) page to see if your suggestion is already added?"
required: true
- label: "Have you checked the [Current bugs project](https://github.com/rockyhawk64/CommandPanels/projects/6) to see if your suggestion was already submitted and or denied?"
required: true
- label: "Have you asked if the feature already exists in the [Discord Server](https://discord.com/invite/eUWBWh7)? (Or got redirected to a Github issue here)"
required: true
- type: textarea
id: what-happened
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is.
placeholder: "Example: I'm always frustrated when [...]"
validations:
required: true
- type: textarea
id: solution
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Screenshots/Videos (you can drag and drop files or paste links)
description: Add any other context or screenshots about the feature request here.
- type: markdown
attributes:
value: |
## Thanks for taking the time to fill out this feature request!

View File

@ -1,32 +0,0 @@
---
name: Need help
about: Create an issue for a problem you are having.
title: ''
labels: 'help wanted'
assignees: ''
---
### Have you checked the [wiki](https://rockyhawk99.gitbook.io/rockyhawk-wiki/commandpanels/wiki) page to see if the solution for your problem is there?
Yes/No
### Have you checked the [issue tracker](https://github.com/rockyhawk64/CommandPanels/issues?q=is%3Aissue) to see if your issue is a duplicate and your problem already has been solved?
Yes/No
### Have you asked for help in the [Discord Server](https://discord.com/invite/eUWBWh7)? *(Or got redirected to a Github issue here)*
Yes/No
### Describe the Issue
A clear and concise description of what the problem is.
### Expected behavior
A clear and concise description of what you expected to happen.
### Screenshots/videos
If applicable, add screenshots or videos to help explain your problem.
### Versions:
- Minecraft: [e.g. 1.16]
- CommandPanels: [e.g. 3.2.0]
### Additional context/Panel files
Add any other context about the problem here. Please also send you're panel in question. We only accept [pastebin](https://pastebin.com/) links.

122
.github/ISSUE_TEMPLATE/need-help.yml vendored Normal file
View File

@ -0,0 +1,122 @@
name: Need help
description: Create an issue for a problem you are having.
labels: [ "help wanted" ]
body:
- type: checkboxes
id: searched
attributes:
label: Terms
options:
- label: "Have you checked the [wiki](https://rockyhawk99.gitbook.io/rockyhawk-wiki/commandpanels/wiki) page to see if the solution for your problem is there?"
required: true
- label: "Have you checked the [Current bugs project](https://github.com/rockyhawk64/CommandPanels/projects/6) to see if your issue is a duplicate and your problem already has been solved?"
required: true
- label: "Have you asked for help in the [Discord Server](https://discord.com/invite/eUWBWh7)? (Or got redirected to a Github issue here)"
required: true
- type: dropdown
id: server_version
attributes:
label: What server version are you running?
options:
- 1.7
- 1.8
- 1.9
- 1.10
- 1.11
- 1.12
- 1.13
- 1.14
- 1.15
- 1.16
- 1.17
- 1.18
- 1.19
- 1.20
validations:
required: true
- type: dropdown
id: commandpanels_version
attributes:
label: What CommandPanels version are you using?
options:
- latest
- 3.20.0.3
- 3.20.0.2
- 3.20.0.1
- 3.19.0.3
- 3.19.0.2
- 3.19.0.1
- 3.19.0.0
- 3.18.6.2
- 3.18.6.1
- 3.18.6.0
- 3.18.5.1
- 3.18.5.0
- 3.18.4.1
- 3.18.4.0
- 3.18.3.0
- 3.18.2.0
- 3.18.1.4
- 3.18.1.3
- 3.18.1.2
- 3.18.1.1
- 3.18.1.0
- 3.18.0.0
- 3.17.5.0
- 3.17.4.3
- 3.17.4.2
- 3.17.4.1
- 3.17.4.0
- 3.17.3.1
- Any other version
validations:
required: true
- type: dropdown
id: server_software
attributes:
label: What server software are you running?
options:
- PaperMC
- Purpur
- Spigot
- CraftBukkit
- Glowstone
- Magma
- Mohist
- WaterFall
- BungeeCord
- Velocity
- Travertine
validations:
required: true
- type: textarea
id: what-happened
attributes:
label: Describe the Issue
description: A clear and concise description of what the problem is.
placeholder: "Example: How can I add commands to a item"
validations:
required: true
- type: textarea
id: description
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: files
attributes:
label: Additional context/Panel files
description: Add any other context about the problem here. Please also send you're panel in question. We only accept [pastebin](https://pastebin.com/) links.
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Screenshots/Videos (you can drag and drop files or paste links)
description: Add any other context or screenshots about the feature request here.
- type: markdown
attributes:
value: |
## Thanks for taking the time to fill out this help request!

5
.gitignore vendored
View File

@ -1,2 +1,5 @@
# Project exclude paths
/out/
/out/
/target/
.idea/
.github

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
CommandPanels

View File

@ -1,9 +0,0 @@
<component name="ArtifactManager">
<artifact type="jar" name="Command Panels">
<output-path>$PROJECT_DIR$/out/artifacts/Command_Panels</output-path>
<root id="archive" name="Command Panels.jar">
<element id="file-copy" path="$PROJECT_DIR$/resource/plugin.yml" />
<element id="module-output" name="Command Panels" />
</root>
</artifact>
</component>

13
.idea/compiler.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="CommandPanels" />
</profile>
</annotationProcessing>
</component>
</project>

9
.idea/encodings.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/resource" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/resource_editor" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/resource_example" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src" charset="UTF-8" />
</component>
</project>

115
.idea/jarRepositories.xml Normal file
View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jitpack.io" />
<option name="name" value="jitpack.io" />
<option name="url" value="https://jitpack.io" />
</remote-repository>
<remote-repository>
<option name="id" value="jeff-media-public" />
<option name="name" value="jeff-media-public" />
<option name="url" value="https://hub.jeff-media.com/nexus/repository/jeff-media-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="io.papermc" />
<option name="name" value="io.papermc" />
<option name="url" value="https://papermc.io/repo/repository/maven-releases/" />
</remote-repository>
<remote-repository>
<option name="id" value="sonatype" />
<option name="name" value="sonatype" />
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="io.papermc" />
<option name="name" value="io.papermc" />
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="codemc-repo" />
<option name="name" value="codemc-repo" />
<option name="url" value="https://repo.codemc.io/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="opencollab-snapshot" />
<option name="name" value="opencollab-snapshot" />
<option name="url" value="https://repo.opencollab.dev/main/" />
</remote-repository>
<remote-repository>
<option name="id" value="placeholderapi" />
<option name="name" value="placeholderapi" />
<option name="url" value="https://repo.extendedclip.com/content/repositories/placeholderapi/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="oraxen" />
<option name="name" value="Oraxen Repository" />
<option name="url" value="https://repo.oraxen.com/#/releases" />
</remote-repository>
<remote-repository>
<option name="id" value="phoenix" />
<option name="name" value="phoenix" />
<option name="url" value="https://nexus.phoenixdevt.fr/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BenCodez Repo" />
<option name="name" value="BenCodez Repo" />
<option name="url" value="https://nexus.bencodez.com/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="central" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="oraxen" />
<option name="name" value="Oraxen Repository" />
<option name="url" value="https://repo.oraxen.com/releases" />
</remote-repository>
<remote-repository>
<option name="id" value="github" />
<option name="name" value="github" />
<option name="url" value="https://maven.pkg.github.com/xap3y/skullcreator" />
</remote-repository>
<remote-repository>
<option name="id" value="jitpack-repo" />
<option name="name" value="jitpack-repo" />
<option name="url" value="https://jitpack.io" />
</remote-repository>
<remote-repository>
<option name="id" value="ess-repo" />
<option name="name" value="ess-repo" />
<option name="url" value="https://repo.essentialsx.net/releases/" />
</remote-repository>
<remote-repository>
<option name="id" value="spigot-repo" />
<option name="name" value="spigot-repo" />
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="jeff-media-public" />
<option name="name" value="jeff-media-public" />
<option name="url" value="https://repo.jeff-media.com/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="minecraft-repo" />
<option name="name" value="minecraft-repo" />
<option name="url" value="https://libraries.minecraft.net/" />
</remote-repository>
</component>
</project>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="HeadDatabaseAPI">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/HeadDatabaseAPI.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.kyori:adventure-api:4.11.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-api/4.11.0/adventure-api-4.11.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-api/4.11.0/adventure-api-4.11.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-api/4.11.0/adventure-api-4.11.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.kyori:adventure-key:4.11.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-key/4.11.0/adventure-key-4.11.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-key/4.11.0/adventure-key-4.11.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-key/4.11.0/adventure-key-4.11.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: net.kyori:adventure-text-minimessage:4.11.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-text-minimessage/4.11.0/adventure-text-minimessage-4.11.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-text-minimessage/4.11.0/adventure-text-minimessage-4.11.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-text-minimessage/4.11.0/adventure-text-minimessage-4.11.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="PlaceholderAPI-2.10.8">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/PlaceholderAPI-2.10.8.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="TokenManager-3.2.4">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/TokenManager-3.2.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="Vault">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/Vault.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="VotingPlugin">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/VotingPlugin.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="spigot-1.13.2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot-1.13.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot-1.13.2.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="spigot-1.16.1">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot-1.16.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot-1.16.1.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
<option name="workspaceImportForciblyTurnedOn" value="true" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="17" project-jdk-type="JavaSDK" />
</project>

View File

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Command Panels.iml" filepath="$PROJECT_DIR$/Command Panels.iml" />
<module fileurl="file://$PROJECT_DIR$/CommandPanels.iml" filepath="$PROJECT_DIR$/CommandPanels.iml" />
</modules>
</component>
</project>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resource" type="java-resource" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="HeadDatabaseAPI" level="project" />
<orderEntry type="library" name="TokenManager-3.2.4" level="project" />
<orderEntry type="library" name="Vault" level="project" />
<orderEntry type="library" name="VotingPlugin" level="project" />
<orderEntry type="library" name="PlaceholderAPI-2.10.8" level="project" />
<orderEntry type="library" name="spigot-1.16.1" level="project" />
<orderEntry type="library" name="spigot-1.13.2" level="project" />
</component>
</module>

14
CommandPanels.iml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>ADVENTURE</platformType>
<platformType>SPIGOT</platformType>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>

674
LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -1,10 +1,36 @@
# CommandPanels
Command Panels main Github page. Wiki Page Below:
![TitleLogo](https://i.imgur.com/YQMXkoi.png)
https://rockyhawk99.gitbook.io/rockyhawk-wiki/
<p align="center">
<a href="https://discord.gg/eUWBWh7"><img src="https://i.imgur.com/50KoZcJ.png" alt="Discord"></a>
<a href="https://commandpanels.net/wiki"><img src="https://i.imgur.com/kR6n5uw.png" alt="Wiki"></a>
<a href="https://commandpanels.net/editor"><img src="https://i.imgur.com/hg68XFc.png" alt="Editor"></a>
</p>
Discord: https://discord.gg/eUWBWh7
<img align="center" src="https://i.imgur.com/w8UaAP2.png" alt="Screenshot">
For bug reports, issues or feature requests, please look at https://github.com/rockyhawk64/CommandPanels/issues
## Partner
ReviveNode is a leading Minecraft hosting provider that offers affordable and high-quality server hosting solutions. Their focus on performance, reliability, and customer support makes them the perfect partner for CommandPanels.
For new features currently being worked on, please look at https://github.com/rockyhawk64/CommandPanels/projects
We have proudly partnered with [ReviveNode](http://billing.revivenode.com/aff.php?aff=379)!
CommandPanels users have been offered 15% off on the first month by using the Promocode: **PANELS**
## About
Minecraft Servers use GUIs for many different tasks from lobbies to shops. Command Panels takes a simple approach to YAML scripting to create a powerful yet simple design. Use variables, data, placeholders and other powerful tools to fully customize your GUIs.
Command Panels treats the inventory as three different sections, you have the Top, Middle and Bottom. Which are the Chest, Player and Hotbar locations. You can have three GUIs running simultaneously, by simply choosing which location you want a panel to open!
Making a plugin? You can use Command Panels as a library to make your own GUIs for your plugins. It's as simple as making a panel, adding the panel YAML file to your plugin and adding one line of code to open the panel.
## Main Features
**Online Editor** Offers simple GUI creation, the layout and logic has been simplified for easier usage.
**Animations, Logic, Data** are some of the powerful YAML tools that can be used in your GUIs!
**Player Inventory** allows you to extend the GUI into the player's inventory area underneath, to make advanced menu experiences!
**Developer API** for easy GUI creation in your own plugins (using this as a dependency) or simply to interact with Command Panels.
### Spigot Page
You can find the spigot page for the plugin [here](https://www.spigotmc.org/resources/67788/).

2
jitpack.yml Normal file
View File

@ -0,0 +1,2 @@
jdk:
- openjdk17

217
pom.xml Normal file
View File

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.rockyhawk.commandpanels</groupId>
<artifactId>CommandPanels</artifactId>
<version>DEV</version>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<src.dir>src</src.dir>
</properties>
<build>
<sourceDirectory>${src.dir}</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>org.bukkit.craftbukkit.libs.org.apache.commons.io</pattern>
<shadedPattern>org.apache.commons.io</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>me.rockyhawk.commandpanels.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>de.tr7zw.changeme.nbtapi</pattern>
<shadedPattern>me.rockyhawk.commandpanels.nbtapi</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>resource</directory>
</resource>
<resource>
<directory>resource_editor</directory>
</resource>
<resource>
<directory>resource_example</directory>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>io.papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jeff-media-public</id>
<url>https://repo.jeff-media.com/public/</url>
</repository>
<repository>
<id>ess-repo</id>
<url>https://repo.essentialsx.net/releases/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>phoenix</id>
<url>https://nexus.phoenixdevt.fr/repository/maven-public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
<repository>
<id>opencollab-snapshot</id>
<url>https://repo.opencollab.dev/main/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.14.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.17.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.jeff_media</groupId>
<artifactId>ChestSortAPI</artifactId>
<version>13.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.11.50</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.Indyuce</groupId>
<artifactId>MMOItems-API</artifactId>
<version>6.10-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.lumine</groupId>
<artifactId>MythicLib-dist</artifactId>
<version>1.6.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.arcaniax</groupId>
<artifactId>HeadDatabase-API</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.LoneDev6</groupId>
<artifactId>api-itemsadder</artifactId>
<version>3.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.8</version>
</dependency>
<dependency>
<groupId>net.essentialsx</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.20.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.2.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,34 +1,80 @@
# |------------------------------------------------------------------------
# | CommandPanels Config File
# | By RockyHawk v4.0
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# | By RockyHawk v5.2
# | https://www.spigotmc.org/resources/67788/
# |
# |------------------------------------------------------------------------
config:
refresh-panels: true
refresh-delay: 20
panel-blocks: true
refresh-delay: 4
hotbar-items: true
custom-commands: true
auto-register-commands: false
auto-update-panels: false
server-ping-timeout: 10
stop-sound: true
disabled-world-message: true
update-notifications: true
panel-snooper: false
ingame-editor: true
input-cancel: cancel
input-cancelled: '&cCancelled!'
input-message:
- '%cp-tag%&aEnter Input for Command'
- '&cType &4%cp-args% &cto Cancel the command'
enable-import-command: false
format:
tag: '&6[&bCommandPanels&6]'
tag: '&6[&bCommandPanels&6] '
perms: '&cNo permission.'
reload: '&aReloaded.'
nopanel: '&cPanel not found.'
noitem: '&cPanel doesn''t have clickable item.'
notitem: '&cPlayer not found.'
error: '&cError found in config at'
needmoney: '&cInsufficient Funds!'
needitems: '&cInsufficient Items!'
bought: '&aSuccessfully Bought For $%cp-args%'
sold: '&aSuccessfully Sold Item!'
error: '&cError found in config.'
offline: 'Offline'
offlineHeadValue: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmU1Mjg2YzQ3MGY2NmZmYTFhMTgzMzFjYmZmYjlhM2MyYTQ0MjRhOGM3MjU5YzQ0MzZmZDJlMzU1ODJhNTIyIn19fQ=='
input: '&cYour Input is too long!'
disabled: '&cThis feature is disabled in your plugin config.'
input:
input-cancel: cancel
input-cancelled: '&cCancelled!'
max-input-length: -1
input-message:
- '&aEnter Input for Command'
- '&cType &4%cp-args% &cto Cancel the command'
hexcodes:
start_tag: '&#'
end_tag: ''
placeholders:
primary:
start: '%'
end: '%'
secondary:
start: '{'
end: '}'
updater:
auto-update: false
update-checks: true
purchase:
currency:
enable: true
success: '&aSuccessfully Bought For $%cp-args%'
failure: '&cInsufficient Funds!'
data:
enable: true
success: '&aSuccessfully Bought For $%cp-args%'
failure: '&cInsufficient Funds!'
tokens:
enable: true
success: '&aSuccessfully Bought For %cp-args% Tokens.'
failure: '&cInsufficient Tokens!'
coins:
enable: true
success: '&aSuccessfully Bought For %cp-args% Coins.'
failure: '&cInsufficient Coins!'
item:
enable: true
success: '&aSuccessfully Sold %cp-args%.'
failure: '&cInsufficient Items!'
xp:
enable: true
success: '&aSuccessfully Bought For %cp-args% Experience.'
failure: '&cInsufficient Experience!'
permission:
enable: true
success: '&aYou have successfully passed the permission check for "%cp-args%".'
failure: '&cInefficient Permissions'

View File

@ -1,10 +1,10 @@
version: 3.10.3
main: me.rockyhawk.commandPanels.commandpanels
version: 3.21.4.4
main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels
author: RockyHawk
api-version: '1.13'
description: Fully Custom GUIs. Make your Server Professional.
softdepend: [PlaceholderAPI, Vault, HeadDatabase, TokenManager, VotingPlugin]
softdepend: [Essentials, PlaceholderAPI, Vault, HeadDatabase, TokenManager, VotingPlugin, MMOItems, ChestSort, floodgate]
commands:
commandpanel:
description: Open a command panel.
@ -14,6 +14,14 @@ commands:
description: Reloads plugin config.
usage: /commandpanelreload
aliases: [cpr, cpanelr]
commandpaneldata:
description: Change data values for players
usage: /commandpaneldata
aliases: [cpdata]
commandpanelupdate:
description: Refresh/update panel/s for player
usage: /commandpanelupdate
aliases: [ cpu, cpanelu ]
commandpaneldebug:
description: Enable and Disable debug mode globally
usage: /commandpaneldebug
@ -22,10 +30,6 @@ commands:
description: Add or remove panels from blocks being looked at.
usage: /commandpanelblock
aliases: [cpb, cpanelb]
commandpanelclose:
description: Close current GUI.
usage: /commandpanelclose
aliases: [cpc, cpanelc]
commandpanelgenerate:
description: Generate GUI.
usage: /commandpanelgenerate
@ -34,18 +38,18 @@ commands:
description: Display the current version.
usage: /commandpanelversion
aliases: [cpv, cpanelv]
commandpaneladdons:
description: Find downloadable panels online.
usage: /commandpaneladdons
aliases: [cpa, cpanela]
commandpaneledit:
description: Edit panels ingame.
usage: /commandpaneledit [panel]
usage: /commandpaneledit <panel>
aliases: [cpe, cpanele]
commandpanellist:
description: Lists the currently loaded panels.
usage: /commandpanellist
aliases: [cpl, cpanell]
commandpanelimport:
description: Import raw text panels from online.
usage: /commandpanelimport
aliases: [cpi, cpaneli]
permissions:
commandpanel.panel.default:
default: true
@ -69,11 +73,15 @@ permissions:
default: op
commandpanel.version:
default: true
commandpanel.addons:
default: true
commandpanel.editor:
default: true
commandpanel.update:
default: op
commandpanel.data:
default: op
commandpanel.refresh:
default: op
commandpanel.edit:
default: op
commandpanel.list:
default: op
commandpanel.import:
default: op

View File

@ -1,31 +1,44 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | By RockyHawk v2.0
# | CommandPanels Legacy Example File
# | Official Panel v2.4
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
example:
perm: default
panelType: default
perm: admin
rows: 4
title: '&6[&bExample Panel&6]&f Welcome!'
command: example
sound-on-open: BLOCK_NOTE_BLOCK_CHIME
empty: BLACK_STAINED_GLASS_PANE
commands:
- "example"
empty: STAINED_GLASS_PANE
emptyID: 15
disabled-worlds:
- 'world_nether'
- 'world_nether'
open-with-item:
material: CLOCK
material: PAPER
name: '&6[&bExample Panel&6]'
lore:
- '&3Click me to open the panel!'
stationary: 4
- '&3Click me to open the panel!'
item:
'0':
material: LEATHER_HELMET
name: '&d&lPURPLE'
leatherarmor: PURPLE
damage: 30
'1':
material: DIAMOND
name: '&fThis is a diamond'
lore: "&7Feel free to take me!"
itemType:
- placeable
'10':
material: REDSTONE_BLOCK
name: '&fTake the diamond'
has0:
value0: NOT DIAMOND
compare0: '%cp-material-1%'
name: '&fNice One!'
material: EMERALD_BLOCK
'9':
material: LEATHER_CHESTPLATE
name: '&9&lBLUE'
@ -73,18 +86,19 @@ panels:
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzE5ZjUwYjQzMmQ4NjhhZTM1OGUxNmY2MmVjMjZmMzU0MzdhZWI5NDkyYmNlMTM1NmM5YWE2YmIxOWEzODYifX19
name: '&e&lL'
'20':
material: RED_WOOL
material: WOOL
ID: 14
name: '&cYour nickname is not ''RockyHawk'''
commands:
- 'msg= &cNot RockyHawk'
hasvalue:
output: true
value: RockyHawk
compare: '%cp-player-name%'
material: LIME_WOOL
- 'msg= &cNot RockyHawk'
has0:
value0: RockyHawk
compare0: '%cp-player-name%'
material: WOOL
ID: 5
name: '&aYour username is ''RockyHawk'''
commands:
- 'msg= &aWelcome my master!'
- 'msg= &aWelcome my master!'
'27':
material: LEATHER_BOOTS
name: '&e&lYELLOW'
@ -93,41 +107,41 @@ panels:
'32':
material: COMPASS
stack: 12
enchanted: true
enchanted:
- true
name: '&cClick Me'
lore:
- '&fI will teleport you home!'
- '&fI will teleport you home!'
commands:
- home
- commandpanels:commandpanelclose
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"}
- console= title %cp-player-name% title {"text":"Welcome Home"}
- home
- cpc
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"}
- console= title %cp-player-name% title {"text":"Welcome Home"}
'30':
material: POTION
ID: 8225
name: '&5&lInstant Health II'
potion: INSTANT_HEAL
commands:
- heal
- commandpanels:commandpanelclose
- heal
- cpc
'34':
material: REDSTONE_BLOCK
name: '&cNo Permission'
lore:
- '&4You cannot change to'
- '&4creative looking like that!'
hasperm:
perm: essentials.gamemode
output: true
- '&4You cannot change to'
- '&4creative looking like that!'
has0:
value0: '%cp-player-name% HASPERM'
compare0: essentials.gamemode
material: EMERALD_BLOCK
name: '&aClick Me'
lore:
- '&2I will change you'
- '&2to creative mode!'
- '&2I will change you'
- '&2to creative mode!'
commands:
- gamemode creative
- commandpanels:commandpanelclose
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"You are now in creative
mode!","color":"green"}
- console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"}
- gamemode creative
- cpc
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"You are now in creative mode!","color":"green"}
- console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"}

View File

@ -0,0 +1,50 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | Official Panel v3.1
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
example_bottom:
perm: default
rows: 3
title: 'Example'
empty: LIGHT_BLUE_STAINED_GLASS_PANE
panelType:
- nocommand
item:
'0':
material: BARRIER
name: '&cClose the panel'
commands:
- cpc
'4':
material: cps= self
name: '&7Name: &eRockyHawk'
lore:
- ''
- '&8Example Panel made by:'
- '&8RockyHawk'
'8':
material: ENDER_PEARL
name: '&bOpen Player Browser'
lore:
- '&7The Player Browser requires'
- '&7PlaceholderAPI with the Math extension'
has1:
compare0: '%math_0:_1+1%'
value0: '2'
material: ENDER_PEARL
name: '&bOpen Player Browser'
commands:
- open= example_middle_two {Middle}
has0:
compare0: '%cp-data-example_item%'
value0: true
material: COOKED_PORKCHOP
name: '&fSecret Item'
lore:
- '&7Click me and I will allow you to'
- '&7use the one time only message again'
commands:
- set-data= example_item false
- 'refresh'

View File

@ -0,0 +1,121 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | Official Panel v3.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
example_middle_one:
perm: default
rows: 3
title: 'Example'
animatevalue: 15
refresh-delay: 5
panelType:
- nocommand
empty: YELLOW_STAINED_GLASS_PANE
item:
'0':
material: AIR
stack: 1
name: ''
animate0:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'1':
material: AIR
stack: 1
name: ''
animate1:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'2':
material: AIR
stack: 1
name: ''
animate2:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'3':
material: AIR
stack: 1
name: ''
animate3:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'5':
material: AIR
stack: 1
name: ''
animate9:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'6':
material: AIR
stack: 1
name: ''
animate10:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'7':
material: AIR
stack: 1
name: ''
animate11:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'12':
material: AIR
stack: 1
name: ''
animate4:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'14':
material: AIR
stack: 1
name: ''
animate8:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'16':
material: AIR
stack: 1
name: ''
animate12:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'21':
material: AIR
stack: 1
name: ''
animate5:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'22':
material: AIR
stack: 1
name: ''
animate6:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'23':
material: AIR
stack: 1
name: ''
animate7:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'25':
material: AIR
stack: 1
name: ''
animate13:
material: PUFFERFISH
name: '&ePopper the Pufferfish'
'26':
material: AIR
stack: 1
name: ''
animate14:
material: PUFFERFISH
name: '&ePopper the Pufferfish'

View File

@ -0,0 +1,180 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | Official Panel v3.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
example_middle_two:
perm: default
rows: 4
title: '&e&lOnline Browser - Page $cp-data-nextpage$'
empty: LIGHT_BLUE_STAINED_GLASS_PANE
panelType:
- nocommand
placeholders:
primary:
start: '$'
end: '$'
secondary:
start: '{'
end: '}'
pre-load-commands:
- add-data= onlinepage 0
- add-data= nextpage 1
item:
'10':
material: 'cps= $cp-player-online-%math_0:_1+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_1+14*{cp-data-onlinepage}%$'
has0:
compare0: '$cp-player-online-%math_0:_1+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'11':
material: 'cps= $cp-player-online-%math_0:_2+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_2+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_2+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'12':
material: 'cps= $cp-player-online-%math_0:_3+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_3+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_3+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'13':
material: 'cps= $cp-player-online-%math_0:_4+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_4+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_4+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'14':
material: 'cps= $cp-player-online-%math_0:_5+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_5+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_5+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'15':
material: 'cps= $cp-player-online-%math_0:_6+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_6+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_6+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'16':
material: 'cps= $cp-player-online-%math_0:_7+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_7+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_7+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'19':
material: 'cps= $cp-player-online-%math_0:_8+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_8+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_8+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'20':
material: 'cps= $cp-player-online-%math_0:_9+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_9+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_9+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'21':
material: 'cps= $cp-player-online-%math_0:_10+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_10+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_10+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'22':
material: 'cps= $cp-player-online-%math_0:_11+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_11+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_11+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'23':
material: 'cps= $cp-player-online-%math_0:_12+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_12+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_12+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'24':
material: 'cps= $cp-player-online-%math_0:_13+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_13+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_13+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'25':
material: 'cps= $cp-player-online-%math_0:_14+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_0:_14+14*{cp-data-onlinepage}%$'
has0:
compare0: '&e$cp-player-online-%math_0:_14+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'2':
material: LIGHT_BLUE_STAINED_GLASS_PANE
name: "&f"
has0:
value0: 'NOT 0 ISGREATER'
compare0: '$cp-data-onlinepage$'
material: STICK
stack: 1
name: "&c&lLast Page"
commands:
- math-data= onlinepage -1
- math-data= nextpage -1
- open= example_middle_two
'6':
material: ARROW
stack: 1
name: "&e&lNext Page"
commands:
- 'math-data= onlinepage +1'
- 'math-data= nextpage +1'
- open= example_middle_two
'4':
material: OAK_SIGN
name: '&e&lOnline Players'
lore:
- '&b$cp-online-players$'
- ''
- '&8Player Browser made by:'
- '&8TinyTank800'

View File

@ -0,0 +1,148 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | Official Panel v3.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
example:
perm: admin
rows: 6
title: '&6&l[&b&lExample&6&l]&r Hello %cp-player-name%!'
sound-on-open: BLOCK_NOTE_BLOCK_CHIME
pre-load-commands:
- placeholder= [item:APPLE]
- add-data= example_item false
commands-on-open:
- open= example_middle_one {Middle}
- open= example_bottom {Bottom}
commands:
- example_panel
empty: LIGHT_BLUE_STAINED_GLASS_PANE
custom-item:
bread:
material: BREAD
name: '&fMmm.. Yummy'
item:
'1':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc3MTY1YzlkYjc2M2E5YWNkMTNjMDYyMjBlOTJkM2M5NzBkZmEzNmRhYzU2ZTU5NTdkMDJkMzZmNWE5ZjBiOCJ9fX0=
name: '&e&lE'
'2':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTVkNWM3NWY2Njc1ZWRjMjkyZWEzNzg0NjA3Nzk3MGQyMjZmYmQ1MjRlN2ZkNjgwOGYzYTQ3ODFhNTQ5YjA4YyJ9fX0=
name: '&e&lX'
'3':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTUxN2I0ODI5YjgzMTkyYmQ3MjcxMTI3N2E4ZWZjNDE5NjcxMWU0MTgwYzIyYjNlMmI4MTY2YmVhMWE5ZGUxOSJ9fX0=
name: '&e&lA'
'4':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWQ3MTYyNTZkNzI3YmExZGYxOGY4MjZmMTE5MDUxYzMzYTM5NDIwOWE5NWJlODM3Y2NmNmZhZTllZTZiODcxYiJ9fX0=
name: '&e&lM'
'5':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjU1MzE0MWFhYmU4OWE4YTU4MDRhMTcyMTMzYjQzZDVkMGVlMDU0OWNjMTlkYjAzODU2ODQwNDNjZmE5NDZhNSJ9fX0=
name: '&e&lP'
'6':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjA2YmM0MTdlM2MwNmIyMjczNWQ1MzlmOWM2YzhmZDdjMWVmZDE5MjM2ZTJjMzgxNTM0MDUxZDlkNmJlZTgwNCJ9fX0=
name: '&e&lL'
'7':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc3MTY1YzlkYjc2M2E5YWNkMTNjMDYyMjBlOTJkM2M5NzBkZmEzNmRhYzU2ZTU5NTdkMDJkMzZmNWE5ZjBiOCJ9fX0=
name: '&e&lE'
'15':
material: IRON_SWORD
name: '&fThis sword has been damaged'
damage: 20
'17':
material: LEATHER_HELMET
name: '&aGreen &fArmor'
leatherarmor: GREEN
'18':
material: BREAD
name: '&fPay $20 for bread'
commands:
- paywall= 20
- give-item= bread
'19':
material: APPLE
name: '&fClick me to change item'
commands:
- placeholder= [item:GOLDEN_APPLE]
- refresh
has0:
material: GOLDEN_APPLE
compare0: '%cp-item%'
value0: GOLDEN_APPLE
name: '&fClick me to change item'
commands:
- placeholder= [item:APPLE]
- refresh
'21':
material: GOLDEN_APPLE
name: '&fClick to heal the player'
lore:
- '&7Uses the /heal command if'
- '&7the player has permission'
commands:
- heal
'24':
material: BOW
name: '&fThis bow is enchanted'
enchanted:
- true
'26':
material: LEATHER_CHESTPLATE
name: '&eYellow &fArmor'
leatherarmor: YELLOW
'27':
material: COOKED_BEEF
name: '&fReplenish your hunger bars'
lore:
- '&7Uses /feed command'
commands:
- feed
'28':
material: COOKED_PORKCHOP
name: '&fSends a message'
lore:
- '&7Can only be used once per player'
commands:
- set-data= example_item true
- msg= &fThis message can only be sent one time
- refresh
has0:
compare0: '%cp-data-example_item%'
value0: true
material: BARRIER
name: '&cItem has been used!'
'30':
material: COMPASS
name: '&fTeleport Home'
commands:
- home
- cpc
- title= %cp-player-name% 20 60 20 &eWelcome Home/n/&2%cp-player-displayname%
'33':
material: ARROW
name: '&fItems can be stacked'
stack: 16
'35':
material: LEATHER_LEGGINGS
name: '&cRed &fArmor'
leatherarmor: RED
'42':
material: IRON_AXE
name: '#4eabd1Crazy #b6d1eaColours'
lore:
- '&71.16+ you can use HEX colours!'
'44':
material: LEATHER_BOOTS
name: '&6Orange &fArmor'
leatherarmor: ORANGE
'45':
material: RED_WOOL
name: '&cMinimize Panel'
commands:
- close= Middle
- close= Bottom
'46':
material: LIME_WOOL
name: '&aReset Bottom of Panel'
commands:
- open= example_middle_one {Middle}
- open= example_bottom {Bottom}

View File

@ -0,0 +1,19 @@
# |------------------------------------------------------------------------
# | CommandPanels Template File
# | Official Panel v1.1
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
template:
perm: admin
rows: 1
title: '&8Template Panel'
empty: GLASS_PANE
item:
'4':
material: COBBLESTONE
stack: 1
name: '&fClick Me!'
commands:
- msg= You clicked the item!
- cpc

View File

@ -1,464 +0,0 @@
package me.rockyhawk.commandPanels.ClassResources;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.*;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.Objects;
public class CommandTags {
commandpanels plugin;
public CommandTags(commandpanels pl) {
this.plugin = pl;
}
public void commandTags(Player p, String command) {
String tag = plugin.config.getString("config.format.tag") + " ";
//set cp placeholders
command = plugin.papi(p, plugin.setCpPlaceholders(p, command));
if (command.split("\\s")[0].equalsIgnoreCase("server=")) {
//this contacts bungee and tells it to send the server change command
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(command.split("\\s")[1]);
Player player = Bukkit.getPlayerExact(p.getName());
assert player != null;
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} else if (command.split("\\s")[0].equalsIgnoreCase("open=")) {
//if player uses open= it will open the panel forced
String panelName = command.split("\\s")[1];
for(String[] tempName : plugin.panelNames){
if(tempName[0].equals(panelName)){
YamlConfiguration panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1]))));
plugin.openGui(panelName, p, panelConfig, 1, 0);
return;
}
}
}else if (command.split("\\s")[0].equalsIgnoreCase("op=")) {
//if player uses op= it will perform command as op
boolean isop = p.isOp();
try {
p.setOp(true);
Bukkit.dispatchCommand(p,plugin.papi(p, command.replace("op=", "").trim()));
p.setOp(isop);
} catch (Exception exc) {
p.setOp(isop);
plugin.debug(exc);
p.sendMessage(tag + plugin.papi( plugin.config.getString("config.format.error") + " op=: Error in op command!"));
}
}else if (command.split("\\s")[0].equalsIgnoreCase("delay=")) {
//if player uses op= it will perform command as op
final int delaySeconds = Integer.parseInt(command.split("\\s")[1]);
String finalCommand = command.split("\\s",3)[2];
new BukkitRunnable() {
@Override
public void run() {
commandTags(p, finalCommand);
this.cancel();
}
}.runTaskTimer(plugin, 20*delaySeconds, 20); //20 ticks == 1 second
} else if (command.split("\\s")[0].equalsIgnoreCase("console=")) {
//if player uses console= it will perform command in the console
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), plugin.papi(p, command.replace("console=", "").trim()));
} else if (command.split("\\s")[0].equalsIgnoreCase("buy=")) {
//if player uses buy= it will be eg. buy= <price> <item> <amount of item> <ID>
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()){
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
if (p.getInventory().firstEmpty() >= 0) {
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
} else {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
}
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buy) {
plugin.debug(buy);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("tokenbuy=")) {
//if player uses tokenbuy= it will be eg. tokenbuy= <price> <item> <amount of item> <ID>
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
if (p.getInventory().firstEmpty() >= 0) {
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
} else {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])));
}
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Buying Requires TokenManager to work!"));
}
} catch (Exception buy) {
plugin.debug(buy);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("sell=")) {
//if player uses sell= it will be eg. sell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.econ != null) {
boolean sold = false;
for (int f = 0; f < p.getInventory().getSize(); f++) {
ItemStack itm = p.getInventory().getItem(f);
if (itm != null && itm.getType().equals(Material.matchMaterial(command.split("\\s")[2]))) {
//determine if the command contains parameters for extensions
String potion = "false";
for(String argsTemp : command.split("\\s")){
if(argsTemp.startsWith("potion:")){
potion = argsTemp.replace("potion:","");
}
}
//check to ensure any extensions are checked
try {
if (!potion.equals("false")) {
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
assert potionMeta != null;
if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Your item has the wrong potion effect"));
return;
}
}
}catch(Exception exc){
//skip unless plugin.debug enabled
plugin.debug(exc);
}
if (itm.getAmount() >= new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount()) {
int amt = itm.getAmount() - new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount();
itm.setAmount(amt);
p.getInventory().setItem(f, amt > 0 ? itm : null);
plugin.econ.depositPlayer(p, Double.parseDouble(command.split("\\s")[1]));
sold = true;
p.updateInventory();
break;
}
}
}
if (!sold) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needitems")));
} else {
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.sold")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Selling Requires Vault and an Economy to work!"));
}
} catch (Exception sell) {
plugin.debug(sell);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("tokensell=")) {
//if player uses tokensell= it will be eg. tokensell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
boolean sold = false;
for (int f = 0; f < p.getInventory().getSize(); f++) {
ItemStack itm = p.getInventory().getItem(f);
if (itm != null && itm.getType().equals(Material.matchMaterial(command.split("\\s")[2]))) {
//determine if the command contains parameters for extensions
String potion = "false";
for(String argsTemp : command.split("\\s")){
if(argsTemp.startsWith("potion:")){
potion = argsTemp.replace("potion:","");
}
}
//check to ensure any extensions are checked
try {
if (!potion.equals("false")) {
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
assert potionMeta != null;
if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Your item has the wrong potion effect"));
return;
}
}
}catch(Exception exc){
//skip if it cannot do unless plugin.debug is enabled
plugin.debug(exc);
}
if (itm.getAmount() >= new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount()) {
int amt = itm.getAmount() - new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount();
itm.setAmount(amt);
p.getInventory().setItem(f, amt > 0 ? itm : null);
plugin.econ.depositPlayer(p, Double.parseDouble(command.split("\\s")[1]));
assert api != null;
api.addTokens(p, Long.parseLong(command.split("\\s")[1]));
sold = true;
p.updateInventory();
break;
}
}
}
if (!sold) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needitems")));
} else {
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.sold")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Selling Requires TokenManager to work!"));
}
} catch (Exception sell) {
plugin.debug(sell);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("msg=")) {
//if player uses msg= it will send the player a message
p.sendMessage(plugin.papi(p, command.replace("msg=", "").trim()));
} else if (command.split("\\s")[0].equalsIgnoreCase("sound=")) {
//if player uses sound= it will play a sound (sound= [sound])
try {
p.playSound(p.getLocation(), Sound.valueOf(command.split("\\s")[1]), 1F, 1F);
} catch (Exception s) {
plugin.debug(s);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("tokenbuycommand=")) {
//if player uses tokenbuycommand [price] [command]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//execute command under here
String commandp = command;
commandp = commandp.replace("tokenbuycommand=", "").trim();
String price = commandp.split(" ", 2)[0];
commandp = commandp.split(" ", 2)[1];
commandTags(p,plugin.papi(p, commandp));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", price)));
}
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("buycommand=")) {
//if player uses buycommand [price] [command]
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
//execute command under here
String commandp = command;
commandp = commandp.replace("buycommand=", "").trim();
String price = commandp.split(" ", 2)[0];
commandp = commandp.split(" ", 2)[1];
commandTags(p,plugin.papi(p, commandp));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", price)));
}
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("teleport=")) {
//if player uses teleport= x y z (optional other player)
if (command.split("\\s").length == 6) {
float x, y, z, yaw, pitch; //pitch is the heads Y axis and yaw is the X axis
x = Float.parseFloat(plugin.papi(p, command.split("\\s")[1]));
y = Float.parseFloat(plugin.papi(p, command.split("\\s")[2]));
z = Float.parseFloat(plugin.papi(p, command.split("\\s")[3]));
yaw = Float.parseFloat(plugin.papi(p, command.split("\\s")[4]));
pitch = Float.parseFloat(plugin.papi(p, command.split("\\s")[5]));
p.teleport(new Location(p.getWorld(), x, y, z, yaw, pitch));
} else if (command.split("\\s").length <= 4) {
float x, y, z;
x = Float.parseFloat(plugin.papi(p, command.split("\\s")[1]));
y = Float.parseFloat(plugin.papi(p, command.split("\\s")[2]));
z = Float.parseFloat(plugin.papi(p, command.split("\\s")[3]));
p.teleport(new Location(p.getWorld(), x, y, z));
} else {
try {
Player otherplayer = Bukkit.getPlayer(plugin.papi(p, command.split("\\s")[4]));
float x, y, z;
x = Float.parseFloat(plugin.papi(p, command.split("\\s")[1]));
y = Float.parseFloat(plugin.papi(p, command.split("\\s")[2]));
z = Float.parseFloat(plugin.papi(p, command.split("\\s")[3]));
assert otherplayer != null;
otherplayer.teleport(new Location(otherplayer.getWorld(), x, y, z));
} catch (Exception tpe) {
p.sendMessage(tag + plugin.config.getString("config.format.notitem"));
}
}
} else if (command.split("\\s")[0].equalsIgnoreCase("stopsound=")) {
//if player uses stopsound= [sound]
try {
p.stopSound(Sound.valueOf(command.split("\\s")[1]));
} catch (Exception ss) {
plugin.debug(ss);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
} else if (command.split("\\s")[0].equalsIgnoreCase("sudo=")) {
//if player uses sudo= [command]
p.chat(plugin.papi(p, "/" + command.replaceAll("sudo=", "").trim()));
} else {
Bukkit.dispatchCommand(p, plugin.papi(p, command));
}
}
public int commandPayWall(Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
String tag = plugin.config.getString("config.format.tag") + " ";
if (command.split("\\s")[0].equalsIgnoreCase("paywall=")) {
//if player uses paywall= [price]
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
//if the message is empty don't send
if(!plugin.config.getString("config.format.bought").isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
return 0;
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!"));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
} else if (command.split("\\s")[0].equalsIgnoreCase("tokenpaywall=")) {
//if player uses tokenpaywall= [price]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
return 0;
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Paying TokenManager to work!"));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
}else if (command.split("\\s")[0].equalsIgnoreCase("item-paywall=")) {
//if player uses item-paywall= [Material] [Amount]
try {
ItemStack sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])),Integer.parseInt(command.split("\\s")[2]));
int sellItemAmount = sellItem.getAmount();
sellItem.setAmount(1);
int removedItem = 0;
for(ItemStack content : p.getInventory().getContents()){
int contentAmount;
try {
contentAmount = content.getAmount();
}catch(NullPointerException skip){
//item is air
continue;
}
content.setAmount(1);
if(content.isSimilar(sellItem)){
if(sellItemAmount <= contentAmount){
content.setAmount(contentAmount-sellItemAmount);
p.updateInventory();
removedItem = 1;
break;
}
}
content.setAmount(contentAmount);
}
if(removedItem == 0){
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}else{
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold")).isEmpty()) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.sold")));
}
}
return removedItem;
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
}else if (command.split("\\s")[0].equalsIgnoreCase("xp-paywall=")) {
//if player uses xp-paywall= [price]
try {
int balance = p.getLevel();
if (balance >= Integer.parseInt(command.split("\\s")[1])) {
p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
} else {
return 2;
}
}
}

View File

@ -1,139 +0,0 @@
package me.rockyhawk.commandPanels.ClassResources;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Objects;
public class ExecuteOpenVoids {
commandpanels plugin;
public ExecuteOpenVoids(commandpanels pl) {
this.plugin = pl;
}
//this is the main method to open a panel
public void openCommandPanel(CommandSender sender, Player p, String panels, YamlConfiguration cf, boolean sendOpenedMessage){
String tag = plugin.config.getString("config.format.tag") + " ";
if (sender.hasPermission("commandpanel.panel." + cf.getString("panels." + panels + ".perm"))) {
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !sendOpenedMessage) {
try {
if (cf.contains("panels." + panels + ".disabled-worlds")) {
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
if (disabledWorlds.contains(p.getWorld().getName())) {
//panel cannot be used in the players world!
if (Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")) {
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Panel is disabled in the world!"));
}
return;
}
}
}catch(NullPointerException offlinePlayer){
//SKIP because player is offline
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.notitem")));
return;
}
try {
if (cf.contains("panels." + panels + ".sound-on-open")) {
//play sound when panel is opened
if(!Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).equalsIgnoreCase("off")) {
try {
p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).toUpperCase()), 1F, 1F);
} catch (Exception s) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + cf.getString("panels." + panels + ".sound-on-open")));
}
}
}
if (cf.contains("panels." + panels + ".commands-on-open")) {
//execute commands on panel open
try {
List<String> commands = cf.getStringList("panels." + panels + ".commands-on-open");
for (int i = 0; commands.size() - 1 >= i; i++) {
int val = plugin.commandTags.commandPayWall(p,commands.get(i));
if(val == 0){
break;
}
if(val == 2){
plugin.commandTags.commandTags(p, commands.get(i));
}
}
}catch(Exception s){
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + cf.getString("panels." + panels + ".commands-on-open")));
}
}
plugin.openGui(panels, p, cf,1,0);
if(sendOpenedMessage) {
sender.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));
}
} catch (Exception r) {
plugin.debug(r);
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
}
return;
}
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
}
//this will give a hotbar item to a player
public void giveHotbarItem(CommandSender sender, Player p, String panels, YamlConfiguration cf, boolean sendGiveMessage){
String tag = plugin.config.getString("config.format.tag") + " ";
if (sender.hasPermission("commandpanel.item." + cf.getString("panels." + panels + ".perm")) && cf.contains("panels." + panels + ".open-with-item")) {
try {
if (cf.contains("panels." + panels + ".disabled-worlds")) {
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
if (disabledWorlds.contains(p.getWorld().getName())) {
//panel cannot be used in the players world!
if (Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")) {
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Panel is disabled in the world!"));
}
return;
}
}
}catch(NullPointerException offlinePlayer){
//SKIP because player is offline
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.notitem")));
return;
}
ItemStack s;
try {
s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(cf.getConfigurationSection("panels." + panels + ".open-with-item")), p, false, true);
}catch(Exception n){
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " open-with-item: material"));
return;
}
plugin.setName(s, cf.getString("panels." + panels + ".open-with-item.name"), cf.getStringList("panels." + panels + ".open-with-item.lore"),p,false, true);
//if the sender has OTHER perms, or if sendGiveMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !sendGiveMessage) {
try {
if(cf.contains("panels." + panels + ".open-with-item.stationary")) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.stationary"))), s);
}else{
p.getInventory().addItem(s);
}
if(sendGiveMessage) {
sender.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName()));
}
} catch (Exception r) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
}
return;
}
if (!cf.contains("panels." + panels + ".open-with-item")) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.noitem")));
return;
}
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
}
}

View File

@ -1,72 +0,0 @@
package me.rockyhawk.commandPanels.ClassResources;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.util.UUID;
public class GetCustomHeads {
commandpanels plugin;
public GetCustomHeads(commandpanels pl) {
this.plugin = pl;
}
//getting the head from a Player
@SuppressWarnings("deprecation")
public ItemStack getPlayerHead(String name) {
ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
meta.setOwner(name);
itemStack.setItemMeta(meta);
return itemStack;
}
public ItemStack getCustomHead(String b64stringtexture) {
//get head from base64
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
PropertyMap propertyMap = profile.getProperties();
if (propertyMap == null) {
throw new IllegalStateException("Profile doesn't contain a property map");
} else {
propertyMap.put("textures", new Property("textures", b64stringtexture));
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
ItemMeta headMeta = head.getItemMeta();
assert headMeta != null;
Class headMetaClass = headMeta.getClass();
try {
getField(headMetaClass, "profile", GameProfile.class, 0).set(headMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException var10) {
plugin.debug(var10);
}
head.setItemMeta(headMeta);
return head;
}
}
//used with getItem for heads
private <T> Field getField(Class<?> target, String name, Class<T> fieldType, int index) {
Field[] var4 = target.getDeclaredFields();
for (Field field : var4) {
if ((name == null || field.getName().equals(name)) && fieldType.isAssignableFrom(field.getType()) && index-- <= 0) {
field.setAccessible(true);
return field;
}
}
if (target.getSuperclass() != null) {
return getField(target.getSuperclass(), name, fieldType, index);
} else {
throw new IllegalArgumentException("Cannot find field with type " + fieldType);
}
}
}

View File

@ -1,354 +0,0 @@
package me.rockyhawk.commandPanels.ClassResources;
import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import javax.swing.*;
import java.io.File;
import java.util.Objects;
import java.util.UUID;
public class ItemCreation {
commandpanels plugin;
public ItemCreation(commandpanels pl) {
plugin = pl;
}
public ItemStack makeItemFromConfig(ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours){
String tag = plugin.config.getString("config.format.tag") + " ";
String material = itemSection.getString("material");
try {
if (Objects.requireNonNull(itemSection.getString("material")).equalsIgnoreCase("AIR")) {
return null;
}
}catch(NullPointerException e){
plugin.debug(e);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " material: could not load material!"));
return null;
}
ItemStack s;
String mat;
String matskull;
String skullname;
//this will convert the %cp-player-online-1-find% into cps= NAME
assert material != null;
if (material.contains("%cp-player-online-")) {
int start = material.indexOf("%cp-player-online-");
int end = material.lastIndexOf("-find%");
String playerLocation = material.substring(start, end).replace("%cp-player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Integer.parseInt(playerLocation) > playerFind.length) {
material = material.replace(material.substring(start, end) + "-find%", "cps= " + plugin.config.getString("config.format.offlineHeadValue"));
} else {
material = material.replace(material.substring(start, end) + "-find%", "cpo= " + playerFind[Integer.parseInt(playerLocation) - 1].getName());
//cpo is to get the skull of the player online. It is fine since the plugin knows the player is online
}
}
try {
mat = material.toUpperCase();
matskull = material;
skullname = "no skull";
if (matskull.split("\\s")[0].toLowerCase().equals("cps=") || matskull.split("\\s")[0].toLowerCase().equals("cpo=")) {
skullname = p.getUniqueId().toString();
mat = "PLAYER_HEAD";
}
if (matskull.split("\\s")[0].toLowerCase().equals("hdb=")) {
skullname = "hdb";
mat = "PLAYER_HEAD";
}
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1);
if (!skullname.equals("no skull") && !skullname.equals("hdb") && !matskull.split("\\s")[0].equalsIgnoreCase("cpo=")) {
try {
SkullMeta meta;
if (matskull.split("\\s")[1].equalsIgnoreCase("self")) {
//if cps= self
meta = (SkullMeta) s.getItemMeta();
try {
assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname)));
} catch (Exception var23) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " material: cps= self"));
plugin.debug(var23);
}
s.setItemMeta(meta);
}else if (plugin.papiNoColour(p,matskull.split("\\s")[1]).length() <= 16) {
//if cps= username
s = plugin.customHeads.getPlayerHead(plugin.papiNoColour(p,matskull.split("\\s")[1]));
} else {
//custom data cps= base64
s = plugin.customHeads.getCustomHead(plugin.papiNoColour(p,matskull.split("\\s")[1]));
}
} catch (Exception var32) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
plugin.debug(var32);
}
}
if (!skullname.equals("no skull") && matskull.split("\\s")[0].equalsIgnoreCase("cpo=")) {
SkullMeta cpoMeta = (SkullMeta) s.getItemMeta();
assert cpoMeta != null;
cpoMeta.setOwningPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(matskull.split("\\s")[1])).getUniqueId()));
s.setItemMeta(cpoMeta);
}
if (skullname.equals("hdb")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("HeadDatabase")) {
HeadDatabaseAPI api;
api = new HeadDatabaseAPI();
try {
s = api.getItemHead(matskull.split("\\s")[1].trim());
} catch (Exception var22) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!"));
plugin.debug(var22);
}
} else {
p.sendMessage(plugin.papi(tag + "Download HeadDatabaseHook from Spigot to use this feature!"));
}
}
if (itemSection.contains("map")) {
/*
This will do maps from custom images
the maps will be in the 'maps' folder, so
CommandPanels/maps/image.png <-- here
Commandpanels/panels/example.yml
The images should be 128x128
*/
try{
@SuppressWarnings("deprecation")
MapView map = Bukkit.getServer().getMap(0);
try {
map.getRenderers().clear();
map.setCenterX(30000000);
map.setCenterZ(30000000);
}catch(NullPointerException ignore){
//ignore catch
}
if(new File(plugin.getDataFolder().getPath() + File.separator + "maps" + File.separator + itemSection.getString("map")).exists()) {
map.addRenderer(new MapRenderer() {
public void render(MapView view, MapCanvas canvas, Player player) {
canvas.drawImage(0, 0, new ImageIcon(plugin.getDataFolder().getPath() + File.separator + "maps" + File.separator + itemSection.getString("map")).getImage());
}
});
MapMeta meta = (MapMeta) s.getItemMeta();
meta.setMapView(map);
s.setItemMeta(meta);
}else{
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " map: File not found."));
}
}catch(Exception map){
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map")));
plugin.debug(map);
}
}
if (itemSection.contains("enchanted")) {
try {
ItemMeta EnchantMeta;
if (Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("true")) {
EnchantMeta = s.getItemMeta();
assert EnchantMeta != null;
EnchantMeta.addEnchant(Enchantment.KNOCKBACK, 1, false);
EnchantMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
s.setItemMeta(EnchantMeta);
} else if (!Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("false")) {
EnchantMeta = s.getItemMeta();
assert EnchantMeta != null;
EnchantMeta.addEnchant(Objects.requireNonNull(Enchantment.getByKey(NamespacedKey.minecraft(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[0].toLowerCase()))), Integer.parseInt(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[1]), true);
s.setItemMeta(EnchantMeta);
}
} catch (Exception ench) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted")));
plugin.debug(ench);
}
}
if (itemSection.contains("customdata")) {
ItemMeta customMeta = s.getItemMeta();
assert customMeta != null;
customMeta.setCustomModelData(Integer.parseInt(Objects.requireNonNull(itemSection.getString("customdata"))));
s.setItemMeta(customMeta);
}
if (itemSection.contains("leatherarmor")) {
//if the item is leather armor, change the colour to this
try {
if (s.getType() == Material.LEATHER_BOOTS || s.getType() == Material.LEATHER_LEGGINGS || s.getType() == Material.LEATHER_CHESTPLATE || s.getType() == Material.LEATHER_HELMET) {
LeatherArmorMeta leatherMeta = (LeatherArmorMeta) s.getItemMeta();
String colourCode = itemSection.getString("leatherarmor");
assert colourCode != null;
if (!colourCode.contains(",")) {
//use a color name
assert leatherMeta != null;
leatherMeta.setColor(plugin.colourCodes.get(colourCode.toUpperCase()));
} else {
//use RGB sequence
int[] colorRGB = {255, 255, 255};
int count = 0;
for (String colourNum : colourCode.split(",")) {
colorRGB[count] = Integer.parseInt(colourNum);
count += 1;
}
assert leatherMeta != null;
leatherMeta.setColor(Color.fromRGB(colorRGB[0], colorRGB[1], colorRGB[2]));
}
s.setItemMeta(leatherMeta);
}
} catch (Exception er) {
//don't colour the armor
plugin.debug(er);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor")));
}
}
if (itemSection.contains("potion")) {
//if the item is a potion, give it an effect
try {
PotionMeta potionMeta = (PotionMeta)s.getItemMeta();
String effectType = itemSection.getString("potion");
assert potionMeta != null;
assert effectType != null;
potionMeta.setBasePotionData(new PotionData(PotionType.valueOf(effectType.toUpperCase())));
potionMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
s.setItemMeta(potionMeta);
} catch (Exception er) {
//don't add the effect
plugin.debug(er);
p.sendMessage(plugin.papi(tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion")));
}
}
if (itemSection.contains("damage")) {
//change the damage amount (placeholders accepted)
try {
Damageable itemDamage = (Damageable) s.getItemMeta();
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage")))));
s.setItemMeta((ItemMeta) itemDamage);
}catch(Exception e){
plugin.debug(e);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
}
}
if (itemSection.contains("stack")) {
//change the stack amount (placeholders accepted)
s.setAmount(Integer.parseInt(Objects.requireNonNull(plugin.papi(p,itemSection.getString("stack")))));
}
} catch (IllegalArgumentException | NullPointerException var33) {
plugin.debug(var33);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material")));
return null;
}
plugin.setName(s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours);
return s;
}
//hasperm hasvalue, etc sections will be done here
public String hasSection(ConfigurationSection cf, Player p){
if (cf.contains("hasvalue")) {
//this will do the hasvalue without any numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("hasvalue.output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue.output");
}
String value = cf.getString("hasvalue.value");
String compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue.compare"))));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p);
//string section, it executes itself to check for subsections
return ".hasvalue" + section;
}
//loop through possible hasvalue 1,2,3,etc
for (int count = 0; cf.getKeys(false).size() > count; count++) {
if (cf.contains("hasvalue" + count)) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasvalue" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue" + count + ".output");
}
value = cf.getString("hasvalue" + count + ".value");
compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".compare"))));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p);
//string section, it executes itself to check for subsections
return ".hasvalue" + count + section;
}
}
}
}
if (cf.contains("hasgreater")) {
//this will do the hasgreater without any numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("hasgreater.output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater.output");
}
int value = cf.getInt("hasgreater.value");
double compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater.compare")))));
if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
return ".hasgreater" + section;
}
//loop through possible hasgreater 1,2,3,etc
for (int count = 0; cf.getKeys(false).size() > count; count++) {
if (cf.contains("hasgreater" + count)) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasgreater" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater" + count + ".output");
}
value = cf.getInt("hasgreater" + count + ".value");
compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater" + count + ".compare")))));
if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
return ".hasgreater" + count + section;
}
}
}
}
if (cf.contains("hasperm")) {
//this will do hasperm with no numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm.perm"))) == outputValue) {
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p);
return ".hasperm" + section;
}
for(int count = 0; cf.getKeys(false).size() > count; count++){
if (cf.contains("hasperm" + count) && cf.contains("hasperm" + count + ".perm")) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasperm" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasperm" + count + ".output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm" + count + ".perm"))) == outputValue) {
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm" + count)), p);
return ".hasperm" + count + section;
}
}
}
}
return "";
}
}

View File

@ -1,485 +0,0 @@
package me.rockyhawk.commandPanels.ClassResources;
import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class OpenEditorGuis {
commandpanels plugin;
public OpenEditorGuis(commandpanels pl) {
plugin = pl;
}
public void openEditorGui(Player p, int pageChange) {
Inventory i = Bukkit.createInventory(null, 54, "Command Panels Editor");
ArrayList<String> panelNames = new ArrayList<String>(); //all panels from ALL files (panel names)
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
ArrayList<ItemStack> panelItems = new ArrayList<ItemStack>(); //all panels from ALL files (panel materials)
try {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
if (!plugin.checkPanels(temp)) {
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
panelNames.add(plugin.papi( key));
panelTitles.add(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
if (temp.contains("panels." + key + ".open-with-item.material")) {
panelItems.add(plugin.itemCreate.makeItemFromConfig(temp.getConfigurationSection("panels." + key + ".open-with-item"), p, false, true));
} else {
panelItems.add(new ItemStack(Material.FILLED_MAP));
}
}
}
} catch (Exception fail) {
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
int pageNumber = 1;
if (p.getOpenInventory().getTitle().equals("Command Panels Editor")) {
pageNumber = Integer.parseInt(ChatColor.stripColor(Objects.requireNonNull(Objects.requireNonNull(p.getOpenInventory().getItem(49)).getItemMeta()).getDisplayName()).replace("Page ", ""));
}
//will add the difference
pageNumber = pageNumber + pageChange;
if (pageNumber <= 0) {
//double check page number IS NOT under 1
pageNumber = 1;
}
//get amount of pages total
int pagesAmount = (int) Math.ceil(panelNames.size() / 45.0);
//make all the bottom bar items
ItemStack temp;
temp = new ItemStack(Material.SUNFLOWER, 1);
plugin.setName(temp, ChatColor.WHITE + "Page " + pageNumber, null, p, true, true);
i.setItem(49, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Exit Menu", null, p, true, true);
i.setItem(45, temp);
temp = new ItemStack(Material.BOOK, 1);
List<String> lore = new ArrayList();
lore.add(ChatColor.GRAY + "- Click on a panel to edit items.");
lore.add(ChatColor.GRAY + "- Right click on a panel to edit settings.");
lore.add(ChatColor.GRAY + "- To edit an item in a panel, shift click");
lore.add(ChatColor.GRAY + " on the item of choice.");
lore.add(ChatColor.GRAY + "- When entering a value,");
lore.add(ChatColor.GRAY + " type 'remove' to set a");
lore.add(ChatColor.GRAY + " value to default, and use");
lore.add(ChatColor.GRAY + " '" + plugin.config.getString("config.input-cancel") + "' to cancel.");
plugin.setName(temp, ChatColor.WHITE + "Panel Editor Tips", lore, p, true, true);
i.setItem(53, temp);
if (pageNumber != 1) {
//only show previous page button if number is not one
temp = new ItemStack(Material.PAPER, 1);
plugin.setName(temp, ChatColor.WHITE + "Previous Page", null, p, true, true);
i.setItem(48, temp);
}
if (pageNumber < pagesAmount) {
//if page number is under pages amount
temp = new ItemStack(Material.PAPER, 1);
plugin.setName(temp, ChatColor.WHITE + "Next Page", null, p, true, true);
i.setItem(50, temp);
}
int count = 0;
int slot = 0;
lore.clear();
for (String panelName : panelNames) {
//count is +1 because count starts at 0 not 1
if ((pageNumber * 45 - 45) < (count + 1) && (pageNumber * 45) > (count)) {
temp = panelItems.get(count);
plugin.setName(temp, ChatColor.WHITE + panelName, lore, p, false, true);
i.setItem(slot, temp);
slot += 1;
}
count += 1;
}
p.openInventory(i);
}
public void openPanelSettings(Player p, String panelName, YamlConfiguration cf) {
Inventory i = Bukkit.createInventory(null, 45, "Panel Settings: " + panelName);
List<String> lore = new ArrayList();
ItemStack temp;
//remove if the player already had a string from previously
for (int o = 0; plugin.editorInputStrings.size() > o; o++) {
if (plugin.editorInputStrings.get(o)[0].equals(p.getName())) {
plugin.editorInputStrings.remove(o);
o = o - 1;
}
}
//make all the items
temp = new ItemStack(Material.WRITABLE_BOOK, 1);
lore.add(ChatColor.GRAY + "Permission required to open panel");
lore.add(ChatColor.GRAY + "commandpanel.panel.[insert]");
if (cf.contains("panels." + panelName + ".perm")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "commandpanel.panel." + cf.getString("panels." + panelName + ".perm"));
}
plugin.setName(temp, ChatColor.WHITE + "Panel Permission", lore, p,true, true);
i.setItem(1, temp);
temp = new ItemStack(Material.NAME_TAG, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Title of the Panel");
if (cf.contains("panels." + panelName + ".title")) {
lore.add(ChatColor.WHITE + "------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".title"));
}
plugin.setName(temp, ChatColor.WHITE + "Panel Title", lore, p,true, true);
i.setItem(3, temp);
temp = new ItemStack(Material.JUKEBOX, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Sound when opening panel");
if (cf.contains("panels." + panelName + ".sound-on-open")) {
lore.add(ChatColor.WHITE + "------------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("panels." + panelName + ".sound-on-open")).toUpperCase());
}
plugin.setName(temp, ChatColor.WHITE + "Panel Sound", lore, p,true, true);
i.setItem(5, temp);
temp = new ItemStack(Material.IRON_DOOR, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Custom command to open panel");
if (cf.contains("panels." + panelName + ".command")) {
lore.add(ChatColor.WHITE + "----------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".command"));
}
plugin.setName(temp, ChatColor.WHITE + "Panel Command", lore, p,true, true);
i.setItem(7, temp);
temp = new ItemStack(Material.LAVA_BUCKET, 1);
lore.clear();
lore.add(ChatColor.DARK_RED + "Permanently delete Panel");
plugin.setName(temp, ChatColor.RED + "Delete Panel", lore, p,true, true);
i.setItem(21, temp);
temp = new ItemStack(Material.PISTON, 1);
lore.clear();
lore.add(ChatColor.GRAY + "How many rows the panel will be");
lore.add(ChatColor.GRAY + "choose an integer from 1 to 6");
plugin.setName(temp, ChatColor.WHITE + "Panel Rows", lore, p,true, true);
i.setItem(23, temp);
temp = new ItemStack(Material.BLACK_STAINED_GLASS, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Fill empty slots with an item");
if (cf.contains("panels." + panelName + ".empty")) {
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("panels." + panelName + ".empty")).toUpperCase());
}
plugin.setName(temp, ChatColor.WHITE + "Panel Empty Item", lore, p,true, true);
i.setItem(13, temp);
temp = new ItemStack(Material.COMMAND_BLOCK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Execute commands when opening");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
if (cf.contains("panels." + panelName + ".commands-on-open")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panels." + panelName + ".commands-on-open")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Panel Commands", lore, p,true, true);
i.setItem(15, temp);
temp = new ItemStack(Material.ITEM_FRAME, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Code name to open panel");
lore.add(ChatColor.GRAY + "/cp [name]");
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + panelName);
plugin.setName(temp, ChatColor.WHITE + "Panel Name", lore, p,true, true);
i.setItem(11, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p,true, true);
i.setItem(18, temp);
//This will create a wall of glass panes, separating panel settings with hotbar settings
temp = new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1);
plugin.setName(temp, ChatColor.WHITE + "", null, p,false, true);
for(int d = 27; d < 36; d++){
i.setItem(d, temp);
}
//This is the items for hotbar items (open-with-item)
boolean hotbarItems = false;
if(cf.contains("panels." + panelName + ".open-with-item.material")){
hotbarItems = true;
temp = plugin.itemCreate.makeItemFromConfig(cf.getConfigurationSection("panels." + panelName + ".open-with-item"), p, false, true);
}else{
temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
}
lore.clear();
lore.add(ChatColor.GRAY + "Current Item");
if (cf.contains("panels." + panelName + ".open-with-item.material")) {
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("panels." + panelName + ".open-with-item.material")).toUpperCase());
}else{
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.RED + "DISABLED");
}
plugin.setName(temp, ChatColor.WHITE + "Panel Hotbar Item", lore, p,true, true);
i.setItem(40, temp);
if(hotbarItems) {
temp = new ItemStack(Material.NAME_TAG, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Name for Hotbar item");
if (cf.contains("panels." + panelName + ".open-with-item.name")) {
lore.add(ChatColor.WHITE + "----------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("panels." + panelName + ".open-with-item.name")));
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Name", lore, p, true, true);
i.setItem(38, temp);
temp = new ItemStack(Material.SPRUCE_SIGN, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display a lore under the Hotbar item");
lore.add(ChatColor.GRAY + "- Left click to add lore");
lore.add(ChatColor.GRAY + "- Right click to remove lore");
if (cf.contains("panels." + panelName + ".open-with-item.lore")) {
lore.add(ChatColor.WHITE + "-------------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panels." + panelName + ".open-with-item.lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Lore", lore, p,true, true);
i.setItem(36, temp);
temp = new ItemStack(Material.BEDROCK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Hotbar location for the item");
lore.add(ChatColor.GRAY + "choose a number from 1 to 9");
if (cf.contains("panels." + panelName + ".open-with-item.stationary")) {
lore.add(ChatColor.WHITE + "-------------------------");
//in the editor, change the value of 0-8 to 1-9 for simplicity
int location = cf.getInt("panels." + panelName + ".open-with-item.stationary") + 1;
lore.add(ChatColor.WHITE + String.valueOf(location));
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Location", lore, p, true, true);
i.setItem(42, temp);
temp = new ItemStack(Material.BOOK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "- To refresh changes use");
lore.add(ChatColor.GRAY + " /cp " + panelName + " item");
lore.add(ChatColor.GRAY + "- Hotbar items will need a");
lore.add(ChatColor.GRAY + " name to work properly.");
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Tips", lore, p, true, true);
i.setItem(44, temp);
}
p.openInventory(i);
}
public void openItemSettings(Player p, String panelName, YamlConfiguration cf, int itemNumber) {
Inventory i = Bukkit.createInventory(null, 36, "Item Settings: " + panelName);
List<String> lore = new ArrayList();
ItemStack temp;
//remove if the player already had a string from previously
for (int o = 0; plugin.editorInputStrings.size() > o; o++) {
if (plugin.editorInputStrings.get(o)[0].equals(p.getName())) {
plugin.editorInputStrings.remove(o);
o = o - 1;
}
}
//make all the items
temp = new ItemStack(Material.NAME_TAG, 1);
lore.add(ChatColor.GRAY + "Display name of the item in the Panel");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".name")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".name"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Name", lore, p,true, true);
i.setItem(1, temp);
temp = new ItemStack(Material.COMMAND_BLOCK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Execute commands when item is clicked");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".commands")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panels." + panelName + ".item." + itemNumber + ".commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Commands", lore, p,true, true);
i.setItem(3, temp);
temp = new ItemStack(Material.EXPERIENCE_BOTTLE, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display enchantment of the item in the Panel");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".enchanted")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".enchanted"));
}
} else {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "false");
}
plugin.setName(temp, ChatColor.WHITE + "Item Enchantment", lore, p,true, true);
i.setItem(5, temp);
temp = new ItemStack(Material.POTION, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display potion effect of the item in the Panel");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".potion")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".potion"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".potion"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Potion Effect", lore, p,true, true);
i.setItem(7, temp);
temp = new ItemStack(Material.SPRUCE_SIGN, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display a lore under the item name");
lore.add(ChatColor.GRAY + "- Left click to add lore line");
lore.add(ChatColor.GRAY + "- Right click to remove lore line");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".lore")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panels." + panelName + ".item." + itemNumber + ".lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Lores", lore, p, true, true);
i.setItem(19, temp);
temp = new ItemStack(Material.ITEM_FRAME, 2);
lore.clear();
lore.add(ChatColor.GRAY + "How many of the item will be stacked");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".stack")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"), "")) {
try {
temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"))));
} catch (Exception ignored) {
}
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Stack Size", lore, p, true, true);
i.setItem(21, temp);
temp = new ItemStack(Material.ANVIL, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Add Custom Model Data here");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".customdata")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".customdata"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".customdata"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Custom Model Data", lore, p, true, true);
i.setItem(23, temp);
temp = new ItemStack(Material.LEATHER_HELMET, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Choose a colour for the armor");
lore.add(ChatColor.GRAY + "use r,g,b or a spigot API color");
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".leatherarmor")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".leatherarmor"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".leatherarmor"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Leather Armor Colour", lore, p, true, true);
i.setItem(25, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true);
i.setItem(27, temp);
if(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).startsWith("cps=")){
temp = new ItemStack(Material.PLAYER_HEAD, 1);
if(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).equalsIgnoreCase("cps= self")){
//if self
SkullMeta meta = (SkullMeta) temp.getItemMeta();
try {
assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(p.getUniqueId()));
} catch (Exception var23) {
plugin.debug(var23);
}
temp.setItemMeta(meta);
}else{
//custom head
temp = plugin.customHeads.getCustomHead(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).replace("cps=", "").trim());
}
}else if (Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).startsWith("%cp-player-online-")){
//leave default for the find material tag
temp = new ItemStack(Material.PLAYER_HEAD, 1);
}else if (Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).startsWith("hdb=")){
//head database head
temp = new ItemStack(Material.PLAYER_HEAD, 1);
if (plugin.getServer().getPluginManager().isPluginEnabled("HeadDatabase")) {
HeadDatabaseAPI api;
api = new HeadDatabaseAPI();
try {
temp = api.getItemHead(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")).replace("hdb=", "").trim());
} catch (Exception var22) {
plugin.debug(var22);
}
}
}else{
temp = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".material")))), 1);
}
try {
temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"))));
} catch (Exception ex) {
//skip
}
if (cf.contains("panels." + panelName + ".item." + itemNumber + ".enchanted")) {
if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".enchanted"), "false")) {
ItemMeta EnchantMeta;
EnchantMeta = temp.getItemMeta();
assert EnchantMeta != null;
EnchantMeta.addEnchant(Enchantment.KNOCKBACK, 1, true);
EnchantMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
temp.setItemMeta(EnchantMeta);
}
}
lore.clear();
lore.add(ChatColor.GRAY + "Click to set custom material");
lore.add(ChatColor.GRAY + "typically for custom heads");
plugin.setName(temp, ChatColor.WHITE + "Item Slot " + itemNumber + " Preview", lore, p, true, true);
i.setItem(35, temp);
p.openInventory(i);
}
}

View File

@ -1,718 +0,0 @@
package me.rockyhawk.commandPanels;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
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!
*/
@SuppressWarnings({"WeakerAccess", "unused"})
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;
// A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>();
/**
* Class constructor.
*
* @param plugin The plugin which stats should be submitted.
*/
public Metrics(Plugin plugin) {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null!");
}
this.plugin = plugin;
// 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("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);
}
continue; // continue looping since we cannot do any other thing.
}
}
} 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(new Runnable() {
@Override
public void run() {
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.toString());
}
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);
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.write(compressedData);
outputStream.flush();
outputStream.close();
InputStream inputStream = connection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder builder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
builder.append(line);
}
bufferedReader.close();
if (logResponseStatusText) {
plugin.getLogger().info("Sent data to bStats and received response: " + builder.toString());
}
}
/**
* 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();
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
gzip.write(str.getBytes(StandardCharsets.UTF_8));
gzip.close();
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(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(categoryValue);
}
values.add(entry.getKey(), categoryValues);
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.add("values", values);
return data;
}
}
}

View File

@ -1,670 +0,0 @@
package me.rockyhawk.commandPanels;
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import java.io.*;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.URL;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import me.clip.placeholderapi.PlaceholderAPI;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandPanels.ClassResources.*;
import me.rockyhawk.commandPanels.commands.*;
import me.rockyhawk.commandPanels.completeTabs.cpTabComplete;
import me.rockyhawk.commandPanels.generatePanels.commandpanelsgenerate;
import me.rockyhawk.commandPanels.generatePanels.newGenUtils;
import me.rockyhawk.commandPanels.generatePanels.tabCompleteGenerate;
import me.rockyhawk.commandPanels.ingameEditor.cpIngameEditCommand;
import me.rockyhawk.commandPanels.ingameEditor.cpTabCompleteIngame;
import me.rockyhawk.commandPanels.ingameEditor.editorUserInput;
import me.rockyhawk.commandPanels.ingameEditor.editorUtils;
import me.rockyhawk.commandPanels.ioClasses.sequence_1_13;
import me.rockyhawk.commandPanels.ioClasses.sequence_1_14;
import me.rockyhawk.commandPanels.openWithItem.utilsOpenWithItem;
import me.rockyhawk.commandPanels.panelBlocks.blocksTabComplete;
import me.rockyhawk.commandPanels.panelBlocks.commandpanelblocks;
import me.rockyhawk.commandPanels.panelBlocks.panelBlockOnClick;
import me.rockyhawk.commandPanels.premium.commandpanelUserInput;
import me.rockyhawk.commandPanels.premium.commandpanelrefresher;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.*;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public class commandpanels extends JavaPlugin {
public YamlConfiguration config;
public Economy econ = null;
public boolean update = false;
public boolean debug = false;
public boolean openWithItem = false; //this will be true if there is a panel with open-with-item
public List<Player> generateMode = new ArrayList<>(); //players that are currently in generate mode
public List<String> panelRunning = new ArrayList<>();
public List<String[]> userInputStrings = new ArrayList<>();
public List<String[]> editorInputStrings = new ArrayList<>();
public List<String> panelFiles = new ArrayList<>(); //names of all the files in the panels folder including extension
public List<String[]> panelNames = new ArrayList<>(); //this will return something like {"mainMenuPanel","4"} which means the 4 is for panelFiles.get(4). So you know which file it is for
//get alternate classes
public CommandTags commandTags = new CommandTags(this);
public OpenEditorGuis editorGuis = new OpenEditorGuis(this);
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
public ItemCreation itemCreate = new ItemCreation(this);
public GetCustomHeads customHeads = new GetCustomHeads(this);
public File panelsf;
public YamlConfiguration blockConfig; //where panel block locations are stored
public commandpanels() {
this.panelsf = new File(this.getDataFolder() + File.separator + "panels");
this.blockConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "blocks.yml"));
}
public void onEnable() {
this.config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + File.separator + "config.yml"));
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loading...");
this.setupEconomy();
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
new Metrics(this);
Objects.requireNonNull(this.getCommand("commandpanel")).setExecutor(new commandpanel(this));
Objects.requireNonNull(this.getCommand("commandpanel")).setTabCompleter(new cpTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpanelblock")).setTabCompleter(new blocksTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpanelgenerate")).setTabCompleter(new tabCompleteGenerate(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setTabCompleter(new cpTabCompleteIngame(this));
Objects.requireNonNull(this.getCommand("commandpanelgenerate")).setExecutor(new commandpanelsgenerate(this));
Objects.requireNonNull(this.getCommand("commandpanelreload")).setExecutor(new commandpanelsreload(this));
Objects.requireNonNull(this.getCommand("commandpaneldebug")).setExecutor(new commandpanelsdebug(this));
Objects.requireNonNull(this.getCommand("commandpanelclose")).setExecutor(new commandpanelclose(this));
Objects.requireNonNull(this.getCommand("commandpanelversion")).setExecutor(new commandpanelversion(this));
Objects.requireNonNull(this.getCommand("commandpaneladdons")).setExecutor(new commandpanelresources(this));
Objects.requireNonNull(this.getCommand("commandpanellist")).setExecutor(new commandpanelslist(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setExecutor(new cpIngameEditCommand(this));
Objects.requireNonNull(this.getCommand("commandpanelblock")).setExecutor(new commandpanelblocks(this));
this.getServer().getPluginManager().registerEvents(new utils(this), this);
this.getServer().getPluginManager().registerEvents(new utilsOpenWithItem(this), this);
this.getServer().getPluginManager().registerEvents(new editorUtils(this), this);
this.getServer().getPluginManager().registerEvents(new newGenUtils(this), this);
this.getServer().getPluginManager().registerEvents(new commandpanelcustom(this), this);
this.getServer().getPluginManager().registerEvents(new commandpanelUserInput(this), this);
this.getServer().getPluginManager().registerEvents(new editorUserInput(this), this);
this.getServer().getPluginManager().registerEvents(new commandpanelrefresher(this), this);
this.getServer().getPluginManager().registerEvents(new panelBlockOnClick(this), this);
//save the config.yml file
File configFile = new File(this.getDataFolder() + File.separator + "config.yml");
if (!configFile.exists()) {
//generate a new config file from internal resources
try {
FileConfiguration configFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("config.yml")));
configFileConfiguration.save(configFile);
this.config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + File.separator + "config.yml"));
} catch (IOException var11) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not save the config file!");
}
}else{
//check if the config file has any missing elements
try {
YamlConfiguration configFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("config.yml")));
this.config.addDefaults(configFileConfiguration);
this.config.options().copyDefaults(true);
this.config.save(new File(this.getDataFolder() + File.separator + "config.yml"));
} catch (IOException var10) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not save the config file!");
}
}
//save the example.yml file
if (!this.panelsf.exists() || Objects.requireNonNull(this.panelsf.list()).length == 0) {
try {
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example.yml"));
} catch (IOException var11) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not save the example file!");
}
}
if (Objects.requireNonNull(this.config.getString("config.update-notifications")).equalsIgnoreCase("true")) {
githubNewUpdate(true);
}
//load panelFiles
reloadPanelFiles();
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loaded!");
}
public void onDisable() {
Bukkit.getLogger().info("RockyHawk's CommandPanels Plugin Disabled, aww man.");
}
public Inventory openGui(String panels, Player p, YamlConfiguration pconfig, int onOpen, int animateValue) {
String tag = this.config.getString("config.format.tag") + " ";
if (Integer.parseInt(Objects.requireNonNull(pconfig.getString("panels." + panels + ".rows"))) < 7 && Integer.parseInt(Objects.requireNonNull(pconfig.getString("panels." + panels + ".rows"))) > 0) {
Inventory i;
if (onOpen != 3) {
//use the regular inventory
i = Bukkit.createInventory(null, Integer.parseInt(Objects.requireNonNull(pconfig.getString("panels." + panels + ".rows"))) * 9, papi( Objects.requireNonNull(pconfig.getString("panels." + panels + ".title"))));
} else {
//this means it is the Editor window
i = Bukkit.createInventory(null, Integer.parseInt(Objects.requireNonNull(pconfig.getString("panels." + panels + ".rows"))) * 9, papi( ChatColor.GRAY + "Editing Panel: " + pconfig.getString("panels." + panels + ".title")));
}
String item = "";
String key;
for (Iterator var6 = Objects.requireNonNull(pconfig.getConfigurationSection("panels." + panels + ".item")).getKeys(false).iterator(); var6.hasNext(); item = item + key + " ") {
key = (String) var6.next();
}
item = item.trim();
int c;
for (c = 0; item.split("\\s").length - 1 >= c; ++c) {
if(item.equals("")){
//skip putting any items in the inventory if it is empty
break;
}
String section = "";
//onOpen needs to not be 3 so the editor won't include hasperm and hasvalue, etc items
if (onOpen != 3) {
section = itemCreate.hasSection(pconfig.getConfigurationSection("panels." + panels + ".item." + Integer.parseInt(item.split("\\s")[c])), p);
//This section is for animations below here: VISUAL ONLY
//check for if there is animations inside the items section
if (pconfig.contains("panels." + panels + ".item." + item.split("\\s")[c] + section + ".animate" + animateValue)) {
//check for if it contains the animate that has the animvatevalue
if (pconfig.contains("panels." + panels + ".item." + item.split("\\s")[c] + section + ".animate" + animateValue)) {
section = section + ".animate" + animateValue;
}
}
}
ItemStack s = itemCreate.makeItemFromConfig(Objects.requireNonNull(pconfig.getConfigurationSection("panels." + panels + ".item." + item.split("\\s")[c] + section)), p, onOpen != 3, onOpen != 3);
try {
i.setItem(Integer.parseInt(item.split("\\s")[c]), s);
} catch (ArrayIndexOutOfBoundsException var24) {
debug(var24);
if (debug) {
p.sendMessage(papi(tag + this.config.getString("config.format.error") + " item: One of the items does not fit in the Panel!"));
}
}
}
if (pconfig.contains("panels." + panels + ".empty") && !Objects.equals(pconfig.getString("panels." + panels + ".empty"), "AIR")) {
for (c = 0; Integer.parseInt(Objects.requireNonNull(pconfig.getString("panels." + panels + ".rows"))) * 9 - 1 >= c; ++c) {
boolean found = false;
if(!item.equals("")) {
for (int f = 0; item.split("\\s").length - 1 >= f; ++f) {
if (Integer.parseInt(item.split("\\s")[f]) == c) {
found = true;
}
}
}
if (!found) {
ItemStack empty;
try {
empty = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(pconfig.getString("panels." + panels + ".empty")).toUpperCase())), 1);
if (empty.getType() == Material.AIR) {
continue;
}
} catch (IllegalArgumentException | NullPointerException var26) {
debug(var26);
p.sendMessage(papi(tag + this.config.getString("config.format.error") + " empty: " + pconfig.getString("panels." + panels + ".empty")));
return null;
}
ItemMeta renamedMeta = empty.getItemMeta();
assert renamedMeta != null;
renamedMeta.setDisplayName(" ");
empty.setItemMeta(renamedMeta);
if (onOpen != 3) {
//only place empty items if not editing
i.setItem(c, empty);
}
}
}
}
if (papi( Objects.requireNonNull(pconfig.getString("panels." + panels + ".title"))).equals("Chest")) {
p.sendMessage(papi(tag + this.config.getString("config.format.error") + " Title: Cannot be named Chest"));
return null;
}
if (papi( Objects.requireNonNull(pconfig.getString("panels." + panels + ".title"))).contains("Editing Panel:")) {
p.sendMessage(papi(tag + this.config.getString("config.format.error") + " Title: Cannot contain Editing Panel:"));
return null;
}
if (papi( Objects.requireNonNull(pconfig.getString("panels." + panels + ".title"))).contains("Panel Settings:")) {
p.sendMessage(papi(tag + this.config.getString("config.format.error") + " Title: Cannot contain Panel Settings:"));
return null;
}
if (papi( Objects.requireNonNull(pconfig.getString("panels." + panels + ".title"))).contains("Item Settings:")) {
p.sendMessage(papi(tag + this.config.getString("config.format.error") + " Title: Cannot contain Item Settings:"));
return null;
}
if (papi( Objects.requireNonNull(pconfig.getString("panels." + panels + ".title"))).equals("Command Panels Editor")) {
p.sendMessage(papi(tag + this.config.getString("config.format.error") + " Title: Cannot be named Command Panels Editor"));
return null;
}
if (onOpen == 1 || onOpen == 3) {
//onOpen 1 is default and 3 is for the editor
p.openInventory(i);
} else if (onOpen == 0) {
//onOpen 0 will just refresh the panel
p.getOpenInventory().getTopInventory().setStorageContents(i.getStorageContents());
} else if (onOpen == 2) {
//will return the inventory, not opening it at all
return i;
}
return i;
} else {
p.sendMessage(papi(tag + this.config.getString("config.format.error") + " rows: " + pconfig.getString("panels." + panels + ".rows")));
return null;
}
}
public void setName(ItemStack renamed, String customName, List<String> lore, Player p, Boolean usePlaceholders, Boolean useColours) {
try {
ItemMeta renamedMeta = renamed.getItemMeta();
//set cp placeholders
if(usePlaceholders){
customName = papiNoColour(p,customName);
}
if(useColours){
customName = papi(customName);
}
assert renamedMeta != null;
renamedMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
if (customName != null) {
renamedMeta.setDisplayName(customName);
}
List<String> clore;
if (lore != null) {
if(usePlaceholders && useColours){
clore = papi(p, lore, true);
}else if(usePlaceholders){
clore = papiNoColour(p, lore);
}else if(useColours){
clore = papi(p, lore, false);
}else{
clore = lore;
}
renamedMeta.setLore(clore);
}
renamed.setItemMeta(renamedMeta);
} catch (Exception ignored) {
}
}
private void setupEconomy() {
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
} else {
RegisteredServiceProvider<Economy> rsp = this.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
} else {
this.econ = (Economy) rsp.getProvider();
}
}
}
public boolean checkPanels(YamlConfiguration temp) {
try {
return temp.contains("panels");
} catch (Exception var3) {
return false;
}
}
public String getHeadBase64(ItemStack var0) {
if (var0.getType().equals(Material.PLAYER_HEAD) && var0.hasItemMeta()) {
try {
SkullMeta var1 = (SkullMeta) var0.getItemMeta();
assert var1 != null;
if (!var1.hasOwner()) {
Field var2 = var1.getClass().getDeclaredField("profile");
var2.setAccessible(true);
GameProfile var3 = (GameProfile) var2.get(var1);
Iterator var4 = var3.getProperties().get("textures").iterator();
if (var4.hasNext()) {
Property var5 = (Property) var4.next();
return var5.getValue();
}
}
}catch(Exception exc){/*If there is a problem with the head skip and return null*/}
}
return null;
}
//regular string papi
public String papi(Player p, String setpapi) {
try {
setpapi = setCpPlaceholders(p,setpapi);
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
setpapi = translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//string papi with no colours
public String papiNoColour(Player p, String setpapi) {
try {
setpapi = setCpPlaceholders(p,setpapi);
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//regular string papi, but only colours so Player doesn't need to be there
public String papi(String setpapi) {
try {
setpapi = translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//papi except if it is a String List
public List<String> papi(Player p, List<String> setpapi, boolean placeholders) {
try {
if(placeholders) {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, setCpPlaceholders(p, temp));
tempInt += 1;
}
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
int tempInt = 0;
//change colour
for(String temp : setpapi){
try {
setpapi.set(tempInt, translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', temp)));
}catch(NullPointerException ignore){
}
tempInt += 1;
}
return setpapi;
}
//papi except if it is a String List
public List<String> papiNoColour(Player p, List<String> setpapi) {
try {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, setCpPlaceholders(p, temp));
tempInt += 1;
}
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
return setpapi;
}
public String setCpPlaceholders(Player p, String str) {
String tag = config.getString("config.format.tag") + " ";
//replace nodes with PlaceHolders
str = str.replaceAll("%cp-player-displayname%", p.getDisplayName());
str = str.replaceAll("%cp-player-name%", p.getName());
str = str.replaceAll("%cp-player-world%", p.getWorld().getName());
str = str.replaceAll("%cp-player-x%", String.valueOf(Math.round(p.getLocation().getX())));
str = str.replaceAll("%cp-player-y%", String.valueOf(Math.round(p.getLocation().getY())));
str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ())));
str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
//placeholder to check for server availability
while (str.contains("%cp-server-")) {
int start = str.indexOf("%cp-server-");
int end = str.indexOf("%", str.indexOf("%cp-server-")+1);
String ip_port = str.substring(start, end).replace("%cp-server-", "").replace("%","");
Socket s = new Socket();
try {
s.connect(new InetSocketAddress(ip_port.split(":")[0], Integer.parseInt(ip_port.split(":")[1])), config.getInt("config.server-ping-timeout"));
str = str.replace(str.substring(start, end) + "%", papi(p, "true"));
s.close();
}catch (IOException ex){
str = str.replace(str.substring(start, end) + "%", papi(p, "false"));
}
}
while (str.contains("%cp-player-online-")) {
int start = str.indexOf("%cp-player-online-");
int end = str.indexOf("-find%",str.indexOf("%cp-player-online-")+1);
String playerLocation = str.substring(start, end).replace("%cp-player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Integer.parseInt(playerLocation) > playerFind.length) {
str = str.replace(str.substring(start, end) + "-find%", papi(p,Objects.requireNonNull(config.getString("config.format.offline"))));
} else {
str = str.replace(str.substring(start, end) + "-find%", playerFind[Integer.parseInt(playerLocation) - 1].getName());
}
}
try {
if (econ != null) {
str = str.replaceAll("%cp-player-balance%", String.valueOf(Math.round(econ.getBalance(p))));
}
} catch (Exception place) {
//skip
}
if (this.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
str = str.replaceAll("%cp-tokenmanager-balance%", Long.toString(api.getTokens(p).orElse(0)));
}
if (this.getServer().getPluginManager().isPluginEnabled("VotingPlugin")) {
str = str.replaceAll("%cp-votingplugin-points%", String.valueOf(UserManager.getInstance().getVotingPluginUser(p).getPoints()));
}
if (str.contains("%cp-player-input%")) {
for (String[] key : userInputStrings) {
if (key[0].equals(p.getName())) {
userInputStrings.add(new String[]{p.getName(), str});
return "commandpanels:commandpanelclose";
}
}
userInputStrings.add(new String[]{p.getName(), str});
List<String> inputMessages = new ArrayList<String>(config.getStringList("config.input-message"));
for (String temp : inputMessages) {
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(config.getString("config.input-cancel")));
temp = temp.replaceAll("%cp-tag%", tag);
p.sendMessage(papi(p, temp));
}
str = "commandpanels:commandpanelclose";
}
//end nodes with PlaceHolders
return str;
}
//look through all files in all folders
public void fileNamesFromDirectory(File directory) {
for (String fileName : Objects.requireNonNull(directory.list())) {
if(new File(directory + File.separator + fileName).isDirectory()){
fileNamesFromDirectory(new File(directory + File.separator + fileName));
continue;
}
int ind = fileName.lastIndexOf(".");
if(!fileName.substring(ind).equalsIgnoreCase(".yml") && !fileName.substring(ind).equalsIgnoreCase(".yaml")){
continue;
}
//check before adding the file to commandpanels
if(!checkPanels(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)))){
this.getServer().getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error in: " + fileName);
continue;
}
panelFiles.add((directory + File.separator + fileName).replace(panelsf.toString() + File.separator,""));
for (String tempName : Objects.requireNonNull(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).getConfigurationSection("panels")).getKeys(false)) {
panelNames.add(new String[]{tempName, Integer.toString(panelFiles.size()-1)});
if(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).contains("panels." + tempName + ".open-with-item")) {
openWithItem = true;
}
}
}
}
public void reloadPanelFiles() {
panelFiles.clear();
panelNames.clear();
openWithItem = false;
//load panel files
fileNamesFromDirectory(panelsf);
}
public void debug(Exception e) {
if (debug) {
e.printStackTrace();
}
}
public void helpMessage(CommandSender p) {
String tag = config.getString("config.format.tag") + " ";
p.sendMessage(papi( tag + ChatColor.GREEN + "Commands:"));
p.sendMessage(ChatColor.GOLD + "/cp <panel> [player:item] [player] " + ChatColor.WHITE + "Open a command panel.");
if (p.hasPermission("commandpanel.reload")) {
p.sendMessage(ChatColor.GOLD + "/cpr " + ChatColor.WHITE + "Reloads plugin config.");
}
if (p.hasPermission("commandpanel.addons")) {
p.sendMessage(ChatColor.GOLD + "/cpa " + ChatColor.WHITE + "View downloadable addons for CommandPanels.");
}
p.sendMessage(ChatColor.GOLD + "/cpc " + ChatColor.WHITE + "Close current GUI.");
if (p.hasPermission("commandpanel.generate")) {
p.sendMessage(ChatColor.GOLD + "/cpg <rows> " + ChatColor.WHITE + "Generate GUI from popup menu.");
}
if (p.hasPermission("commandpanel.version")) {
p.sendMessage(ChatColor.GOLD + "/cpv " + ChatColor.WHITE + "Display the current version.");
}
if (p.hasPermission("commandpanel.edit")) {
p.sendMessage(ChatColor.GOLD + "/cpe [panel] " + ChatColor.WHITE + "Edit a panel with the Panel Editor.");
}
if (p.hasPermission("commandpanel.list")) {
p.sendMessage(ChatColor.GOLD + "/cpl " + ChatColor.WHITE + "Lists the currently loaded panels.");
}
if (p.hasPermission("commandpanel.debug")) {
p.sendMessage(ChatColor.GOLD + "/cpd " + ChatColor.WHITE + "Enable and Disable debug mode globally.");
}
if (p.hasPermission("commandpanel.block.add")) {
p.sendMessage(ChatColor.GOLD + "/cpb add <panel> " + ChatColor.WHITE + "Add panel to a block being looked at.");
}
if (p.hasPermission("commandpanel.block.remove")) {
p.sendMessage(ChatColor.GOLD + "/cpb remove " + ChatColor.WHITE + "Removes any panel assigned to a block looked at.");
}
if (p.hasPermission("commandpanel.block.list")) {
p.sendMessage(ChatColor.GOLD + "/cpb list " + ChatColor.WHITE + "List blocks that will open panels.");
}
}
public final Map<String, Color> colourCodes = new HashMap<String, Color>() {{
put("AQUA", Color.AQUA);
put("BLUE", Color.BLUE);
put("GRAY", Color.GRAY);
put("GREEN", Color.GREEN);
put("RED", Color.RED);
put("WHITE", Color.WHITE);
put("BLACK", Color.BLACK);
put("FUCHSIA", Color.FUCHSIA);
put("LIME", Color.LIME);
put("MAROON", Color.MAROON);
put("NAVY", Color.NAVY);
put("OLIVE", Color.OLIVE);
put("ORANGE", Color.ORANGE);
put("PURPLE", Color.PURPLE);
put("SILVER", Color.SILVER);
put("TEAL", Color.TEAL);
put("YELLOW", Color.YELLOW);
}};
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
//this reads the encrypted resource files in the jar file
if(Bukkit.getVersion().contains("1.13")){
return new sequence_1_13().getReaderFromStream(initialStream);
}else{
return new sequence_1_14().getReaderFromStream(initialStream);
}
}
public String githubNewUpdate(boolean sendMessages){
HttpURLConnection connection;
String gitVersion;
if(this.getDescription().getVersion().contains("-")){
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GREEN + " Running a custom version.");
}
return null;
}
try{
connection = (HttpURLConnection) new URL("https://raw.githubusercontent.com/rockyhawk64/CommandPanels/master/resource/plugin.yml").openConnection();
connection.connect();
gitVersion = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine().split("\\s")[1];
if(gitVersion.contains("-")){
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update.");
}
return null;
}
if(!this.getDescription().getVersion().equals(gitVersion)){
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " ================================================");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " An update for CommandPanels is available.");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download version " + gitVersion + " here:");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " https://www.spigotmc.org/resources/command-panels-custom-guis.67788/");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " ================================================");
}
return gitVersion;
}
}catch(IOException e){
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error checking for updates online.");
}
debug(e);
}
return null;
}
//used to translate hex colours into ChatColors
public String translateHexColorCodes(String message) {
final Pattern hexPattern = Pattern.compile("#" + "([A-Fa-f0-9]{6})");
Matcher matcher = hexPattern.matcher(message);
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
while (matcher.find()) {
String group = matcher.group(1);
matcher.appendReplacement(buffer, ChatColor.COLOR_CHAR + "x"
+ ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1)
+ ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3)
+ ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5)
);
}
return matcher.appendTail(buffer).toString();
}
}

View File

@ -1,182 +0,0 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.*;
public class commandpanel implements CommandExecutor {
commandpanels plugin;
public commandpanel(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
YamlConfiguration cf = null; //this is the file to use for any panel.* requests
String panels = "";
ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (titles of panels)
ArrayList<String> opanels = new ArrayList<String>(); //all panels from all files (raw names of panels)
boolean found = false;
//below is going to go through the files and find the right one
if (args.length != 0) { //check to make sure the person hasn't just left it empty
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if(!plugin.checkPanels(temp)){
continue;
}
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
apanels.add(temp.getString("panels." + key + ".title"));
opanels.add(key);
if (args[0].equalsIgnoreCase(key)){
found = true;
panels = key;
cf = temp;
}
}
}
}else{
plugin.helpMessage(sender);
return true;
}
if(!found){
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return true;
}
//below will start the command, once it got the right file and panel
if (cmd.getName().equalsIgnoreCase("cp") || cmd.getName().equalsIgnoreCase("commandpanel") || cmd.getName().equalsIgnoreCase("cpanel")) {
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = panels.split("\\s")[i];
nfound = false;
}
}
if (nfound) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return true;
}else if (!checkconfig(panels, sender, cf)) {
//if the config is missing an element (message will be sent to user via the public boolean)
return true;
}
checkDuplicatePanel(sender,opanels,apanels);
if(!(sender instanceof Player)) {
//do console command command
if(args.length == 2){
if(!args[1].equals("item")){
plugin.openVoids.openCommandPanel(sender,plugin.getServer().getPlayer(args[1]),panels,cf,true);
return true;
}else{
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
return true;
}
}else if(args.length == 3){
if (args[1].equals("item")) {
plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panels,cf,true);
return true;
}else{
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
return true;
}
} else {
sender.sendMessage(plugin.papi( tag + ChatColor.RED + "Please execute command directed to a Player!"));
return true;
}
}else{
//get player
Player p = (Player) sender;
//do player command
if (args.length == 1) {
plugin.openVoids.openCommandPanel(sender, p, panels, cf,false);
return true;
}else if(args.length == 2){
if (args[1].equals("item")) {
plugin.openVoids.giveHotbarItem(sender, p, panels, cf, false);
}else{
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panels, cf,true);
}
return true;
}else if(args.length == 3){
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panels, cf,true);
return true;
}
}
}
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> [player:item] [player]"));
return true;
}
boolean checkDuplicatePanel(CommandSender sender, ArrayList<String> opanels, ArrayList<String> apanels){
String tag = plugin.config.getString("config.format.tag") + " ";
//names is a list of the titles for the Panels
Set<String> oset = new HashSet<String>(opanels);
if (oset.size() < opanels.size()) {
//there are duplicate panel names
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " panels: You cannot have duplicate panel names!"));
if(plugin.debug){
ArrayList<String> opanelsTemp = new ArrayList<String>();
for(String tempName : opanels){
if(opanelsTemp.contains(tempName)){
sender.sendMessage(plugin.papi(tag + ChatColor.RED + " The duplicate panel is: " + tempName));
return false;
}
opanelsTemp.add(tempName);
}
}
return false;
}
Set<String> set = new HashSet<String>(apanels);
if (set.size() < apanels.size()) {
//there are duplicate panel titles
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " title: You cannot have duplicate title names!"));
if(plugin.debug){
ArrayList<String> apanelsTemp = new ArrayList<String>();
for(String tempName : apanels){
if(apanelsTemp.contains(tempName)){
sender.sendMessage(plugin.papi(tag + ChatColor.RED + " The duplicate title is: " + tempName));
return false;
}
apanelsTemp.add(tempName);
}
}
return false;
}
return true;
}
boolean checkconfig(String panels, CommandSender sender, YamlConfiguration pconfig) {
//if it is missing a section specified it will return false
String tag = plugin.config.getString("config.format.tag") + " ";
if(!pconfig.contains("panels." + panels)) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return false;
}
if(!pconfig.contains("panels." + panels + ".perm")) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".rows")) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".title")) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".item")) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
return true;
}
}

View File

@ -1,31 +0,0 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
public class commandpanelclose implements CommandExecutor {
commandpanels plugin;
public commandpanelclose(commandpanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if(!(sender instanceof Player)) {
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Please execute command as a Player!"));
return true;
}
Player p = (Player)sender;
if (cmd.getName().equalsIgnoreCase("cpc") || cmd.getName().equalsIgnoreCase("commandpanelclose") && sender instanceof Player || cmd.getName().equalsIgnoreCase("cpanelc") && sender instanceof Player) {
p.closeInventory();
return true;
}
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpc"));
return true;
}
}

View File

@ -1,76 +0,0 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Objects;
public class commandpanelcustom implements Listener {
commandpanels plugin;
public commandpanelcustom(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public void PlayerCommand(PlayerCommandPreprocessEvent e) {
String panels;
String tag = plugin.config.getString("config.format.tag") + " ";
Player p = e.getPlayer();
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
try {
if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) {
return;
}
}catch(Exception b){
return;
}
YamlConfiguration cf = null; //this is the file to use for any panel.* requests
ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names)
String tpanels; //tpanels is the temp to check through the files
String panel = null;
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
apanels.add(key);
}
tpanels = tpanels.trim();
//check if the requested panel is in the file (then set the config to that panel file)
for(int i = 0; i < tpanels.split("\\s").length;i++){
if(temp.contains("panels." + tpanels.split("\\s")[i] + ".command")) {
for(int c = 0; c < temp.getString("panels." + tpanels.split("\\s")[i] + ".command").split("\\s").length;c++) {
if (("/" + temp.getString("panels." + tpanels.split("\\s")[i] + ".command").split("\\s")[c]).equalsIgnoreCase(e.getMessage())) {
cf = temp;
panels = tpanels;
panels = panels.trim();
panel = panels.split("\\s")[i];
break;
}
}
}
}
}
if(panel == null){
return;
}
e.setCancelled(true);
try {
plugin.openVoids.openCommandPanel(p,p,panel,cf,false);
}catch(Exception er){
//do nothing
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Error opening panel!"));
}
}
}

View File

@ -1,33 +0,0 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
public class commandpanelresources implements CommandExecutor {
commandpanels plugin;
public commandpanelresources(commandpanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if (label.equalsIgnoreCase("cpa") || label.equalsIgnoreCase("commandpaneladdons") || label.equalsIgnoreCase("cpanela")) {
if (sender.hasPermission("commandpanel.addons")) {
//version command
sender.sendMessage(plugin.papi(tag));
sender.sendMessage(ChatColor.GREEN + "Version " + ChatColor.GRAY + plugin.getDescription().getVersion());
sender.sendMessage(ChatColor.GREEN + "Find Addons " + ChatColor.GRAY + "https://commandpanels.org/resources/");
return true;
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpa"));
return true;
}
}

View File

@ -1,39 +0,0 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
public class commandpanelsdebug implements CommandExecutor {
commandpanels plugin;
public commandpanelsdebug(commandpanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if (label.equalsIgnoreCase("cpd") || label.equalsIgnoreCase("commandpaneldebug") || label.equalsIgnoreCase("cpaneld")) {
if (sender.hasPermission("commandpanel.debug")) {
if (args.length == 0) {
//command /cpd
plugin.debug = !plugin.debug;
if(plugin.debug){
sender.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Debug Mode Enabled!"));
}else{
sender.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Debug Mode Disabled!"));
}
}else{
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpd"));
}
return true;
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpd"));
return true;
}
}

View File

@ -1,91 +0,0 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
public class commandpanelslist implements CommandExecutor {
commandpanels plugin;
public commandpanelslist(commandpanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if (label.equalsIgnoreCase("cpl") || label.equalsIgnoreCase("commandpanellist") || label.equalsIgnoreCase("cpanell")) {
if (sender.hasPermission("commandpanel.list")) {
//command /cpl
//check to make sure the panels isn't empty
try {
if (plugin.panelFiles == null) {
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "No panels found!"));
return true;
}
}catch(Exception b){
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "No panels found!"));
return true;
}
ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names)
String tpanels; //tpanels is the temp to check through the files
for (int f = 0; plugin.panelFiles.size() > f; f++) { //will loop through all the files in folder
String key;
YamlConfiguration temp;
tpanels = "";
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(f)));
apanels.add("%file%" + plugin.panelFiles.get(f));
if(!plugin.checkPanels(temp)){
apanels.add("Error Reading File!");
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
apanels.add(key);
}
}
int page = 1;
int skip = 0;
if(args.length == 1){
try {
page = Integer.parseInt(args[0]);
skip = page*9-9;
}catch (Exception e){
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Inaccessible Page"));
}
}
for (int f = skip; apanels.size() > f; f++) {
if(!apanels.get(f).contains("%file%")){
skip++;
}else{
break;
}
}
sender.sendMessage(plugin.papi(tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")"));
for (int f = skip; apanels.size() > f; f++) {
if(apanels.get(f).contains("%file%")){
if(skip+9 <= f){
sender.sendMessage(ChatColor.AQUA + "Type /cpl " + (page+1) + " to read next page");
break;
}
sender.sendMessage(ChatColor.DARK_GREEN + apanels.get(f).replaceAll("%file%",""));
}else{
sender.sendMessage(ChatColor.GREEN + "- " + apanels.get(f));
}
}
return true;
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpl"));
return true;
}
}

View File

@ -1,41 +0,0 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import java.io.File;
import java.io.IOException;
public class commandpanelsreload implements CommandExecutor {
commandpanels plugin;
public commandpanelsreload(commandpanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if (label.equalsIgnoreCase("cpr") || label.equalsIgnoreCase("commandpanelreload") || label.equalsIgnoreCase("cpanelr")) {
if (sender.hasPermission("commandpanel.reload")) {
plugin.reloadPanelFiles();
try {
YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "temp.yml")).save(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
} catch (IOException e) {
//skip clearing temp
}
plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml"));
tag = plugin.config.getString("config.format.tag") + " ";
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.reload")));
return true;
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpr"));
return true;
}
}

View File

@ -1,34 +0,0 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
public class commandpanelversion implements CommandExecutor {
commandpanels plugin;
public commandpanelversion(commandpanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if (label.equalsIgnoreCase("cpv") || label.equalsIgnoreCase("commandpanelversion") || label.equalsIgnoreCase("cpanelv")) {
if (sender.hasPermission("commandpanel.version")) {
//version command
sender.sendMessage(plugin.papi(tag));
sender.sendMessage(ChatColor.GREEN + "Version " + ChatColor.GRAY + plugin.getDescription().getVersion());
sender.sendMessage(ChatColor.GREEN + "Developer " + ChatColor.GRAY + "RockyHawk");
sender.sendMessage(ChatColor.GREEN + "Command " + ChatColor.GRAY + "/cp");
return true;
}else{
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpv"));
return true;
}
}

View File

@ -1,62 +0,0 @@
package me.rockyhawk.commandPanels.completeTabs;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.yaml.snakeyaml.scanner.ScannerException;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class cpTabComplete implements TabCompleter {
commandpanels plugin;
public cpTabComplete(commandpanels pl) { this.plugin = pl; }
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player && args.length == 1){
Player p = ((Player) sender).getPlayer();
if(label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")){
ArrayList<String> apanels = new ArrayList<String>(); //all panels
String tpanels; //tpanels is the temp to check through the files
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
try {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if (!plugin.checkPanels(temp)) {
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if (!key.startsWith(args[0])) {
//this will narrow down the panels to what the user types
continue;
}
if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
if (temp.contains("panels." + key + ".disabled-worlds")) {
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
if (!disabledWorlds.contains(p.getWorld().getName())) {
apanels.add(key);
}
} else {
apanels.add(key);
}
}
}
}catch(Exception skip){
//ignore panel
}
//if file contains opened panel then start
}
return apanels;
}
}
return null;
}
}

View File

@ -1,149 +0,0 @@
package me.rockyhawk.commandPanels.generatePanels;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.*;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
public class newGenUtils implements Listener {
public YamlConfiguration tempEdit;
commandpanels plugin;
public newGenUtils(commandpanels pl) {
this.plugin = pl;
this.tempEdit = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent e) {
Player p = (Player)e.getPlayer();
if (!ChatColor.stripColor(e.getView().getTitle()).equals("Generate New Panel")){
return;
}
//reload panel files to avoid conflicts
plugin.reloadPanelFiles();
generatePanel(p,e.getInventory());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
Player p = e.getPlayer();
//if the player is in generate mode, remove generate mode
this.plugin.generateMode.remove(p);
for(int o = 0; this.plugin.userInputStrings.size() > o; ++o) {
if (this.plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())) {
this.plugin.userInputStrings.remove(o);
break;
}
}
}
@EventHandler
public void onInventoryOpenEvent(InventoryOpenEvent e) {
HumanEntity h = e.getPlayer();
Player p = Bukkit.getPlayer(h.getName());
if ((e.getInventory().getHolder() instanceof Chest || e.getInventory().getHolder() instanceof DoubleChest) && this.plugin.generateMode.contains(p)) {
this.plugin.generateMode.remove(p);
generatePanel(p,e.getInventory());
}
}
@SuppressWarnings("deprecation")
void generatePanel(Player p, Inventory inv){
ItemStack[] cont = inv.getContents();
String tag = plugin.config.getString("config.format.tag") + " ";
ArrayList<String> apanels = new ArrayList();
for(String[] panelNames : plugin.panelNames){
//create list of names that aren't a String list
apanels.add(panelNames[0]);
}
//this is done to make sure the inventories are not empty
boolean foundItem = false;
for(ItemStack temp : inv.getContents()){
if(temp != null){
foundItem = true;
break;
}
}
if(!foundItem){
//panels don't need items but I cancel on generate with no items because then players have the option to cancel if they need to
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Cancelled Panel!"));
return;
}
YamlConfiguration file;
//String date: is what the panel and file name will be called
String date = "panel-1";
for(int count = 1; (Arrays.asList(Objects.requireNonNull(plugin.panelsf.list())).contains("panel-" + count + ".yml")) || (apanels.contains("panel-" + count)); count++){
date = "panel-" + (count+1);
}
File folder = new File(plugin.getDataFolder() + File.separator + "panels");
file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml"));
file.addDefault("panels." + date + ".perm", "default");
file.addDefault("panels." + date + ".panelType", "default");
file.addDefault("panels." + date + ".rows", inv.getSize()/9);
file.addDefault("panels." + date + ".title", "&8Generated " + date);
file.addDefault("panels." + date + ".command", date);
file.addDefault("panels." + date + ".empty", "BLACK_STAINED_GLASS_PANE");
for(int i = 0; cont.length > i; i++){
//repeat through all the items in the chest
try{
//make the item here
if(cont[i].getType() == Material.PLAYER_HEAD){
SkullMeta meta = (SkullMeta) cont[i].getItemMeta();
if(plugin.getHeadBase64(cont[i]) != null){
//check for base64
file.addDefault("panels." + date + ".item." + i + ".material", "cps= " + plugin.getHeadBase64(cont[i]));
}else if(meta.hasOwner()){
//check for skull owner
file.addDefault("panels." + date + ".item." + i + ".material", "cps= " + meta.getOwner());
}else{
file.addDefault("panels." + date + ".item." + i + ".material", cont[i].getType().toString());
}
}else {
file.addDefault("panels." + date + ".item." + i + ".material", cont[i].getType().toString());
}
if(cont[i].getAmount() != 1){
file.addDefault("panels." + date + ".item." + i + ".stack", cont[i].getAmount());
}
if(!cont[i].getEnchantments().isEmpty()){
file.addDefault("panels." + date + ".item." + i + ".enchanted", "true");
}
try {
PotionMeta potionMeta = (PotionMeta) cont[i].getItemMeta();
file.addDefault("panels." + date + ".item." + i + ".potion", potionMeta.getBasePotionData().getType().name());
} catch (Exception er) {
//don't add the effect
}
file.addDefault("panels." + date + ".item." + i + ".name", Objects.requireNonNull(cont[i].getItemMeta()).getDisplayName());
file.addDefault("panels." + date + ".item." + i + ".lore", Objects.requireNonNull(cont[i].getItemMeta()).getLore());
}catch(Exception n){
//skip over an item that spits an error
}
}
file.options().copyDefaults(true);
try {
file.save(new File(plugin.panelsf + File.separator + date + ".yml"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml"));
} catch (IOException var16) {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Save Generated Panel!"));
}
plugin.reloadPanelFiles();
}
}

View File

@ -1,167 +0,0 @@
package me.rockyhawk.commandPanels.ingameEditor;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import java.io.File;
import java.util.*;
public class cpIngameEditCommand implements CommandExecutor {
commandpanels plugin;
public cpIngameEditCommand(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if(!sender.hasPermission("commandpanel.edit")){
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
if(Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("false")){
//this will cancel every /cpe command if ingame-editor is set to false
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Editor disabled!"));
return true;
}
if(!(sender instanceof Player)) {
sender.sendMessage(plugin.papi( tag + ChatColor.RED + "Please execute command as a Player!"));
return true;
}
File panelscf = new File(plugin.getDataFolder() + File.separator + "panels" + File.separator + "example.yml"); //cf == correct file
YamlConfiguration cf; //this is the file to use for any panel.* requests
String panels = "";
ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (titles of panels)
ArrayList<String> opanels = new ArrayList<String>(); //all panels from all files (raw names of panels)
String tpanels; //tpanels is the temp to check through the files
//below is going to go through the files and find the right one
if (args.length != 0) { //check to make sure the person hasn't just left it empty
for (String filename : plugin.panelFiles) { //will loop through all the files in folder
String key;
YamlConfiguration temp;
tpanels = "";
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
if (!plugin.checkPanels(temp)) {
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
apanels.add(temp.getString("panels." + key + ".title"));
opanels.add(key);
}
tpanels = tpanels.trim();
//check if the requested panel is in the file
boolean nfound = true;
for (int i = 0; tpanels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(tpanels.split("\\s")[i])) {
tpanels = tpanels.split("\\s")[i];
nfound = false;
}
}
//if nfound is true it was not found
if (!nfound) {
panels = tpanels;
panelscf = new File(plugin.panelsf + File.separator + filename);
}
}
panels = panels.trim();
}
cf = YamlConfiguration.loadConfiguration(panelscf);
//below will start the command, once it got the right file and panel
if (cmd.getName().equalsIgnoreCase("cpe") || cmd.getName().equalsIgnoreCase("commandpaneledit") || cmd.getName().equalsIgnoreCase("cpanele")) {
Player p = (Player) sender;
//names is a list of the titles for the Panels
Set<String> oset = new HashSet<String>(opanels);
if (oset.size() < opanels.size()) {
//there are duplicate panel names
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " panels: You cannot have duplicate panel names!"));
if(plugin.debug){
ArrayList<String> opanelsTemp = new ArrayList<String>();
for(String tempName : opanels){
if(opanelsTemp.contains(tempName)){
p.sendMessage(plugin.papi(tag + ChatColor.RED + " The duplicate panel is: " + tempName));
return true;
}
opanelsTemp.add(tempName);
}
}
return true;
}
Set<String> set = new HashSet<String>(apanels);
if (set.size() < apanels.size()) {
//there are duplicate panel names
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " title: You cannot have duplicate title names!"));
if(plugin.debug){
ArrayList<String> apanelsTemp = new ArrayList<String>();
for(String tempName : apanels){
if(apanelsTemp.contains(tempName)){
p.sendMessage(plugin.papi(tag + ChatColor.RED + " The duplicate title is: " + tempName));
return true;
}
apanelsTemp.add(tempName);
}
}
return true;
}
if (args.length == 0) {
plugin.editorGuis.openEditorGui(p,0);
return true;
}
if (args.length == 1) {
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = panels.split("\\s")[i];
nfound = false;
}
}
if (nfound) {
//if the panel was not found in the message
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return true;
}else if (!checkconfig(panels, p, cf)) {
//if the config is missing an element (message will be sent to user via the public boolean)
return true;
}
//open editor window here
plugin.openGui(panels, p, cf,3,0);
return true;
}
}
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpe <panel>"));
return true;
}
boolean checkconfig(String panels, Player p, YamlConfiguration pconfig) {
//if it is missing a section specified it will return false
String tag = plugin.config.getString("config.format.tag") + " ";
if(!pconfig.contains("panels." + panels)) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return false;
}
if(!pconfig.contains("panels." + panels + ".perm")) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".rows")) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".title")) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".item")) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
return true;
}
}

View File

@ -1,64 +0,0 @@
package me.rockyhawk.commandPanels.ingameEditor;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
public class cpTabCompleteIngame implements TabCompleter {
commandpanels plugin;
public cpTabCompleteIngame(commandpanels pl) { this.plugin = pl; }
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player && args.length == 1){
Player p = ((Player) sender).getPlayer();
if(label.equalsIgnoreCase("cpe") || label.equalsIgnoreCase("cpanele") || label.equalsIgnoreCase("commandpaneledit")){
ArrayList<String> apanels = new ArrayList<String>(); //all panels
String tpanels; //tpanels is the temp to check through the files
try {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if(!key.startsWith(args[0])){
//this will narrow down the panels to what the user types
continue;
}
if(sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
if(temp.contains("panels." + key + ".disabled-worlds")){
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
assert p != null;
assert disabledWorlds != null;
if(!disabledWorlds.contains(p.getWorld().getName())){
apanels.add(key);
}
}else{
apanels.add(key);
}
}
}
//if file contains opened panel then start
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
}
return apanels;
}
}
return null;
}
}

View File

@ -1,481 +0,0 @@
package me.rockyhawk.commandPanels.ingameEditor;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class editorUserInput implements Listener {
commandpanels plugin;
public editorUserInput(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public void onPlayerChatEditor(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
for(String[] temp : plugin.editorInputStrings) {
//[0] is player name [1] is panel name [2] is section type
if (!temp[0].equals(p.getName())) {
continue;
}
e.setCancelled(true);
String panelName = temp[1];
String panelTitle = temp[1];
File panelFile = null;
String section = temp[2];
YamlConfiguration cf = null;
try {
for (String tempFile : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration tempConf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile));
if (!plugin.checkPanels(tempConf)) {
continue;
}
for (String key : Objects.requireNonNull(tempConf.getConfigurationSection("panels")).getKeys(false)) {
if (key.equals(panelName)) {
cf = tempConf;
panelFile = new File(plugin.panelsf + File.separator + tempFile);
panelTitle = plugin.papi( Objects.requireNonNull(tempConf.getString("panels." + key + ".title")));
break;
}
}
//if file contains opened panel then start
}
} catch (Exception fail) {
//could not fetch all panel names (probably no panels exist)
}
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
plugin.editorInputStrings.remove(temp);
plugin.reloadPanelFiles();
e.getPlayer().sendMessage(plugin.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
return;
}
if(section.startsWith("panel.")) {
panelSectionCheck(p, section, panelName, panelTitle, cf, panelFile, e);
}else if(section.startsWith("item.")){
itemSectionCheck(p, section, panelName, cf, panelFile, e);
}
plugin.editorInputStrings.remove(temp);
plugin.reloadPanelFiles();
if(section.startsWith("panel.")){
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.editorGuis.openEditorGui(p, 0); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
}else if(section.startsWith("item.")) {
final YamlConfiguration finalCF = cf;
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.openGui(panelName, p, finalCF, 3,0); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
}
return;
}
}
boolean savePanelFile(YamlConfiguration cf, File panelFile){
try {
cf.save(panelFile);
return true;
} catch (Exception io) {
plugin.debug(io);
return false;
}
}
void panelSectionCheck(Player p, String section, String panelName, String panelTitle, YamlConfiguration cf, File panelFile, AsyncPlayerChatEvent e){
String tag = plugin.config.getString("config.format.tag") + " ";
switch (section) {
case "panel.delete":
if (e.getMessage().contains("y")) {
if(Objects.requireNonNull(cf.getConfigurationSection("panels")).getKeys(false).size() != 1){
//if the file has more than one panel in it
cf.set("panels." + panelName, null);
if(savePanelFile(cf, panelFile)){
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Deleted Panel!"));
}else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Delete Panel!"));
}
}else {
//if the file only has one panel in it
if (panelFile.delete()) {
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Deleted Panel!"));
}else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Delete Panel!"));
}
}
}
break;
case "panel.perm":
if(e.getMessage().contains(" ")){
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Permission cannot contain spaces!"));
break;
}
cf.set("panels." + panelName + ".perm", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage()));
break;
case "panel.rows":
try {
int rows = Integer.parseInt(e.getMessage());
if (rows >= 7 || rows <= 0) {
//if the number isn't between 1-6
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Choose an integer between 1 to 6!"));
return;
}
cf.set("panels." + panelName + ".rows", rows);
cf.save(panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!"));
} catch (Exception io) {
plugin.debug(io);
}
break;
case "panel.title":
if(panelTitle.equals(plugin.papi(e.getMessage()))){
p.sendMessage(plugin.papi(tag + e.getMessage() + ChatColor.RED + " is in use from another panel!"));
break;
}
cf.set("panels." + panelName + ".title", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage()));
break;
case "panel.name":
if(e.getMessage().contains(" ")){
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Panel name cannot contain spaces!"));
break;
}
if(panelName.equals(e.getMessage())){
p.sendMessage(plugin.papi(tag + ChatColor.RED + e.getMessage() + " is in use from another panel!"));
break;
}
cf.set("panels." + e.getMessage(), cf.get("panels." + panelName));
cf.set("panels." + panelName, null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Name to " + e.getMessage()));
break;
case "panel.empty":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".empty", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Empty materials have been removed."));
break;
}
String materialTemp = null;
try {
materialTemp = Objects.requireNonNull(Material.matchMaterial(e.getMessage())).toString();
}catch(NullPointerException ex){
p.sendMessage(plugin.papi( tag + ChatColor.RED + e.getMessage() + " is not a valid Material!"));
}
cf.set("panels." + panelName + ".empty", materialTemp);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set Empty material to " + materialTemp));
break;
case "panel.sound-on-open":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".sound-on-open", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sounds have been removed."));
break;
}
String tempSound;
try {
tempSound = Sound.valueOf(e.getMessage()).toString();
}catch(Exception ex){
p.sendMessage(plugin.papi( tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!"));
return;
}
cf.set("panels." + panelName + ".sound-on-open", tempSound);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
break;
case "panel.command":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".command", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom commands have been removed."));
break;
}
cf.set("panels." + panelName + ".command", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new custom commands to " + ChatColor.WHITE + "/" + e.getMessage().trim().replace(" ", " /")));
break;
case "panel.commands-on-open.add":
List<String> commandsOnOpenAdd = new ArrayList<>();
if(cf.contains("panels." + panelName + ".commands-on-open")){
commandsOnOpenAdd = cf.getStringList("panels." + panelName + ".commands-on-open");
}
commandsOnOpenAdd.add(e.getMessage());
cf.set("panels." + panelName + ".commands-on-open", commandsOnOpenAdd);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "panel.commands-on-open.remove":
List<String> commandsOnOpenRemove;
if(cf.contains("panels." + panelName + ".commands-on-open")){
commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".commands-on-open");
}else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandsOnOpenRemove.size() == 0){
cf.set("panels." + panelName + ".commands-on-open", null);
}else{
cf.set("panels." + panelName + ".commands-on-open", commandsOnOpenRemove);
}
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
case "panel.hotbar.material":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".open-with-item", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Hotbar item have been removed."));
//after an open-with-item has been altered, reload after changes
plugin.reloadPanelFiles();
break;
}
cf.set("panels." + panelName + ".open-with-item.material", e.getMessage());
if(!cf.contains("panels." + panelName + ".open-with-item.name")){
cf.set("panels." + panelName + ".open-with-item.name", panelName + " Item");
}
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + e.getMessage()));
//after an open-with-item has been altered, reload after changes
plugin.reloadPanelFiles();
break;
case "panel.hotbar.stationary":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".open-with-item.stationary", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Hotbar item can now be moved."));
break;
}
try {
int loc = Integer.parseInt(e.getMessage());
if (loc >= 10 || loc <= 0) {
//if the number isn't between 1-9
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Choose an integer between 1 to 9!"));
return;
}
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
//because it needs to convert 1-9 to 0-8 for in the panel
loc -= 1;
cf.set("panels." + panelName + ".open-with-item.stationary", loc);
cf.save(panelFile);
} catch (Exception io) {
plugin.debug(io);
}
break;
case "panel.hotbar.name":
cf.set("panels." + panelName + ".open-with-item.name",e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage()));
break;
case "panel.hotbar.lore.add":
List<String> loreAdd = new ArrayList<>();
if(cf.contains("panels." + panelName + ".open-with-item.lore")){
loreAdd = cf.getStringList("panels." + panelName + ".open-with-item.lore");
}
loreAdd.add(e.getMessage());
cf.set("panels." + panelName + ".open-with-item.lore", loreAdd);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break;
case "panel.hotbar.lore.remove":
List<String> loreRemove;
if(cf.contains("panels." + panelName + ".open-with-item.lore")){
loreRemove = cf.getStringList("panels." + panelName + ".open-with-item.lore");
}else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No lore found to remove!"));
break;
}
try {
loreRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find lore!"));
break;
}
if(loreRemove.size() == 0){
cf.set("panels." + panelName + ".open-with-item.lore", null);
}else{
cf.set("panels." + panelName + ".open-with-item.lore", loreRemove);
}
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break;
}
}
void itemSectionCheck(Player p, String section, String panelName, YamlConfiguration cf, File panelFile, AsyncPlayerChatEvent e){
String tag = plugin.config.getString("config.format.tag") + " ";
String itemSlot = section.split("\\.")[1];
String sectionChange = section.replace("item." + itemSlot + ".","");
switch (sectionChange) {
case "name":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".name", "");
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Name is now default."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".name", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage()));
break;
case "head":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".material", "PLAYER_HEAD");
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Material is now default."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".material", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage()));
break;
case "stack":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".stack", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Item has been unstacked."));
break;
}
try {
int rows = Integer.parseInt(e.getMessage());
if (rows >= 65 || rows <= 0) {
//if the number isn't between 1-64
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Choose an integer between 1 to 64!"));
return;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".stack", rows);
cf.save(panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set stack to " + rows + "!"));
} catch (Exception io) {
plugin.debug(io);
}
break;
case "enchanted":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".enchanted", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Enchantments have been removed."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".enchanted", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage()));
break;
case "potion":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".potion", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Potion effects have been removed."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".potion", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase()));
break;
case "customdata":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".customdata", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom Model Data has been removed."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".customdata", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage()));
break;
case "leatherarmor":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".leatherarmor", null);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Leather armor colour has been removed."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".leatherarmor", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage()));
break;
case "commands.add":
List<String> commandsOnOpenAdd = new ArrayList<>();
if(cf.contains("panels." + panelName + ".item." + itemSlot + ".commands")){
commandsOnOpenAdd = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".commands");
}
commandsOnOpenAdd.add(e.getMessage());
cf.set("panels." + panelName + ".item." + itemSlot + ".commands", commandsOnOpenAdd);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "commands.remove":
List<String> commandsOnOpenRemove;
if(cf.contains("panels." + panelName + ".item." + itemSlot + ".commands")){
commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".commands");
}else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandsOnOpenRemove.size() == 0){
cf.set("panels." + panelName + ".item." + itemSlot + ".commands", null);
}else{
cf.set("panels." + panelName + ".item." + itemSlot + ".commands", commandsOnOpenRemove);
}
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
case "lore.add":
List<String> loreOnOpenAdd = new ArrayList<>();
if(cf.contains("panels." + panelName + ".item." + itemSlot + ".lore")){
loreOnOpenAdd = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".lore");
}
loreOnOpenAdd.add(e.getMessage());
cf.set("panels." + panelName + ".item." + itemSlot + ".lore", loreOnOpenAdd);
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break;
case "lore.remove":
List<String> loreOnOpenRemove;
if(cf.contains("panels." + panelName + ".item." + itemSlot + ".lore")){
loreOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".lore");
}else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No lore found to remove!"));
break;
}
try {
loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find lore!"));
break;
}
if(loreOnOpenRemove.size() == 0){
cf.set("panels." + panelName + ".item." + itemSlot + ".lore", null);
}else{
cf.set("panels." + panelName + ".item." + itemSlot + ".lore", loreOnOpenRemove);
}
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break;
}
}
}

View File

@ -1,678 +0,0 @@
package me.rockyhawk.commandPanels.ingameEditor;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
public class editorUtils implements Listener {
public YamlConfiguration tempEdit;
public ArrayList<String> inventoryItemSettingsOpening = new ArrayList<>();
commandpanels plugin;
public editorUtils(commandpanels pl) {
this.plugin = pl;
this.tempEdit = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
}
@EventHandler
public void onClickMainEdit(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
//if the inventory isn't the editor main window
try {
if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) {
return;
}
}catch(NullPointerException nu){return;}
if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.papi("Command Panels Editor")))){
return;
}
e.setCancelled(true);
if(e.getClickedInventory() != e.getView().getTopInventory()){
return;
}
ArrayList<String> panelNames = new ArrayList<String>(); //all panels from ALL files (panel names)
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
ArrayList<YamlConfiguration> panelYaml = new ArrayList<YamlConfiguration>(); //all panels from ALL files (panel yaml files)
try {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
if(!plugin.checkPanels(temp)){
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
panelNames.add(plugin.papi( key));
panelTitles.add(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
panelYaml.add(temp);
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
if(e.getSlot() == 48){
//previous page button
try {
if (Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER) {
plugin.editorGuis.openEditorGui(p, -1);
p.updateInventory();
return;
}
}catch(NullPointerException ignored){}
}
if(e.getSlot() == 49){
//sunflower page index
if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.SUNFLOWER){
p.updateInventory();
return;
}
}
if(e.getSlot() == 50){
//next page button
try{
if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER){
plugin.editorGuis.openEditorGui(p, 1);
p.updateInventory();
return;
}
}catch(NullPointerException ignored){}
}
if(e.getSlot() == 45){
//exit button
p.closeInventory();
p.updateInventory();
return;
}
if(e.getSlot() <= 44){
//if panel slots are selected
try{
if(Objects.requireNonNull(e.getCurrentItem()).getType() != Material.AIR){
if(e.getClick().isLeftClick() && !e.getClick().isShiftClick()){
//if left click
int count = 0;
for(String panelName : panelNames){
if(panelName.equals(ChatColor.stripColor(Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName()))){
plugin.openGui(panelName, p, panelYaml.get(count),3,0);
return;
}
count +=1;
}
}else{
//if right click
int count = 0;
for(String panelName : panelNames){
if(panelName.equals(ChatColor.stripColor(Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName()))){
plugin.editorGuis.openPanelSettings(p,panelName,panelYaml.get(count));
return;
}
count +=1;
}
p.updateInventory();
}
}
}catch(NullPointerException ignored){}
}
p.updateInventory();
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
Player p = (Player)e.getWhoClicked();
if(e.getInventory().getType() != InventoryType.CHEST){
return;
}
if(!p.getOpenInventory().getTitle().contains(ChatColor.GRAY + "Editing Panel:")){
return;
}
String panelName = ""; //all panels from ALL files (panel names)
String fileName = ""; //all panels from ALL files (panel names)
YamlConfiguration file = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
boolean found = false;
try {
//neew to loop through files to get file names
for(String fileTempName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
if(!plugin.checkPanels(temp)){
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
panelName = key;
fileName = fileTempName;
file = temp;
found = true;
break;
}
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
if(!found){
return;
}
//this basically just determines if something is dragged.
try {
if (tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) {
if (e.getOldCursor().getType() != Material.matchMaterial(Objects.requireNonNull(tempEdit.getString("panels." + panelName + ".temp." + p.getName() + ".material")))) {
clearTemp(p, panelName);
return;
}
}
}catch(Exception ex){
return;
}
//I cannot use load temp because the Event type is different, also I need to loop through all the items
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName())){
try {
for (int slot : e.getInventorySlots()) {
file.set("panels." + panelName + ".item." + slot, tempEdit.get("panels." + panelName + ".temp." + p.getName()));
//stacks can't be saved to file because it is not accurate in drag drop cases
if(file.contains("panels." + panelName + ".item." + slot + ".stack")){
file.set("panels." + panelName + ".item." + slot + ".stack",null);
}
saveFile(fileName, file, true);
}
}catch(NullPointerException nu){
plugin.debug(nu);
}
}
}
@EventHandler
public void onInventoryEdit(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
if(e.getInventory().getType() != InventoryType.CHEST){
return;
}
if(!p.getOpenInventory().getTitle().contains(ChatColor.GRAY + "Editing Panel:")){
return;
}
String panelName = "";
String fileName = "";
YamlConfiguration file = new YamlConfiguration();
boolean found = false;
try {
//neew to loop through files to get file names
for(String tempName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempName));
String key;
if(!plugin.checkPanels(temp)){
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
panelName = key;
fileName = tempName;
file = temp;
found = true;
break;
}
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
if(!found){
return;
}
//change file below
/*
All item settings will be custom saved and carried over. When inventory is closed, then figure out where items are and allocate the settings to those items...
This is so there is no errors with item amounts and also so settings can be moved around easily
Load temp item if the item is dropped into the panel
Save temp item if the item is picked up from inside the panel
*/
if(e.getClick().isShiftClick() && e.getClickedInventory() == e.getView().getTopInventory()){
if(e.getCurrentItem() == null) {
return;
}
onEditPanelClose(p,e.getInventory(),e.getView());
inventoryItemSettingsOpening.add(p.getName());
//refresh the yaml config
file = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
plugin.editorGuis.openItemSettings(p,panelName,file,e.getSlot());
return;
}
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) {
if(Objects.requireNonNull(e.getCursor()).getType() != Material.PLAYER_HEAD) {
//if the material doesn't match and also isn't a PLAYER_HEAD
if (e.getCursor().getType() != Material.matchMaterial(Objects.requireNonNull(tempEdit.getString("panels." + panelName + ".temp." + p.getName() + ".material")))) {
clearTemp(p, panelName);
}
}
}
if(e.getAction() == InventoryAction.CLONE_STACK){
saveTempItem(e, p, file, panelName);
}else if(e.getAction() == InventoryAction.PLACE_ALL){
loadTempItem(e, p, file, fileName, panelName);
clearTemp(p, panelName);
}else if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR){
//e.setCancelled(true);
saveTempItem(e, p, file, panelName);
}else if(e.getAction() == InventoryAction.DROP_ALL_CURSOR){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.DROP_ALL_SLOT){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.DROP_ONE_CURSOR){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.DROP_ONE_SLOT){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.HOTBAR_SWAP){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.PLACE_SOME){
loadTempItem(e, p, file, fileName, panelName);
}else if(e.getAction() == InventoryAction.SWAP_WITH_CURSOR){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.PICKUP_ALL){
saveTempItem(e, p, file, panelName);
}else if(e.getAction() == InventoryAction.PICKUP_HALF){
saveTempItem(e, p, file, panelName);
}else if(e.getAction() == InventoryAction.PICKUP_ONE){
saveTempItem(e, p, file, panelName);
}else if(e.getAction() == InventoryAction.PICKUP_SOME){
saveTempItem(e, p, file, panelName);
}else if(e.getAction() == InventoryAction.PLACE_ONE){
loadTempItem(e, p, file, fileName, panelName);
}
}
@EventHandler
public void onEditInventoryClose(InventoryCloseEvent e) {
if(inventoryItemSettingsOpening.contains(e.getPlayer().getName())) {
inventoryItemSettingsOpening.remove(e.getPlayer().getName());
return;
}
onEditPanelClose((Player) e.getPlayer(), e.getInventory(), e.getView());
}
@EventHandler
public void onPanelSettings(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
String tag = plugin.config.getString("config.format.tag") + " ";
try {
if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) {
return;
}
}catch(Exception outOf){
//skip as player clicked outside the inventory
return;
}
if(!p.getOpenInventory().getTitle().contains("Panel Settings:")){
return;
}
e.setCancelled(true);
String panelName = ""; //all panels from ALL files (panel names)
boolean found = false;
boolean hotbarItems = false;
try {
//neew to loop through files to get file names
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if(!plugin.checkPanels(temp)){
continue;
}
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
if(e.getView().getTitle().equals("Panel Settings: " + key)){
panelName = key;
if(temp.contains("panels." + panelName + ".open-with-item")){
hotbarItems = true;
}
found = true;
break;
}
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
if(!found){
return;
}
if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.perm"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Permission"));
p.closeInventory();
}
if(e.getSlot() == 3){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.title"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Title"));
p.closeInventory();
}
if(e.getSlot() == 5){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.sound-on-open"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Sound ID"));
p.closeInventory();
}
if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.command"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Command"));
p.closeInventory();
}
if(e.getSlot() == 21){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.delete"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Are you sure? (yes/no)"));
p.closeInventory();
}
if(e.getSlot() == 23){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.rows"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter Row Amount (1 to 6)"));
p.closeInventory();
}
if(e.getSlot() == 13){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.empty"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Material ID"));
p.closeInventory();
}
if(e.getSlot() == 15){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.add"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.remove"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter command line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 11){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.name"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Name"));
p.closeInventory();
}
if(e.getSlot() == 18){
plugin.editorGuis.openEditorGui(p,0);
p.updateInventory();
}
if(e.getSlot() == 40){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.material"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Material"));
p.closeInventory();
}
if(e.getSlot() == 38 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Name"));
p.closeInventory();
}
if(e.getSlot() == 36 && hotbarItems){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.add"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Lore"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 42 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter Location (1 to 9)"));
p.closeInventory();
}
}
@EventHandler
public void onItemSettings(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
String tag = plugin.config.getString("config.format.tag") + " ";
try {
if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) {
return;
}
}catch(Exception outOf){
//skip as player clicked outside the inventory
return;
}
if(!p.getOpenInventory().getTitle().contains("Item Settings:")){
return;
}
e.setCancelled(true);
String panelName = ""; //all panels from ALL files (panel names)
YamlConfiguration panelYaml = null; //all panels from ALL files (panel names)
boolean found = false;
try {
//neew to loop through files to get file names
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if(!plugin.checkPanels(temp)){
continue;
}
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
if(e.getView().getTitle().equals("Item Settings: " + key)){
panelName = key;
panelYaml = temp;
found = true;
break;
}
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
if(!found){
return;
}
int itemSlot;
try {
itemSlot = Integer.parseInt(Objects.requireNonNull(Objects.requireNonNull(e.getView().getTopInventory().getItem(35)).getItemMeta()).getDisplayName().split("\\s")[2]);
}catch(Exception ex){
plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot");
plugin.debug(ex);
return;
}
if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".name"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Name"));
p.closeInventory();
}
if(e.getSlot() == 3){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".commands.add"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".commands.remove"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter command line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 5){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".enchanted"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Enchantment"));
p.closeInventory();
}
if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".potion"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Potion Effect"));
p.closeInventory();
}
if(e.getSlot() == 19){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".lore.add"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Lore"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".lore.remove"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 21){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".stack"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Stack (must be an integer)"));
p.closeInventory();
}
if(e.getSlot() == 23){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".customdata"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Custom Model Data"));
p.closeInventory();
}
if(e.getSlot() == 25){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".leatherarmor"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Leather Armor Colour"));
p.closeInventory();
}
if(e.getSlot() == 35){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".head"});
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Custom Material (eg. cps= self)"));
p.closeInventory();
}
if(e.getSlot() == 27){
plugin.openGui(panelName, p, panelYaml,3,0);
p.updateInventory();
}
}
public void saveTempItem(InventoryClickEvent e, Player p, YamlConfiguration file, String panelName){
//saves item to temp, using getslot
tempEdit.set("panels." + panelName + ".temp." + p.getName(),file.get("panels." + panelName + ".item." + e.getSlot()));
saveFile("temp.yml", tempEdit, false);
}
public void loadTempItem(InventoryClickEvent e, Player p, YamlConfiguration file,String fileName, String panelName){
//loads temp item to the current item
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName())){
file.set("panels." + panelName + ".item." + e.getSlot(),tempEdit.get("panels." + panelName + ".temp." + p.getName()));
saveFile(fileName, file, true);
}
}
public void clearTemp(Player p, String panelName){
//empty temp item
tempEdit.set("panels." + panelName + ".temp." + p.getName(),null);
saveFile("temp.yml", tempEdit, false);
}
public void saveFile(String fileName, YamlConfiguration file, boolean inPanelsFolder){
try {
if(inPanelsFolder){
file.save(new File(plugin.panelsf + File.separator + fileName));
}else{
file.save(new File(plugin.getDataFolder() + File.separator + fileName));
}
} catch (IOException s) {
plugin.debug(s);
}
}
@SuppressWarnings("deprecation")
public void onEditPanelClose(Player p, Inventory inv, InventoryView invView) {
String tag = plugin.config.getString("config.format.tag") + " ";
if(inv.getType() != InventoryType.CHEST){
return;
}
if(!p.getOpenInventory().getTitle().contains(ChatColor.GRAY + "Editing Panel:")){
return;
}
String panelName = ""; //all panels from ALL files (panel names)
String fileName = ""; //all panels from ALL files (panel names)
YamlConfiguration file = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
boolean found = false;
try {
//neew to loop through files to get file names
for(String tempFile : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile));
String key;
if(!plugin.checkPanels(temp)){
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (invView.getTitle().equals(ChatColor.GRAY + "Editing Panel: " + plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
panelName = key;
fileName = tempFile;
file = temp;
found = true;
break;
}
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
if(!found){
return;
}
//save items as they appear
ItemStack cont;
for(int i = 0; inv.getSize() > i; i++){
cont = inv.getItem(i);
//repeat through all the items in the editor
try{
//make the item here
if(cont == null){
//remove if items have been removed
if(file.contains("panels." + panelName + ".item." + i)){
file.set("panels." + panelName + ".item." + i, null);
continue;
}
}
if(file.contains("panels." + panelName + ".item." + i + ".material")){
if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") || Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")){
if(cont.getType() != Material.PLAYER_HEAD){
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
}
}else{
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
}
}else{
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
}
if(cont.getType() == Material.PLAYER_HEAD){
//inject base64 here
if(plugin.getHeadBase64(cont) != null){
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + plugin.getHeadBase64(cont));
}
//check for skull owner
SkullMeta meta = (SkullMeta) cont.getItemMeta();
if(meta.hasOwner()){
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + meta.getOwner());
}
}
if(cont.getAmount() != 1){
file.set("panels." + panelName + ".item." + i + ".stack", cont.getAmount());
}
if(!cont.getEnchantments().isEmpty()){
file.set("panels." + panelName + ".item." + i + ".enchanted", "true");
}
file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore());
}catch(Exception n){
//skip over an item that spits an error
}
}
try {
file.save(new File(plugin.panelsf + File.separator + fileName));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Saved Changes!"));
} catch (IOException s) {
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Could Not Save Changes!"));
plugin.debug(s);
}
plugin.reloadPanelFiles();
}
}

View File

@ -1,17 +0,0 @@
package me.rockyhawk.commandPanels.ioClasses;
//1.13 Imports
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.CharSequenceReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
public class sequence_1_13{
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
//this reads the encrypted resource files in the jar file
byte[] buffer = IOUtils.toByteArray(initialStream);
return new CharSequenceReader(new String(buffer));
}
}

View File

@ -1,17 +0,0 @@
package me.rockyhawk.commandPanels.ioClasses;
//1.14+ Imports
import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils;
import org.bukkit.craftbukkit.libs.org.apache.commons.io.input.CharSequenceReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
public class sequence_1_14{
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
//this reads the encrypted resource files in the jar file
byte[] buffer = IOUtils.toByteArray(initialStream);
return new CharSequenceReader(new String(buffer));
}
}

View File

@ -1,436 +0,0 @@
package me.rockyhawk.commandPanels.openWithItem;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
public class utilsOpenWithItem implements Listener {
commandpanels plugin;
public utilsOpenWithItem(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public void onAnyClick(InventoryClickEvent e) {
//on a click when in any inventory
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
ItemStack clicked = e.getCurrentItem();
Player p = (Player)e.getWhoClicked();
//get the item clicked, then loop through panel names after action isn't nothing
if(e.getAction() == InventoryAction.NOTHING){return;}
if (e.getRawSlot() == -999) {return;}
if (e.getSlotType() != InventoryType.SlotType.QUICKBAR) {return;}
for(String[] panelName : plugin.panelNames){
YamlConfiguration tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1]))));
String tempName = panelName[0];
if(tempFile.contains("panels." + tempName + ".open-with-item") && Objects.requireNonNull(e.getClickedInventory()).getType() == InventoryType.PLAYER) {
try{
assert clicked != null;
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
//cancel the click item event
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
if (e.getSlot() == Integer.parseInt(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.stationary")))) {
e.setCancelled(true);
p.updateInventory();
plugin.openVoids.openCommandPanel(p,p,tempName,tempFile,false);
return;
}
}
return;
}
}
}catch(NullPointerException cancel){
//do nothing skip item
}
}
}
}
@EventHandler
public void onPlayerUse(PlayerInteractEvent e){
//item right clicked only (not left because that causes issues when things are interacted with)
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
try {
if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK || Objects.requireNonNull(e.getItem()).getType() == Material.AIR){
return;
}
if (plugin.panelFiles == null) {
return;
}
}catch(Exception b){
return;
}
ItemStack clicked = e.getItem();
Player p = e.getPlayer();
YamlConfiguration tempFile;
String tempName;
for(String[] panelName : plugin.panelNames){
tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1]))));
tempName = panelName[0];
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
try{
assert clicked != null;
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
//cancel the click item event
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
if (p.getInventory().getHeldItemSlot() != Integer.parseInt(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.stationary")))) {
return;
}
}
e.setCancelled(true);
p.updateInventory();
plugin.openVoids.openCommandPanel(p,p,tempName,tempFile,false);
return;
}
}
}catch(NullPointerException cancel){
//do nothing skip item
}
}
}
}
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent e){
/*
This world change event is added so if the player is using disabled-worlds
and they change worlds, it will check if the player can have the item
and if they can, it gives the item. This is because onRespawn doesn't
give the item to the player in all the worlds that it could automatically.
The player will of course need a plugin to split inventories between worlds
for this to take effect. I don't want to delete the item on the wrong world
because then it might overwrite one of their actual slots upon rejoining the enabled world.
*/
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
Player p = e.getPlayer();
try {
if (plugin.panelFiles == null) {
return;
}
}catch(Exception b){
return;
}
String tpanels; //tpanels is the temp to check through the files
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if(temp.contains("panels." + key + ".disabled-worlds")){
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
assert disabledWorlds != null;
if(disabledWorlds.contains(p.getWorld().getName())){
continue;
}
}
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
if(temp.contains("panels." + key + ".open-with-item.stationary")) {
if (0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), s);
}
}
}
}
}
}
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent e){
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
Player p = e.getPlayer();
try {
if (plugin.panelFiles == null) {
return;
}
}catch(Exception b){
return;
}
String tpanels; //tpanels is the temp to check through the files
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if(temp.contains("panels." + key + ".disabled-worlds")){
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
assert disabledWorlds != null;
if(disabledWorlds.contains(p.getWorld().getName())){
continue;
}
}
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), s);
}
}
}
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
Player p = e.getEntity();
try {
if (plugin.panelFiles == null) {
return;
}
}catch(Exception b){
return;
}
String tpanels; //tpanels is the temp to check through the files
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
if(temp.contains("panels." + key + ".open-with-item.stationary")){
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
e.getDrops().remove(s);
}
}
}
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e){
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
Player p = e.getPlayer();
try {
if (plugin.panelFiles == null) {
return;
}
}catch(Exception b){
return;
}
String tpanels; //tpanels is the temp to check through the files
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
if(temp.contains("panels." + key + ".disabled-worlds")){
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
if(disabledWorlds.contains(p.getWorld().getName())){
continue;
}
}
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), s);
}
}else{
//if the player has an item that they have no permission for, remove it
ItemStack s;
try {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1);
}catch(Exception n){
continue;
}
plugin.setName(s, temp.getString("panels." + key + ".open-with-item.name"), temp.getStringList("panels." + key + ".open-with-item.lore"),p,true, true);
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
try {
if (Objects.requireNonNull(p.getInventory().getItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))))).isSimilar(s)) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), null);
}
}catch(NullPointerException nex){
//skip as player has no item in slot
}
}
}
}
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e){
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
//if item dropped
Player p = e.getPlayer();
try {
if (plugin.panelFiles == null) {
return;
}
}catch(Exception b){
return;
}
ItemStack clicked = e.getItemDrop().getItemStack();
for(String[] panelName : plugin.panelNames){
YamlConfiguration tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1]))));
String tempName = panelName[0];
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
try{
assert clicked != null;
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
//cancel the click item event
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
e.setCancelled(true);
p.updateInventory();
return;
}
return;
}
}
}catch(NullPointerException cancel){
//do nothing skip item
}
}
}
}
@EventHandler
public void onPlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent e){
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
Player p = e.getPlayer();
try {
if (plugin.panelFiles == null) {
return;
}
}catch(Exception b){
return;
}
YamlConfiguration cf; //this is the file to use for any panel.* requests
String tpanels; //tpanels is the temp to check through the files
ItemStack clicked = e.getOffHandItem();
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if(temp.contains("panels." + key + ".open-with-item")){
assert clicked != null;
if(clicked.getType() != Material.AIR) {
//if loop has material first to stop 1.12.2 from spitting errors
//try and catch loop to stop errors with the same material type but different name
try {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.name")))))) {
//cancel the click item event
if(temp.contains("panels." + key + ".open-with-item.stationary")){
if(p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
e.setCancelled(true);
}
}
return;
}
}
}catch(NullPointerException | IllegalArgumentException n){
plugin.debug(n);
}
}
}
}
}
}
@EventHandler
public void onInteractEntity(PlayerInteractEntityEvent e){
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;
}
//cancel everything if holding item (item frames eg)
Player p = (Player)e.getPlayer();
try {
if (plugin.panelFiles == null) {
return;
}
}catch(Exception b){
return;
}
YamlConfiguration cf; //this is the file to use for any panel.* requests
String tpanels; //tpanels is the temp to check through the files
ItemStack clicked = e.getPlayer().getInventory().getItemInMainHand();
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if (temp.contains("panels." + key + ".open-with-item")) {
if (clicked.getType() != Material.AIR) {
//if loop has material first to stop 1.12.2 from spitting errors
//try and catch loop to stop errors with the same material type but different name
try {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.name")))))) {
//cancel the click item event
if (temp.contains("panels." + key + ".open-with-item.stationary")) {
if (p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))) {
e.setCancelled(true);
}
}
return;
}
}
} catch (NullPointerException | IllegalArgumentException n) {
plugin.debug(n);
}
}
}
}
}
}
}

View File

@ -1,79 +0,0 @@
package me.rockyhawk.commandPanels.panelBlocks;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
public class blocksTabComplete implements TabCompleter {
commandpanels plugin;
public blocksTabComplete(commandpanels pl) { this.plugin = pl; }
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player){
Player p = ((Player) sender).getPlayer();
if(label.equalsIgnoreCase("cpb") || label.equalsIgnoreCase("cpanelb") || label.equalsIgnoreCase("commandpanelblock")){
if(args.length == 2) {
if(args[0].equals("add") && p.hasPermission("commandpanel.block.add")) {
ArrayList<String> apanels = new ArrayList<String>(); //all panels
String tpanels; //tpanels is the temp to check through the files
try {
for (String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if (!plugin.checkPanels(temp)) {
continue;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if (!key.startsWith(args[1])) {
//this will narrow down the panels to what the user types
continue;
}
if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
if (temp.contains("panels." + key + ".disabled-worlds")) {
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
if (!disabledWorlds.contains(p.getWorld().getName())) {
apanels.add(key);
}
} else {
apanels.add(key);
}
}
}
//if file contains opened panel then start
}
} catch (Exception fail) {
//could not fetch all panel names (probably no panels exist)
}
return apanels;
}
}
if(args.length == 1){
ArrayList<String> output = new ArrayList<String>();
if (sender.hasPermission("commandpanel.block.add")){
output.add("add");
}
if (sender.hasPermission("commandpanel.block.remove")){
output.add("remove");
}
if (sender.hasPermission("commandpanel.block.list")){
output.add("list");
}
return output;
}
}
}
return null;
}
}

View File

@ -1,56 +0,0 @@
package me.rockyhawk.commandPanels.panelBlocks;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import java.io.File;
import java.util.Objects;
public class panelBlockOnClick implements Listener {
commandpanels plugin;
public panelBlockOnClick(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public void onInteract(PlayerInteractEvent e){
String tag = plugin.config.getString("config.format.tag") + " ";
//if panel blocks are disabled return
if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){
return;
}
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block block = e.getClickedBlock();
Player p = e.getPlayer();
assert block != null;
if(plugin.blockConfig.contains("blocks")){
if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){
return;
}
for (String configLocation : Objects.requireNonNull(plugin.blockConfig.getConfigurationSection("blocks")).getKeys(false)) {
String[] loc = configLocation.split("_");
Location tempLocation = new Location(plugin.getServer().getWorld(loc[0]),Double.parseDouble(loc[1]),Double.parseDouble(loc[2]),Double.parseDouble(loc[3]));
if(tempLocation.equals(block.getLocation())){
e.setCancelled(true);
YamlConfiguration cf = null;
String panelName = "";
for(String[] temp : plugin.panelNames){
if(temp[0].equals(plugin.blockConfig.getString("blocks." + configLocation + ".panel"))){
panelName = temp[0];
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(temp[1]))));
}
}
plugin.openVoids.openCommandPanel(p,p,panelName,cf,false);
return;
}
}
}
}
}
}

View File

@ -1,44 +0,0 @@
package me.rockyhawk.commandPanels.premium;
import me.rockyhawk.commandPanels.ClassResources.CommandTags;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.Objects;
public class commandpanelUserInput implements Listener {
commandpanels plugin;
public commandpanelUserInput(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent e) {
for(int o = 0; plugin.userInputStrings.size() > o; o++){
if(plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())){
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
e.setCancelled(true);
e.getPlayer().sendMessage(plugin.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
for(int i = 0; plugin.userInputStrings.size() > i; i++){
if(plugin.userInputStrings.get(i)[0].equals(e.getPlayer().getName())){
plugin.userInputStrings.remove(i);
//this is here because if one command is removed, i cannot increase by one
i=i-1;
}
}
return;
}
String command = plugin.userInputStrings.get(o)[1].replaceAll("%cp-player-input%", e.getMessage());
plugin.userInputStrings.remove(o);
o=o-1;
e.setCancelled(true);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
new CommandTags(plugin).commandTags(e.getPlayer(), command); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
}
}
}
}

View File

@ -1,175 +0,0 @@
package me.rockyhawk.commandPanels.premium;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.*;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.Objects;
public class commandpanelrefresher implements Listener {
commandpanels plugin;
public commandpanelrefresher(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e){ //Handles when Players open inventory
//I have to convert HumanEntity to a player
if (plugin.config.contains("config.refresh-panels")) {
if (Objects.requireNonNull(plugin.config.getString("config.refresh-panels")).trim().equalsIgnoreCase("false")) {
return;
}
}
HumanEntity h = e.getPlayer();
Player p;
if (h instanceof Player) {
p = Bukkit.getPlayer(h.getName());
}else{
return;
}
//get all panel names (not titles)
YamlConfiguration cf = null;
String panel = null;
String panelTitle = null;
try {
boolean foundPanel = false;
for (String fileName : plugin.panelFiles) { //will loop through all the files in folder
String key;
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if (!plugin.checkPanels(temp)) {
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))).equals(e.getView().getTitle())) {
panel = key;
panelTitle = plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title")));
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
foundPanel = true;
break;
}
}
if (foundPanel) {
//this is to avoid the plugin to continue looking when it was already found
break;
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
}
if(panel == null){
return;
}
//there is already a runnable running for this player
assert p != null;
if(plugin.panelRunning.contains(p.getName() + ";" + panel)){
return;
}
plugin.panelRunning.add(p.getName() + ";" + panel);
if (plugin.config.contains("config.panel-snooper")) {
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Opened " + panel);
}
}
if(cf.contains("panels." + panel + ".panelType")) {
if (cf.getString("panels." + panel + ".panelType").equalsIgnoreCase("temporary")) {
//do not update temporary panels, only default panels
return;
}
}
final YamlConfiguration cfFinal = cf;
final String fpanel = panel;
final String fpanelTitle = panelTitle;
ItemStack[] panelItemList = plugin.openGui(fpanel, p, cf,2, -1).getContents();
ItemStack[] playerItemList = p.getInventory().getStorageContents();
new BukkitRunnable(){
int c = 0;
int animatecount = 0;
@Override
public void run() {
int animatevalue = -1;
if(cfFinal.contains("panels." + fpanel + ".animatevalue")){
animatevalue = cfFinal.getInt("panels." + fpanel + ".animatevalue");
}
//counter counts to refresh delay (in seconds) then restarts
if(c < Double.parseDouble(Objects.requireNonNull(plugin.config.getString("config.refresh-delay")).trim())){
c+=1;
}else{
c=0;
}
//refresh here
if(p.getOpenInventory().getTitle().equals(fpanelTitle)){
if(c == 0) {
//animation counter
if(animatevalue != -1) {
if (animatecount < animatevalue) {
animatecount += 1;
} else {
animatecount = 0;
}
}
try {
plugin.openGui(fpanel, p, cfFinal, 0,animatecount);
} catch (Exception e) {
//error opening gui
}
}
}else{
if(Objects.requireNonNull(plugin.config.getString("config.stop-sound")).trim().equalsIgnoreCase("true")){
try {
p.stopSound(Sound.valueOf(Objects.requireNonNull(cfFinal.getString("panels." + fpanel + ".sound-on-open")).toUpperCase()));
}catch(Exception sou){
//skip
}
}
c = 0;
//check to ensure players haven't duplicated items
try {
p.updateInventory();
for (ItemStack playerContent : p.getInventory().getStorageContents()) {
for (ItemStack panelContent : panelItemList) {
if (playerContent != null && panelContent != null) {
if (!playerContent.getType().equals(Material.matchMaterial("AIR")) && !panelContent.getType().equals(Material.matchMaterial("AIR"))) {
if (playerContent.equals(panelContent)) {
boolean isOriginal = false;
for (ItemStack playerOriginalContent : playerItemList) {
if (playerOriginalContent != null && !playerOriginalContent.getType().equals(Material.matchMaterial("AIR"))) {
if (playerContent.equals(playerOriginalContent)) {
isOriginal = true;
}
}
}
if(!isOriginal) {
p.getInventory().removeItem(playerContent);
}
}
}
}
}
}
}catch(Exception e){
//oof
}
this.cancel();
if(p.getOpenInventory().getTitle().equals(fpanelTitle)) {
p.closeInventory();
}
plugin.panelRunning.remove(p.getName() + ";" + fpanel);
if (plugin.config.contains("config.panel-snooper")) {
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Closed " + fpanel);
}
}
}
}
}.runTaskTimer(this.plugin, 5, 5); //20 ticks == 1 second (5 ticks = 0.25 of a second)
}
}

View File

@ -1,225 +0,0 @@
package me.rockyhawk.commandPanels;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.*;
public class utils implements Listener {
commandpanels plugin;
public utils(commandpanels pl) {
this.plugin = pl;
}
@EventHandler
public void onPanelClick(InventoryClickEvent e) {
//when clicked on a panel
String tag = plugin.config.getString("config.format.tag") + " ";
Player p = (Player)e.getWhoClicked();
ItemStack clicked = e.getCurrentItem();
try {
if(e.getView().getType() != InventoryType.CHEST){
//if it isn't a chest interface
return;
}
if(ChatColor.stripColor(e.getView().getTitle()).equals("Chest") || ChatColor.stripColor(e.getView().getTitle()).equals("Large Chest") || ChatColor.stripColor(e.getView().getTitle()).equals("Trapped Chest")){
//if the inventory is just a chest that has no panel
return;
}
if (plugin.panelFiles == null) {
//if no panels are present
return;
}
if(clicked == null){
//if itemstack is null
return;
}
}catch(Exception b){
return;
}
YamlConfiguration cf = null; //this is the file to use for any panel.* requests
String panel = null;
boolean foundPanel = false;
for (String filename : plugin.panelFiles) { //will loop through all the files in folder
String key;
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
if (!plugin.checkPanels(temp)) {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": Syntax error Found or Missing certain element!"));
return;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))).equals(e.getView().getTitle())) {
panel = key;
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
foundPanel = true;
break;
}
}
if (foundPanel) {
//this is to avoid the plugin to continue looking when it was already found
break;
}
}
if(panel == null){
return;
}
if(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(cf.getString("panels." + panel + ".title")))).equals("Command Panels Editor")){
//cancel if it is the editor (this should never happen unless the user made a panel called Command Panels Editor for some reason)
return;
}
if(e.getSlotType().equals(InventoryType.SlotType.CONTAINER) && e.getRawSlot() <= Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panel + ".rows")))*9-1){
e.setCancelled(true);
p.updateInventory();
//this loops through all the items in the panel
boolean foundSlot = false;
for(String slot : Objects.requireNonNull(cf.getConfigurationSection("panels." + panel + ".item")).getKeys(false)){
if(slot.equals(Integer.toString(e.getSlot()))){
foundSlot = true;
}
}
if(!foundSlot){
return;
}
//loop through possible hasvalue/hasperm 1,2,3,etc
String section = plugin.itemCreate.hasSection(cf.getConfigurationSection("panels." + panel + ".item." + e.getSlot()), p);
//this will remove any pending user inputs, if there is already something there from a previous item
for(int o = 0; plugin.userInputStrings.size() > o; o++){
if(plugin.userInputStrings.get(o)[0].equals(p.getName())){
plugin.userInputStrings.remove(o);
o=o-1;
}
}
redirectPanel(p,cf,panel,section,e.getSlot());
if(cf.contains("panels." + panel + ".item." + e.getSlot() + section + ".commands")) {
List<String> commands = cf.getStringList("panels." + panel + ".item." + e.getSlot() + section + ".commands");
if (commands.size() != 0) {
//this will replace a sequence tag command with the commands from the sequence
List<String> commandsAfterSequence = commands;
for (int i = 0; commands.size() - 1 >= i; i++) {
if(commands.get(i).startsWith("sequence=")){
String locationOfSequence = commands.get(i).split("\\s")[1];
List<String> commandsSequence = cf.getStringList(locationOfSequence);
commandsAfterSequence.remove(i);
commandsAfterSequence.addAll(i,commandsSequence);
}
}
commands = commandsAfterSequence;
for (int i = 0; commands.size() - 1 >= i; i++) {
try {
if (commands.get(i).split("\\s")[0].equalsIgnoreCase("right=")) {
//if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("right=", "").trim());
commands.set(i, commands.get(i).replace("RIGHT=", "").trim());
if (e.isLeftClick() || (e.isShiftClick() && e.isLeftClick()) || (e.isShiftClick() && e.isRightClick())) {
continue;
}
} else if (commands.get(i).split("\\s")[0].equalsIgnoreCase("rightshift=")) {
//if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("rightshift=", "").trim());
commands.set(i, commands.get(i).replace("RIGHTSHIFT=", "").trim());
if (e.isLeftClick() || (!e.isShiftClick() && e.isRightClick())) {
continue;
}
}
if (commands.get(i).split("\\s")[0].equalsIgnoreCase("left=")) {
//if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("left=", "").trim());
commands.set(i, commands.get(i).replace("LEFT=", "").trim());
if (e.isRightClick() || (e.isShiftClick() && e.isRightClick()) || (e.isShiftClick() && e.isLeftClick())) {
continue;
}
} else if (commands.get(i).split("\\s")[0].equalsIgnoreCase("leftshift=")) {
//if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("leftshift=", "").trim());
commands.set(i, commands.get(i).replace("LEFTSHIFT=", "").trim());
if (e.isRightClick() || (!e.isShiftClick() && e.isLeftClick())) {
continue;
}
}
if (!e.isLeftClick() && !e.isRightClick()) {
continue;
}
} catch (Exception click) {
//skip if you can't do this
}
try {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", clicked.getType().toString()));
} catch (Exception mate) {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", "Air"));
}
//end custom PlaceHolders
int val = plugin.commandTags.commandPayWall(p,commands.get(i));
if(val == 0){
return;
}
if(val == 2){
plugin.commandTags.commandTags(p, commands.get(i));
}
}
}
}
}
//stop duplicate
p.updateInventory();
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e){
Player p = e.getPlayer();
if(p.isOp() || p.hasPermission("*.*")){
if(plugin.update) {
p.sendMessage(ChatColor.WHITE + "CommandPanels " + ChatColor.DARK_RED + "is not running the latest version! A new version is available at");
p.sendMessage(ChatColor.RED + "https://www.spigotmc.org/resources/command-panels-custom-guis.67788/");
}
}
}
public void redirectPanel(Player p, YamlConfiguration cf, String panel, String section, int slot){
String tag = plugin.config.getString("config.format.tag") + " ";
if(!cf.contains("panels." + panel + ".item." + slot + section + ".redirect") || !cf.contains("panels." + panel + ".item." + slot + section + ".redirect.panel")) {
return;
}
String panelName = cf.getString("panels." + panel + ".item." + slot + section + ".redirect.panel");
YamlConfiguration panelConfig = null;
for(String[] tempName : plugin.panelNames){
if(tempName[0].equals(panelName)){
panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1]))));
break;
}
}
if(panelConfig == null){
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return;
}
boolean forced = false;
if(cf.contains("panels." + panel + ".item." + slot + section + ".redirect.force")){
//this will force the panel open without consideration of permissions, world, etc
if(cf.getBoolean("panels." + panel + ".item." + slot + section + ".redirect.force")){
forced = true;
}
}
if(cf.contains("panels." + panel + ".item." + slot + section + ".redirect.replacements")){
if(!panelConfig.getString("panels." + panelName + ".panelType").equalsIgnoreCase("temporary") && plugin.config.getBoolean("config.refresh-panels")){
p.sendMessage(plugin.papi(tag + ChatColor.RED + panelName + " panel type needs to be temporary to replace elements."));
}
for(String sectionName : cf.getConfigurationSection("panels." + panel + ".item." + slot + section + ".redirect.replacements").getKeys(false)){
ConfigurationSection temp = cf.getConfigurationSection("panels." + panel + ".item." + slot + section + ".redirect.replacements." + sectionName);
panelConfig.set("panels." + panelName + ".item." + sectionName, temp);
}
}
if(forced){
plugin.openGui(panelName, p, panelConfig, 1, 0);
}else{
plugin.openVoids.openCommandPanel(p, p, panelName, panelConfig, false);
}
}
}

View File

@ -0,0 +1,600 @@
package me.rockyhawk.commandpanels;
import com.google.common.collect.ImmutableMultimap;
import io.lumine.mythic.lib.api.item.NBTItem;
import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.classresources.ExecuteOpenVoids;
import me.rockyhawk.commandpanels.classresources.MiniMessageUtils;
import me.rockyhawk.commandpanels.classresources.customheads.GetCustomHeads;
import me.rockyhawk.commandpanels.classresources.HasSections;
import me.rockyhawk.commandpanels.classresources.ItemCreation;
import me.rockyhawk.commandpanels.classresources.placeholders.expansion.CpPlaceholderExpansion;
import me.rockyhawk.commandpanels.completetabs.DataTabComplete;
import me.rockyhawk.commandpanels.completetabs.ImportTabComplete;
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
import me.rockyhawk.commandpanels.classresources.placeholders.CreateText;
import me.rockyhawk.commandpanels.classresources.placeholders.HexColours;
import me.rockyhawk.commandpanels.classresources.placeholders.Placeholders;
import me.rockyhawk.commandpanels.commands.*;
import me.rockyhawk.commandpanels.commandtags.CommandRunner;
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
import me.rockyhawk.commandpanels.completetabs.UpdateTabComplete;
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
import me.rockyhawk.commandpanels.datamanager.DebugManager;
import me.rockyhawk.commandpanels.datamanager.PanelDataLoader;
import me.rockyhawk.commandpanels.datamanager.PanelDataPlayerManager;
import me.rockyhawk.commandpanels.editor.*;
import me.rockyhawk.commandpanels.floodgatecp.OpenFloodgateGUI;
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
import me.rockyhawk.commandpanels.generatepanels.GenUtils;
import me.rockyhawk.commandpanels.generatepanels.TabCompleteGenerate;
import me.rockyhawk.commandpanels.interactives.OutsideClickEvent;
import me.rockyhawk.commandpanels.interactives.input.UserInputUtils;
import me.rockyhawk.commandpanels.interactives.Commandpanelrefresher;
import me.rockyhawk.commandpanels.interactives.OpenOnJoin;
import me.rockyhawk.commandpanels.ioclasses.nbt.NBTManager;
import me.rockyhawk.commandpanels.ioclasses.legacy.LegacyVersion;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.ioclasses.legacy.PlayerHeads;
import me.rockyhawk.commandpanels.ioclasses.potions.ClassicPotionData;
import me.rockyhawk.commandpanels.ioclasses.potions.LegacyPotionData;
import me.rockyhawk.commandpanels.openpanelsmanager.*;
import me.rockyhawk.commandpanels.openwithitem.HotbarItemLoader;
import me.rockyhawk.commandpanels.openwithitem.SwapItemEvent;
import me.rockyhawk.commandpanels.openwithitem.UtilsChestSortEvent;
import me.rockyhawk.commandpanels.openwithitem.UtilsOpenWithItem;
import me.rockyhawk.commandpanels.panelblocks.BlocksTabComplete;
import me.rockyhawk.commandpanels.panelblocks.Commandpanelblocks;
import me.rockyhawk.commandpanels.panelblocks.PanelBlockOnClick;
import me.rockyhawk.commandpanels.playerinventoryhandler.InventorySaver;
import me.rockyhawk.commandpanels.playerinventoryhandler.ItemStackSerializer;
import me.rockyhawk.commandpanels.playerinventoryhandler.pickupevent.EntityPickupEvent;
import me.rockyhawk.commandpanels.playerinventoryhandler.pickupevent.legacyPlayerEvent;
import me.rockyhawk.commandpanels.updater.Updater;
import net.milkbowl.vault.economy.Economy;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.CharSequenceReader;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.*;
public class CommandPanels extends JavaPlugin{
public YamlConfiguration config;
public Economy econ = null;
public boolean openWithItem = false; //this will be true if there is a panel with open-with-item
//initialise the tag
public String tag = "[CommandPanels]";
public List<Player> generateMode = new ArrayList<>(); //players that are currently in generate mode
public List<Panel> panelList = new ArrayList<>(); //contains all the panels that are included in the panels folder
//get alternate classes
public PanelDownloader downloader = new PanelDownloader(this);
public CommandRunner commandRunner = new CommandRunner(this);
public PanelDataLoader panelData = new PanelDataLoader(this);
public PanelDataPlayerManager panelDataPlayers = new PanelDataPlayerManager(this);
public Placeholders placeholders = new Placeholders(this);
public DebugManager debug = new DebugManager(this);
public CreateText tex = new CreateText(this);
public HexColours hex = new HexColours(this);
public MiniMessageUtils miniMessage = null;
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
public ItemCreation itemCreate = new ItemCreation(this);
public HasSections has = new HasSections(this);
public GetCustomHeads customHeads = new GetCustomHeads(this);
public Updater updater = new Updater(this);
public PlayerHeads getHeads = new PlayerHeads(this);
public ClassicPotionData classicPotion = new ClassicPotionData(this);
public LegacyPotionData legacyPotion = new LegacyPotionData(this);
public LegacyVersion legacy = new LegacyVersion(this);
public OpenPanelsLoader openPanels = new OpenPanelsLoader(this);
public OpenGUI createGUI = new OpenGUI(this);
public PanelPermissions panelPerms = new PanelPermissions(this);
public HotbarItemLoader hotbar = new HotbarItemLoader(this);
public NBTManager nbt = new NBTManager(this);
public InventorySaver inventorySaver = new InventorySaver(this);
public ItemStackSerializer itemSerializer = new ItemStackSerializer(this);
public UserInputUtils inputUtils = new UserInputUtils(this);
public File panelsf = new File(this.getDataFolder() + File.separator + "panels");
public YamlConfiguration blockConfig; //where panel block locations are stored
public void onEnable() {
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loading...");
//Initialise classes that are not used externally
new OpenFloodgateGUI(this);
//register config files
this.blockConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "blocks.yml"));
panelData.dataConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "data.yml"));
inventorySaver.inventoryConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "inventories.yml"));
this.config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + File.separator + "config.yml"));
//save the config.yml file
File configFile = new File(this.getDataFolder() + File.separator + "config.yml");
if (!configFile.exists()) {
//generate a new config file from internal resources
try {
FileConfiguration configFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("config.yml")));
configFileConfiguration.save(configFile);
this.config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + File.separator + "config.yml"));
} catch (IOException var11) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not save the config file!");
}
}else{
//check if the config file has any missing elements
try {
YamlConfiguration configFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("config.yml")));
this.config.addDefaults(configFileConfiguration);
this.config.options().copyDefaults(true);
this.config.save(new File(this.getDataFolder() + File.separator + "config.yml"));
} catch (IOException var10) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not save the config file!");
}
}
//set version to latest version
if (Objects.requireNonNull(this.config.getString("updater.update-checks")).equalsIgnoreCase("true")) {
updater.githubNewUpdate(true);
}
//setup class files
new Metrics(this, 5097);
this.setupEconomy();
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "my:psb");
Objects.requireNonNull(this.getCommand("commandpanel")).setExecutor(new Commandpanel(this));
Objects.requireNonNull(this.getCommand("commandpanel")).setTabCompleter(new CpTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpanelgenerate")).setTabCompleter(new TabCompleteGenerate(this));
Objects.requireNonNull(this.getCommand("commandpanelgenerate")).setExecutor(new Commandpanelsgenerate(this));
Objects.requireNonNull(this.getCommand("commandpaneldata")).setTabCompleter(new DataTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpaneldata")).setExecutor(new Commandpanelsdata(this));
Objects.requireNonNull(this.getCommand("commandpanelupdate")).setTabCompleter(new UpdateTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpanelupdate")).setExecutor(new Commandpanelsupdate(this));
Objects.requireNonNull(this.getCommand("commandpanelimport")).setExecutor(new CommandPanelImport(this));
Objects.requireNonNull(this.getCommand("commandpanelimport")).setTabCompleter(new ImportTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setExecutor(new CommandPanelsEditor(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setTabCompleter(new EditorTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpanelreload")).setExecutor(new Commandpanelsreload(this));
Objects.requireNonNull(this.getCommand("commandpaneldebug")).setExecutor(new Commandpanelsdebug(this));
Objects.requireNonNull(this.getCommand("commandpanelversion")).setExecutor(new Commandpanelversion(this));
Objects.requireNonNull(this.getCommand("commandpanellist")).setExecutor(new Commandpanelslist(this));
this.getServer().getPluginManager().registerEvents(new Utils(this), this);
this.getServer().getPluginManager().registerEvents(inventorySaver, this);
if(this.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_12)){
this.getServer().getPluginManager().registerEvents(new EntityPickupEvent(this), this);
}else{
this.getServer().getPluginManager().registerEvents(new legacyPlayerEvent(this), this);
}
try {
// Check all the minimessage classes exist before loading
Class.forName("net.kyori.adventure.text.Component");
Class.forName("net.kyori.adventure.text.format.TextDecoration");
Class.forName("net.kyori.adventure.text.minimessage.MiniMessage");
Class.forName("net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer");
miniMessage = new MiniMessageUtils(this);
} catch (ClassNotFoundException ignore) {
//do not initialise miniMessage
}
this.getServer().getPluginManager().registerEvents(inputUtils, this);
this.getServer().getPluginManager().registerEvents(panelDataPlayers, this);
this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this);
this.getServer().getPluginManager().registerEvents(new GenUtils(this), this);
this.getServer().getPluginManager().registerEvents(new ItemFallManager(this), this);
this.getServer().getPluginManager().registerEvents(new OpenOnJoin(this), this);
this.getServer().getPluginManager().registerEvents(new OutsideClickEvent(this), this);
if (this.getServer().getPluginManager().isPluginEnabled("floodgate")) {
this.getServer().getPluginManager().registerEvents(new OpenFloodgateGUI(this), this);
}
//load in the updater if requested
if (Objects.requireNonNull(config.getString("updater.update-checks")).equalsIgnoreCase("true")) {
this.getServer().getPluginManager().registerEvents(updater, this);
}
//load in PlaceholderAPI Expansion
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new CpPlaceholderExpansion(this).register();
}
//load in all built in command tags
commandRunner.registerBuiltInTags();
//if refresh-panels set to false, don't load this
if(Objects.requireNonNull(config.getString("config.refresh-panels")).equalsIgnoreCase("true")){
this.getServer().getPluginManager().registerEvents(new Commandpanelrefresher(this), this);
}
//if custom-commands set to false, don't load this
if(Objects.requireNonNull(config.getString("config.custom-commands")).equalsIgnoreCase("true")){
this.getServer().getPluginManager().registerEvents(new Commandpanelcustom(this), this);
}
//if hotbar-items set to false, don't load this
if(Objects.requireNonNull(config.getString("config.hotbar-items")).equalsIgnoreCase("true")){
this.getServer().getPluginManager().registerEvents(new UtilsOpenWithItem(this), this);
}
//if panel-blocks set to false, don't load this
if(Objects.requireNonNull(config.getString("config.panel-blocks")).equalsIgnoreCase("true")){
Objects.requireNonNull(this.getCommand("commandpanelblock")).setExecutor(new Commandpanelblocks(this));
Objects.requireNonNull(this.getCommand("commandpanelblock")).setTabCompleter(new BlocksTabComplete(this));
this.getServer().getPluginManager().registerEvents(new PanelBlockOnClick(this), this);
}
//if 1.8 don't use this
if (!Bukkit.getVersion().contains("1.8")) {
this.getServer().getPluginManager().registerEvents(new SwapItemEvent(this), this);
}
//if plugin ChestSort is enabled
if(getServer().getPluginManager().isPluginEnabled("ChestSort")){
this.getServer().getPluginManager().registerEvents(new UtilsChestSortEvent(this), this);
}
//save the example_top.yml file and the template.yml file
if (!this.panelsf.exists()) {
try {
if(legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("exampleLegacy.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example.yml"));
}else {
//top
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_top.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_top.yml"));
//middle one
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_one.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_one.yml"));
//middle two
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_two.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_two.yml"));
//bottom
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_bottom.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_bottom.yml"));
}
FileConfiguration templateFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("template.yml")));
templateFileConfiguration.save(new File(this.panelsf + File.separator + "template.yml"));
} catch (IOException var11) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not save the example file!");
}
}
//load panelFiles
reloadPanelFiles();
//do hotbar items
hotbar.reloadHotbarSlots();
//load all known players for data
panelDataPlayers.reloadAllPlayers();
//add custom charts bStats
Metrics metrics = new Metrics(this, 5097);
metrics.addCustomChart(new SingleLineChart("panels_amount", () -> {
//this is the total panels loaded
return panelList.size();
}));
//get tag
tag = tex.colour(config.getString("config.format.tag"));
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loaded!");
}
public void onDisable() {
//close all the panels
for(String name : openPanels.openPanels.keySet()){
openPanels.closePanelForLoader(name, PanelPosition.Top);
try {
Bukkit.getPlayer(name).closeInventory();
}catch (Exception ignore){}
}
//save files
panelData.saveDataFile();
inventorySaver.saveInventoryFile();
updater.autoUpdatePlugin(this.getFile().getName());
Bukkit.getLogger().info("RockyHawk's CommandPanels Plugin Disabled, aww man.");
}
public static CommandPanelsAPI getAPI(){
return new CommandPanelsAPI(JavaPlugin.getPlugin(CommandPanels.class));
}
public ItemStack setName(Panel panel, ItemStack renamed, String customName, List<String> lore, Player p, Boolean usePlaceholders, Boolean useColours, Boolean hideAttributes) {
try {
ItemMeta renamedMeta = renamed.getItemMeta();
//set cp placeholders
if(usePlaceholders){
customName = tex.placeholdersNoColour(panel,PanelPosition.Top,p,customName);
}
if(useColours){
customName = tex.colour(customName);
}
assert renamedMeta != null;
//hiding attributes will add an NBT tag
if(hideAttributes) {
renamedMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
renamedMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
//HIDE_ADDITIONAL_TOOLTIP was added into 1.20.5 api
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_21) ||
(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && legacy.MINOR_VERSION >= 5)){
renamedMeta.addItemFlags(ItemFlag.valueOf("HIDE_ADDITIONAL_TOOLTIP"));
}
//HIDE_POTION_EFFECTS was removed in the 1.20.5 api
if(legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && legacy.MINOR_VERSION <= 4)){
renamedMeta.addItemFlags(ItemFlag.valueOf("HIDE_POTION_EFFECTS"));
}
//HIDE_ARMOR_TRIM was added into 1.20 api
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20)){
renamedMeta.addItemFlags(ItemFlag.HIDE_ARMOR_TRIM);
}
//HIDE_DYE was added into 1.17 api
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_17)){
renamedMeta.addItemFlags(ItemFlag.HIDE_DYE);
}
//setAttributeModifiers was added into 1.14 api
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_14)){
renamedMeta.setAttributeModifiers(ImmutableMultimap.of());
}
}
if (customName != null) {
renamedMeta.setDisplayName(customName);
}
List<String> re_lore;
if (lore != null) {
if(usePlaceholders && useColours){
re_lore = tex.placeholdersList(panel,PanelPosition.Top, p, lore, true);
}else if(usePlaceholders){
re_lore = tex.placeholdersNoColour(panel,PanelPosition.Top,p, lore);
}else if(useColours){
re_lore = tex.placeholdersList(panel,PanelPosition.Top, p, lore, false);
}else{
re_lore = lore;
}
renamedMeta.setLore(splitListWithEscape(re_lore));
}
renamed.setItemMeta(renamedMeta);
} catch (Exception ignored) {}
return renamed;
}
private void setupEconomy() {
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
} else {
RegisteredServiceProvider<Economy> rsp = this.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
} else {
this.econ = (Economy) rsp.getProvider();
}
}
}
public boolean checkPanels(YamlConfiguration temp) {
try {
return temp.contains("panels");
} catch (Exception var3) {
return false;
}
}
//check for duplicate panel names
public boolean checkDuplicatePanel(CommandSender sender){
List<String> apanels = new ArrayList<>();
for(Panel panel : panelList){
apanels.add(panel.getName());
}
//names is a list of the titles for the Panels
Set<String> oset = new HashSet<>(apanels);
if (oset.size() < apanels.size()) {
//there are duplicate panel names
ArrayList<String> opanelsTemp = new ArrayList<>();
for(String tempName : apanels){
if(opanelsTemp.contains(tempName)){
sender.sendMessage(tex.colour(tag) + ChatColor.RED + "Error duplicate panel name: " + tempName);
return false;
}
opanelsTemp.add(tempName);
}
return false;
}
return true;
}
//look through all files in all folders
public void fileNamesFromDirectory(File directory) {
for (String fileName : Objects.requireNonNull(directory.list())) {
if(new File(directory + File.separator + fileName).isDirectory()){
fileNamesFromDirectory(new File(directory + File.separator + fileName));
continue;
}
try {
int ind = fileName.lastIndexOf(".");
if (!fileName.substring(ind).equalsIgnoreCase(".yml") && !fileName.substring(ind).equalsIgnoreCase(".yaml")) {
continue;
}
}catch (Exception ex){
continue;
}
//check before adding the file to commandpanels
if(!checkPanels(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)))){
this.getServer().getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error in: " + fileName);
continue;
}
for (String tempName : Objects.requireNonNull(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).getConfigurationSection("panels")).getKeys(false)) {
panelList.add(new Panel(new File((directory + File.separator + fileName)),tempName));
if(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).contains("panels." + tempName + ".open-with-item")) {
openWithItem = true;
}
}
}
}
public void reloadPanelFiles() {
panelList.clear();
openWithItem = false;
//load panel files
fileNamesFromDirectory(panelsf);
}
public void debug(Exception e, Player p) {
if (p == null) {
if(debug.consoleDebug){
getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "[CommandPanels] The plugin has generated a debug error, find the error below");
e.printStackTrace();
}
}else{
if(debug.isEnabled(p)){
p.sendMessage(tag + ChatColor.DARK_RED + "Check the console for a detailed error.");
getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "[CommandPanels] The plugin has generated a debug error, find the error below");
e.printStackTrace();
}
}
}
public void helpMessage(CommandSender p) {
p.sendMessage(tex.colour( tag + ChatColor.GREEN + "Commands:"));
p.sendMessage(ChatColor.GOLD + "/cp <panel> [player:item] [player] " + ChatColor.WHITE + "Open a command panel.");
if (p.hasPermission("commandpanel.reload")) {
p.sendMessage(ChatColor.GOLD + "/cpr " + ChatColor.WHITE + "Reloads plugin config.");
}
if (p.hasPermission("commandpanel.generate")) {
p.sendMessage(ChatColor.GOLD + "/cpg <rows> " + ChatColor.WHITE + "Generate GUI from popup menu.");
}
if (p.hasPermission("commandpanel.version")) {
p.sendMessage(ChatColor.GOLD + "/cpv " + ChatColor.WHITE + "Display the current version.");
}
if (p.hasPermission("commandpanel.refresh")) {
p.sendMessage(ChatColor.GOLD + "/cpu <player> [position:all] " + ChatColor.WHITE + "Update a panel for a player while it is still open.");
}
if (p.hasPermission("commandpanel.update")) {
p.sendMessage(ChatColor.GOLD + "/cpv latest " + ChatColor.WHITE + "Download the latest update upon server reload/restart.");
p.sendMessage(ChatColor.GOLD + "/cpv [version:cancel] " + ChatColor.WHITE + "Download an update upon server reload/restart.");
}
if (p.hasPermission("commandpanel.edit")) {
p.sendMessage(ChatColor.GOLD + "/cpe <panel file> " + ChatColor.WHITE + "Export panel to the Online Editor.");
}
if (p.hasPermission("commandpanel.import")) {
p.sendMessage(ChatColor.GOLD + "/cpi <file name> <URL> " + ChatColor.WHITE + "Downloads a panel from a raw link online.");
}
if (p.hasPermission("commandpanel.list")) {
p.sendMessage(ChatColor.GOLD + "/cpl " + ChatColor.WHITE + "Lists the currently loaded panels.");
}
if (p.hasPermission("commandpanel.data")) {
p.sendMessage(ChatColor.GOLD + "/cpdata " + ChatColor.WHITE + "Change panel data for a user.");
}
if (p.hasPermission("commandpanel.debug")) {
p.sendMessage(ChatColor.GOLD + "/cpd " + ChatColor.WHITE + "Enable and Disable debug mode globally.");
}
if (p.hasPermission("commandpanel.block.add")) {
p.sendMessage(ChatColor.GOLD + "/cpb add <panel> " + ChatColor.WHITE + "Add panel to a block being looked at.");
}
if (p.hasPermission("commandpanel.block.remove")) {
p.sendMessage(ChatColor.GOLD + "/cpb remove " + ChatColor.WHITE + "Removes any panel assigned to a block looked at.");
}
if (p.hasPermission("commandpanel.block.list")) {
p.sendMessage(ChatColor.GOLD + "/cpb list " + ChatColor.WHITE + "List blocks that will open panels.");
}
}
public final Map<String, Color> colourCodes = new HashMap<String, Color>() {{
put("AQUA", Color.AQUA);
put("BLUE", Color.BLUE);
put("GRAY", Color.GRAY);
put("GREEN", Color.GREEN);
put("RED", Color.RED);
put("WHITE", Color.WHITE);
put("BLACK", Color.BLACK);
put("FUCHSIA", Color.FUCHSIA);
put("LIME", Color.LIME);
put("MAROON", Color.MAROON);
put("NAVY", Color.NAVY);
put("OLIVE", Color.OLIVE);
put("ORANGE", Color.ORANGE);
put("PURPLE", Color.PURPLE);
put("SILVER", Color.SILVER);
put("TEAL", Color.TEAL);
put("YELLOW", Color.YELLOW);
}};
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
//this reads the encrypted resource files in the jar file
byte[] buffer = IOUtils.toByteArray(initialStream);
return new CharSequenceReader(new String(buffer));
}
//split lists using \n escape character
public List<String> splitListWithEscape(List<String> list){
List<String> output = new ArrayList<>();
for(String str : list){
output.addAll(Arrays.asList(str.split("\\\\n")));
}
return output;
}
public int getRandomNumberInRange(int min, int max) {
if (min >= max) {
throw new IllegalArgumentException("max must be greater than min");
}
Random r = new Random();
return r.nextInt((max - min) + 1) + min;
}
//returns true if the item is the MMO Item
public boolean isMMOItem(ItemStack itm, String type, String id){
try {
if (getServer().getPluginManager().isPluginEnabled("MMOItems")) {
NBTItem nbt = NBTItem.get(itm);
if (nbt.getType().equalsIgnoreCase(type) && nbt.getString("MMOITEMS_ITEM_ID").equalsIgnoreCase(id)){
return true;
}
itm.getType();
}
}catch (Exception ex){
debug(ex,null);
}
return false;
}
}

View File

@ -0,0 +1,152 @@
package me.rockyhawk.commandpanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.interactives.input.PlayerInput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.*;
import java.util.List;
import java.util.Objects;
public class Utils implements Listener {
CommandPanels plugin;
public Utils(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void onItemDrag(InventoryDragEvent e) {
Player p = (Player)e.getWhoClicked();
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
if(e.getInventory().getType() != InventoryType.PLAYER){
e.setCancelled(true);
}
}
@EventHandler
public void onPanelClick(InventoryClickEvent e) {
//when clicked on a panel
Player p = (Player)e.getWhoClicked();
int clickedSlot = e.getSlot();
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top) || e.getClick() == ClickType.DOUBLE_CLICK){
return;
}
//set the panel to the top panel
Panel panel = plugin.openPanels.getOpenPanel(p.getName(),PanelPosition.Top);
if(e.getSlotType() == InventoryType.SlotType.OUTSIDE){
//if the panel is clicked on the outside area of the GUI
if (panel.getConfig().contains("outside-commands")) {
try {
plugin.commandRunner.runCommands(panel,PanelPosition.Top,p, panel.getConfig().getStringList("outside-commands"),e.getClick());
}catch(Exception s){
plugin.debug(s,p);
}
}
return;
}
PanelPosition position = PanelPosition.Top;
if(e.getClickedInventory().getType() == InventoryType.PLAYER) {
//cancel the event and return, stops items going from players inventory to the panels
if(e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY){
e.setCancelled(true);
return;
}
//do player or panel inventory checks
if (e.getSlotType() == InventoryType.SlotType.CONTAINER) {
if(plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Middle)) {
position = PanelPosition.Middle;
clickedSlot -= 9;
}else{
e.setCancelled(itemsUnmovable(panel));
return;
}
} else{
if(plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Bottom)) {
position = PanelPosition.Bottom;
//this is set to cancelled as if the command is to close the panel and there is a hotbar item in the same slot
//it will also trigger the hotbar item after the panel is closed
e.setCancelled(true);
}else{
e.setCancelled(itemsUnmovable(panel));
return;
}
}
}
//the panels proper position
panel = plugin.openPanels.getOpenPanel(p.getName(),position);
//this loops through all the items in the panel
String foundSlot = null;
for(String item : Objects.requireNonNull(panel.getConfig().getConfigurationSection("item")).getKeys(false)){
String slot = plugin.tex.placeholdersNoColour(panel, position, p, item);
if (slot.equals(Integer.toString(clickedSlot))) {
foundSlot = item;
break;
}
}
if(foundSlot == null){
e.setCancelled(true);
return;
}
//get the section of the slot that was clicked
String section = plugin.has.hasSection(panel,position,panel.getConfig().getConfigurationSection("item." + foundSlot), p);
if(panel.getConfig().contains("item." + foundSlot + section + ".itemType")){
if(panel.getConfig().getStringList("item." + foundSlot + section + ".itemType").contains("placeable")){
//skip if the item is a placeable
e.setCancelled(false);
return;
}
}
//updates the inventory to stop item glitches
e.setCancelled(true);
p.updateInventory();
//if an item has an area for input instead of commands
if(panel.getConfig().contains("item." + foundSlot + section + ".player-input")) {
plugin.inputUtils.playerInput.put(p,new PlayerInput(panel,panel.getConfig().getStringList("item." + foundSlot + section + ".player-input"),e.getClick()));
plugin.inputUtils.sendMessage(panel,position,p);
}
if(panel.getConfig().contains("item." + foundSlot + section + ".commands")) {
List<String> commands = panel.getConfig().getStringList("item." + foundSlot + section + ".commands");
if (!commands.isEmpty()) {
for (int i = 0; commands.size() > i; i++) {
try {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", e.getCurrentItem().getType().toString()));
} catch (Exception mate) {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", "AIR"));
}
}
if (panel.getConfig().contains("item." + foundSlot + section + ".multi-paywall")) {
plugin.commandRunner.runMultiPaywall(panel,position,p,
panel.getConfig().getStringList("item." + foundSlot + section + ".multi-paywall"),
commands,e.getClick());
} else {
plugin.commandRunner.runCommands(panel, position, p, commands, e.getClick());
}
}
}
}
private boolean itemsUnmovable(Panel panel){
if(panel.getConfig().isSet("panelType")){
//cancel event and return to signal no commands and no movement will occur
return panel.getConfig().getStringList("panelType").contains("unmovable");
}
return false;
}
}

View File

@ -0,0 +1,80 @@
package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class CommandPanelsAPI {
//set to public to adjust any public settings within the plugin through the API
public CommandPanels plugin;
public CommandPanelsAPI(CommandPanels pl) {
this.plugin = pl;
}
//returns true if the player has a panel open
public boolean isPanelOpen(Player p){
return plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top);
}
//get the name of a panel currently open, will return null if panel is not open
public Panel getOpenPanel(Player p, PanelPosition position){
return plugin.openPanels.getOpenPanel(p.getName(), position);
}
//loaded panels in folder
public List<Panel> getPanelsLoaded(){
return plugin.panelList;
}
//import panel into folder
public void addPanel(Panel panel) throws IOException{
File addedFile = new File(plugin.panelsf + File.separator + panel.getName() + ".yml");
YamlConfiguration newYaml = new YamlConfiguration();
if(panel.getConfig().contains("panels")){
newYaml.set("",panel.getConfig());
}else{
newYaml.set("panels." + panel.getName(),panel.getConfig());
}
newYaml.save(addedFile);
plugin.reloadPanelFiles();
}
//remove panel from folder
public void removePanel(Panel panel){
for(Panel panels : plugin.panelList){
if(panels.getName().equals(panel.getName())){
if(panels.getFile().delete()){
plugin.reloadPanelFiles();
}
}
}
}
//get panel from folder
public Panel getPanel(String panelName){
for(Panel panel : plugin.panelList) {
if(panel.getName().equals(panelName)) {
return panel;
}
}
return null;
}
//if the players inventory has no panels in it
public boolean hasNormalInventory(Player p){
return plugin.inventorySaver.hasNormalInventory(p);
}
//make custom item using items section
public ItemStack makeItem(Player p, ConfigurationSection itemSection){
return plugin.itemCreate.makeCustomItemFromConfig(null,PanelPosition.Top,itemSection, p, true, true, false);
}
}

View File

@ -0,0 +1,135 @@
package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.classresources.placeholders.PanelPlaceholders;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
public class Panel{
CommandPanels plugin = JavaPlugin.getPlugin(CommandPanels.class);
/*This is the PanelConfig object*/
private ConfigurationSection panelConfig;
private String panelName;
private File panelFile = null;
public PanelPlaceholders placeholders = new PanelPlaceholders();
public boolean isOpen = false;
//make the object, using a file is recommended
public Panel(File file, String name){
this.panelName = name;
this.panelFile = file;
this.panelConfig = YamlConfiguration.loadConfiguration(file).getConfigurationSection("panels." + name);
}
public Panel(ConfigurationSection config, String name){
if(config.contains("panels")){
config = config.getConfigurationSection("panels." + name);
}
this.panelName = name;
this.panelConfig = config;
}
public Panel(String name){
this.panelName = name;
}
//set elements of the panel
public void setName(String name){
this.panelName = name;
}
public void setConfig(ConfigurationSection config){
if(config.contains("panels")){
config = config.getConfigurationSection("panels." + this.panelName);
}
this.panelConfig = config;
}
public void setFile(File file){
this.panelFile = file;
this.panelConfig = YamlConfiguration.loadConfiguration(file).getConfigurationSection("panels." + this.getName());
}
//get elements of the panel
public String getName(){
return this.panelName;
}
public ConfigurationSection getConfig(){
return this.panelConfig;
}
public File getFile(){
return this.panelFile;
}
public ItemStack getItem(Player p, int slot){
String section = plugin.has.hasSection(this,PanelPosition.Top,panelConfig.getConfigurationSection("item." + slot), p);
ConfigurationSection itemSection = panelConfig.getConfigurationSection("item." + slot + section);
return plugin.itemCreate.makeItemFromConfig(this,PanelPosition.Top,itemSection, p, true, true, false);
}
public ItemStack getCustomItem(Player p, String itemName){
String section = plugin.has.hasSection(this,PanelPosition.Top,panelConfig.getConfigurationSection("custom-item." + itemName), p);
ConfigurationSection itemSection = panelConfig.getConfigurationSection("custom-item." + itemName + section);
return plugin.itemCreate.makeCustomItemFromConfig(this,PanelPosition.Top,itemSection, p, true, true, false);
}
//NBT will equal to panelName:slot and the slot will be -1 if item is not stationery
public ItemStack getHotbarItem(Player p){
if (this.getConfig().contains("open-with-item.pre-load-commands")) {
try {
plugin.commandRunner.runCommands(this,PanelPosition.Top,p, this.getConfig().getStringList("open-with-item.pre-load-commands"), null);
}catch(Exception s){
plugin.debug(s,p);
}
}
ItemStack s = plugin.itemCreate.makeItemFromConfig(this,PanelPosition.Top,getHotbarSection(p), p, true, true, false);
String slot = "-1";
if(getHotbarSection(p).isSet("stationary")){
slot = getHotbarSection(p).getString("stationary");
}
try {
//add NBT to item and return the ItemStack
return plugin.nbt.setNBT(s, "CommandPanelsHotbar", "string_" + panelName + ":" + slot);
}catch(Exception e) {
//return air if null
return new ItemStack(Material.AIR);
}
}
public ConfigurationSection getHotbarSection(Player p){
String section = plugin.has.hasSection(this,PanelPosition.Top,panelConfig.getConfigurationSection("open-with-item"), p);
return panelConfig.getConfigurationSection("open-with-item" + section);
}
public boolean hasHotbarItem(){
return this.panelConfig.contains("open-with-item");
}
//this will make a preview of the inventory using a certain player on the top
public Inventory getInventory(Player p){
return plugin.createGUI.openGui(this,p,PanelPosition.Top, PanelOpenType.Return,0);
}
//open the panel for the player
public void open(Player p, PanelPosition position){
isOpen = true;
plugin.openVoids.openCommandPanel(p, p, this, position, false);
}
//create blank clone
public Panel copy(){
if(panelFile != null){
return new Panel(panelFile, panelName);
}
return new Panel(panelConfig, panelName);
}
}

View File

@ -0,0 +1,45 @@
package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.Inventory;
public class PanelClosedEvent extends Event{
private final Player p;
private final Panel panel;
private final PanelPosition pos;
public PanelClosedEvent(Player player, Panel panel, PanelPosition position) {
this.p = player;
this.panel = panel;
this.pos = position;
}
public Player getPlayer(){
return this.p;
}
public PanelPosition getPosition(){
return this.pos;
}
public Inventory getInventory(){
return this.p.getInventory();
}
public Panel getPanel(){
return this.panel;
}
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -0,0 +1,39 @@
package me.rockyhawk.commandpanels.api;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PanelCommandEvent extends Event {
private final Player p;
private final String args;
private final Panel panel;
public PanelCommandEvent(Player player, String message, Panel panel1) {
this.p = player;
this.args = message;
this.panel = panel1;
}
public Player getPlayer(){
return this.p;
}
public Panel getPanel(){
return this.panel;
}
public String getMessage(){
return this.args;
}
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -0,0 +1,55 @@
package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.Inventory;
public class PanelOpenedEvent extends Event implements Cancellable {
private boolean isCancelled;
private final Player p;
private final Panel panel;
private final PanelPosition pos;
public boolean isCancelled() {
return this.isCancelled;
}
public void setCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
}
public PanelOpenedEvent(Player player, Panel panel, PanelPosition position) {
this.p = player;
this.panel = panel;
this.pos = position;
}
public PanelPosition getPosition(){
return this.pos;
}
public Player getPlayer(){
return this.p;
}
public Inventory getInventory(){
return this.p.getInventory();
}
public Panel getPanel(){
return this.panel;
}
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -0,0 +1,60 @@
package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
public class PanelsInterface {
public String playerName;
private Panel top,middle,bottom = null;
public PanelsInterface(String player){
playerName = player;
}
//if all panels are closed
public boolean allClosed(){
return top == null && middle == null && bottom == null;
}
//get the panels based on position
public void setPanel(Panel panel, PanelPosition position){
switch(position){
case Top:{
if(panel == null && top != null){
top.isOpen = false;
}
top = panel;
return;
}
case Middle:{
if(panel == null && middle != null){
middle.isOpen = false;
}
middle = panel;
return;
}
case Bottom:{
if(panel == null && bottom != null){
bottom.isOpen = false;
}
bottom = panel;
}
}
}
//get the panels based on position
public Panel getPanel(PanelPosition position){
switch(position){
case Top:{
return top;
}
case Middle:{
return middle;
}
case Bottom:{
return bottom;
}
}
return null;
}
}

View File

@ -0,0 +1,164 @@
package me.rockyhawk.commandpanels.classresources;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import java.util.Objects;
public class ExecuteOpenVoids {
CommandPanels plugin;
public ExecuteOpenVoids(CommandPanels pl) {
this.plugin = pl;
}
//this is the main method to open a panel
public void openCommandPanel(CommandSender sender, Player p, Panel panel, PanelPosition position, boolean openForOtherUser){
if(p == null){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Player not found."));
return;
}
if(p.isSleeping()){
//avoid plugin glitches when sleeping
return;
}
if((plugin.debug.isEnabled(sender) || plugin.config.getBoolean("config.auto-update-panels")) && panel.getFile() != null){
//reload the panel if debug is enabled
panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile()));
}
if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return;
}
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !openForOtherUser) {
//check for disabled worlds
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return;
}
if(position != PanelPosition.Top && !plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Cannot open a panel without a panel at the top already."));
return;
}
//close any foreign GUIs for CommandPanels
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top) && p.getOpenInventory().getType() != InventoryType.CRAFTING){
p.closeInventory();
}
//fire PanelOpenedEvent
PanelOpenedEvent openedEvent = new PanelOpenedEvent(p,panel,position);
Bukkit.getPluginManager().callEvent(openedEvent);
if(openedEvent.isCancelled()){
return;
}
//do these commands before the panel loads
beforeLoadCommands(panel,position,p);
try {
//create and open the GUI
plugin.createGUI.openGui(panel, p, position,PanelOpenType.Normal,0);
//execute commands once the panel opens
if (panel.getConfig().contains("commands-on-open")) {
try {
plugin.commandRunner.runCommands(panel,position,p, panel.getConfig().getStringList("commands-on-open"), null);
}catch(Exception s){
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open")));
}
}
if (panel.getConfig().contains("sound-on-open")) {
//play sound when panel is opened
if(!Objects.requireNonNull(panel.getConfig().getString("sound-on-open")).equalsIgnoreCase("off")) {
try {
p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(panel.getConfig().getString("sound-on-open")).toUpperCase()), 1F, 1F);
} catch (Exception s) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + panel.getConfig().getString("sound-on-open")));
}
}
}
if(openForOtherUser) {
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));
}
} catch (Exception r) {
plugin.debug(r,null);
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error")));
plugin.openPanels.closePanelForLoader(p.getName(),position);
p.closeInventory();
}
}else{
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
}
}
//this will give a hotbar item to a player
public void giveHotbarItem(CommandSender sender, Player p, Panel panel, boolean sendGiveMessage){
if (sender.hasPermission("commandpanel.item." + panel.getConfig().getString("perm")) && panel.getConfig().contains("open-with-item")) {
//check for disabled worlds
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return;
}
//if the sender has OTHER perms, or if sendGiveMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !sendGiveMessage) {
try {
if(panel.getConfig().contains("open-with-item.stationary")) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(panel.getConfig().getString("open-with-item.stationary"))), panel.getHotbarItem(p));
}else{
p.getInventory().addItem(panel.getHotbarItem(p));
}
if(sendGiveMessage) {
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName()));
}
} catch (Exception r) {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return;
}
if (!panel.getConfig().contains("open-with-item")) {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.noitem")));
return;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
public void beforeLoadCommands(Panel panel,PanelPosition pos, Player p){
if (panel.getConfig().contains("pre-load-commands")) {
try {
plugin.commandRunner.runCommands(panel,pos,p, panel.getConfig().getStringList("pre-load-commands"), null);
}catch(Exception s){
plugin.debug(s,p);
}
}
}
}

View File

@ -0,0 +1,132 @@
package me.rockyhawk.commandpanels.classresources;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import java.math.BigDecimal;
import java.util.*;
public class HasSections {
CommandPanels plugin;
public HasSections(CommandPanels pl) {
plugin = pl;
}
public String hasSection(Panel panel, PanelPosition position, ConfigurationSection cf, Player p) {
// Use a TreeMap to automatically sort the sections by the extracted number.
Map<Integer, String> sortedSections = new TreeMap<>();
// Loop through the section names and filter for the ones starting with "has".
for (String key : cf.getKeys(false)) {
if (!cf.isConfigurationSection(key)) continue;
// Check if the section starts with "has" and is followed by a number.
if (key.startsWith("has")) {
try {
// Extract the number after "has" and put it in the map for sorting.
int number = Integer.parseInt(key.substring(3));
sortedSections.put(number, key);
} catch (NumberFormatException ignore) {
// If the section name doesn't have a valid number after "has", skip it.
}
}
}
for (String hasSection : sortedSections.values()) {
if (!cf.isConfigurationSection(hasSection)) continue;
ConfigurationSection currentSection = cf.getConfigurationSection(hasSection);
int numberOfConditions = currentSection.getKeys(false).size();
Boolean currentBlockResult = null; // This will store the result of the current block (a set of conditions combined by AND or OR).
String previousOperator = "AND"; // Default logical operator to start with.
for (int a = 0; a < numberOfConditions; a++) {
if (!currentSection.isSet("value" + a) || !currentSection.isSet("compare" + a)) {
continue;
}
String value = ChatColor.stripColor(plugin.tex.placeholders(panel, position, p, currentSection.getString("value" + a)));
String compare = ChatColor.stripColor(plugin.tex.placeholders(panel, position, p, currentSection.getString("compare" + a)));
String operator = "AND"; // Default operator for the current condition.
if (compare.endsWith(" OR")) {
compare = compare.substring(0, compare.length() - 3);
operator = "OR";
} else if (compare.endsWith(" AND")) {
compare = compare.substring(0, compare.length() - 4);
}
HashSet<String> values = doOperators(new HashSet<>(Collections.singletonList(value)));
boolean localResult = false; // This tracks the result of the current condition.
for (String val : values) {
if (hasProcess(val, compare)) {
localResult = true;
break;
}
}
if (currentBlockResult == null) {
// Initialize the result of the block with the result of the first condition.
currentBlockResult = localResult;
} else {
// Combine the result of the current condition with the block result based on the previous operator.
if (previousOperator.equals("AND")) {
currentBlockResult = currentBlockResult && localResult;
} else if (previousOperator.equals("OR")) {
currentBlockResult = currentBlockResult || localResult;
}
}
previousOperator = operator; // Update the operator for the next condition.
}
if (currentBlockResult != null && currentBlockResult) {
// If the result of this section is true, check nested sections.
return "." + hasSection + hasSection(panel, position, currentSection, p);
}
// If the result is false, continue to the next 'has' section.
}
return "";
}
private HashSet<String> doOperators(HashSet<String> value){
for(String val : value){
if(val.contains(" OR ")){
value.remove(val);
value.addAll(Arrays.asList(val.split(" OR ")));
return doOperators(value);
}
}
return value;
}
private boolean hasProcess(String value, String compare){
//check to see if the value should be reversed
boolean outputValue = true;
if(value.startsWith("NOT ")){
value = value.substring(4);
outputValue = false;
}
//the current has section with all the functions implemented inside it
if(value.endsWith(" HASPERM")) {
String playername = value.substring(0, value.length()-8);
Player player = Bukkit.getPlayerExact(playername);
if(player != null){
return player.hasPermission(compare) == outputValue;
}
}else if(value.endsWith(" ISGREATER")) {
return (new BigDecimal(compare).compareTo(new BigDecimal(value.substring(0, value.length()-10).replace(",",""))) <= 0 == outputValue);
}else{
return compare.equals(value) == outputValue;
}
return false;
}
}

View File

@ -0,0 +1,647 @@
package me.rockyhawk.commandpanels.classresources;
import dev.lone.itemsadder.api.CustomStack;
import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.classresources.customheads.SavedCustomHead;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.manager.ItemManager;
import org.bukkit.*;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.inventory.meta.trim.ArmorTrim;
import org.bukkit.inventory.meta.trim.TrimMaterial;
import org.bukkit.inventory.meta.trim.TrimPattern;
import org.bukkit.potion.PotionType;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
public class ItemCreation {
CommandPanels plugin;
public ItemCreation(CommandPanels pl) {
plugin = pl;
}
@SuppressWarnings("deprecation")
public ItemStack makeItemFromConfig(Panel panel, PanelPosition position, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String material = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("material"));
try {
if (Objects.requireNonNull(material).equalsIgnoreCase("AIR")) {
return null;
}
}catch(NullPointerException e){
plugin.debug(e,p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!"));
return null;
}
ItemStack s = null;
boolean hideAttributes = false;
String mat;
String matraw;
String skullname;
//this will convert the %cp-player-online-1-find% into cps= NAME
if (material.contains("%cp-player-online-")) {
int start = material.indexOf("%cp-player-online-");
int end = material.lastIndexOf("-find%");
String playerLocation = material.substring(start, end).replace("%cp-player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Integer.parseInt(playerLocation) > playerFind.length) {
material = material.replace(material.substring(start, end) + "-find%", "cps= " + plugin.config.getString("config.format.offlineHeadValue"));
} else {
material = material.replace(material.substring(start, end) + "-find%", "cpo= " + playerFind[Integer.parseInt(playerLocation) - 1].getName());
//cpo is to get the skull of the player online. It is fine since the plugin knows the player is online
}
}
try {
//can be changed
mat = material.toUpperCase();
//cannot be changed (raw)
matraw = material;
//generate item stack normally
boolean normalCreation = true;
//name of head/skull if used
skullname = "no skull";
short id = 0;
if(itemSection.contains("ID")){
id = Short.parseShort(itemSection.getString("ID"));
}
if (matraw.split("\\s")[0].equalsIgnoreCase("cps=") || matraw.split("\\s")[0].toLowerCase().equals("cpo=")) {
skullname = p.getUniqueId().toString();
mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
id = 3;
}
}
if (matraw.split("\\s")[0].equalsIgnoreCase("hdb=")) {
skullname = "hdb";
mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
id = 3;
}
}
//Oraxen support, uses itemID (eg, oraxen= coin)
if (matraw.split("\\s")[0].equalsIgnoreCase("oraxen=")) {
String itemID = matraw.split("\\s")[1];
try {
// Load the OraxenItems class
Class<?> oraxenItemsClass = Class.forName("io.th0rgal.oraxen.api.OraxenItems");
// Retrieve the 'getItemById' method from the OraxenItems class
Method getItemByIdMethod = oraxenItemsClass.getMethod("getItemById", String.class);
getItemByIdMethod.setAccessible(true);
// Invoke the 'getItemById' method with the itemID
Object oraxenItem = getItemByIdMethod.invoke(null, itemID); // static method, so pass 'null'
// Ensure that the method returned a valid Oraxen item
if (oraxenItem != null) {
// Now we need to invoke 'getReferenceClone' on the OraxenItem object
Method getReferenceCloneMethod = oraxenItem.getClass().getMethod("getReferenceClone");
getReferenceCloneMethod.setAccessible(true);
ItemStack stack = (ItemStack) getReferenceCloneMethod.invoke(oraxenItem);
// Check if stack is not null
if (stack != null) {
s = stack;
normalCreation = false;
}
}
} catch (Exception e) {
plugin.debug(e, null);
// Handle the error or inform the player
}
}
//ItemsAdder support, needs namespaceID (eg, itemsadder= money:coin)
if (matraw.split("\\s")[0].equalsIgnoreCase("itemsadder=")) {
String namespaceID = matraw.split("\\s")[1];
CustomStack stack = CustomStack.getInstance(namespaceID);
if(stack != null) {
s = stack.getItemStack().clone();
normalCreation = false;
}
}
//creates custom MMOItems items
if(matraw.split("\\s")[0].equalsIgnoreCase("mmo=") && plugin.getServer().getPluginManager().isPluginEnabled("MMOItems")){
String itemType = matraw.split("\\s")[1];
String itemID = matraw.split("\\s")[2];
ItemManager itemManager = MMOItems.plugin.getItems();
MMOItem mmoitem = itemManager.getMMOItem(MMOItems.plugin.getTypes().get(itemType), itemID);
s = mmoitem.newBuilder().build();
normalCreation = false;
}
//creates a written book item
if(matraw.split("\\s")[0].equalsIgnoreCase("book=")){
s = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) s.getItemMeta();
bookMeta.setTitle(matraw.split("\\s")[1]);
bookMeta.setAuthor(matraw.split("\\s")[1]);
List<String> bookLines = plugin.tex.placeholdersList(panel,position,p,itemSection.getStringList("write"),true);
String result = bookLines.stream().map(String::valueOf).collect(Collectors.joining("\n" + ChatColor.RESET, "", ""));
bookMeta.setPages(result);
s.setItemMeta(bookMeta);
normalCreation = false;
}
//creates item from custom-items section of panel
if(matraw.split("\\s")[0].equalsIgnoreCase("cpi=")){
s = makeCustomItemFromConfig(panel,position,panel.getConfig().getConfigurationSection("custom-item." + matraw.split("\\s")[1]), p, true, true, false);
normalCreation = false;
}
if(normalCreation) {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1, id);
}
if (!skullname.equals("no skull") && !skullname.equals("hdb") && !matraw.split("\\s")[0].equalsIgnoreCase("cpo=")) {
try {
SkullMeta meta;
if (matraw.split("\\s")[1].equalsIgnoreCase("self")) {
//if cps= self
meta = (SkullMeta) s.getItemMeta();
if(!plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
try {
assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname)));
} catch (Exception var23) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self"));
plugin.debug(var23,p);
}
}else{
meta.setOwner(p.getName());
}
s.setItemMeta(meta);
}else if (plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]).length() <= 16) {
//if cps= username
s = plugin.customHeads.getPlayerHead(plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]));
} else {
//custom data cps= base64
s = plugin.customHeads.getCustomHead(plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]));
}
} catch (Exception var32) {
p.sendMessage(plugin.tex.colour( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
plugin.debug(var32,p);
}
}
if (!skullname.equals("no skull") && matraw.split("\\s")[0].equalsIgnoreCase("cpo=")) {
SkullMeta cpoMeta = (SkullMeta) s.getItemMeta();
assert cpoMeta != null;
cpoMeta.setOwningPlayer(Bukkit.getOfflinePlayer(Objects.requireNonNull(Bukkit.getPlayer(matraw.split("\\s")[1])).getUniqueId()));
s.setItemMeta(cpoMeta);
}
if (skullname.equals("hdb")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("HeadDatabase")) {
HeadDatabaseAPI api;
api = new HeadDatabaseAPI();
try {
s = api.getItemHead(matraw.split("\\s")[1].trim());
} catch (Exception var22) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!"));
plugin.debug(var22,p);
}
} else {
p.sendMessage(plugin.tex.colour(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!"));
}
}
//itemType values
if(itemSection.contains("itemType")){
//if hidden, reverse
if(itemSection.getStringList("itemType").contains("noAttributes")){
hideAttributes = true;
}
if(itemSection.getStringList("itemType").contains("placeable")){
addNBT = false;
}
}
if(itemSection.contains("nbt")){
//ItemStack item, ConfigurationSection section, Player player, Panel panel, PanelPosition position
plugin.nbt.applyNBTRecursively(s, itemSection.getConfigurationSection("nbt"), p, panel, position);
//plugin.nbt.applyNBTRecursively("", itemSection.getConfigurationSection("nbt"), s, p, panel, position);
}
if(addNBT){
plugin.nbt.setNBT(s, "CommandPanelsItem","boolean_" + "true");
}
if (itemSection.contains("enchanted")) {
try {
ItemMeta EnchantMeta;
if(itemSection.isList("enchanted")){
//if list contains true, hide enchanted and add KNOCKBACK
EnchantMeta = s.getItemMeta();
assert EnchantMeta != null;
for(String enchantment : itemSection.getStringList("enchanted")){
if(enchantment.equalsIgnoreCase("true")) {
EnchantMeta.addEnchant(Enchantment.KNOCKBACK, 1, false);
EnchantMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
continue;
}
EnchantMeta.addEnchant(Objects.requireNonNull(EnchantmentWrapper.getByKey(NamespacedKey.minecraft(enchantment.split("\\s")[0].toLowerCase()))), Integer.parseInt(enchantment.split("\\s")[1]), true);
}
s.setItemMeta(EnchantMeta);
}
} catch (Exception ench) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted")));
plugin.debug(ench,p);
}
}
if (itemSection.contains("customdata")) {
ItemMeta customMeta = s.getItemMeta();
assert customMeta != null;
customMeta.setCustomModelData(Integer.parseInt(plugin.tex.placeholders(panel,position,p,itemSection.getString("customdata"))));
s.setItemMeta(customMeta);
}
try {
if (itemSection.contains("banner")) {
BannerMeta bannerMeta = (BannerMeta) s.getItemMeta();
List<Pattern> patterns = new ArrayList<>(); //Load patterns in order top to bottom
for (String temp : itemSection.getStringList("banner")) {
temp = plugin.tex.placeholdersNoColour(panel,position,p,temp);
String[] dyePattern = temp.split(",");
patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED,STRIPE_TOP
}
bannerMeta.setPatterns(patterns);
s.setItemMeta(bannerMeta);
}
}catch(Exception ignore){
//not a banner or error
}
if (itemSection.contains("leatherarmor")) {
//if the item is leather armor, change the colour to this
try {
if (s.getType() == Material.LEATHER_BOOTS ||
s.getType() == Material.LEATHER_LEGGINGS ||
s.getType() == Material.LEATHER_CHESTPLATE ||
s.getType() == Material.LEATHER_HELMET ||
s.getType() == Material.matchMaterial("LEATHER_HORSE_ARMOR")) { //avoid exceptions on older versions which don't have leather armour
LeatherArmorMeta leatherMeta = (LeatherArmorMeta) s.getItemMeta();
String colourCode = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("leatherarmor"));
assert colourCode != null;
if (!colourCode.contains(",")) {
//use a color name
assert leatherMeta != null;
leatherMeta.setColor(plugin.colourCodes.get(colourCode.toUpperCase()));
} else {
//use RGB sequence
int[] colorRGB = {255, 255, 255};
int count = 0;
for (String colourNum : colourCode.split(",")) {
colorRGB[count] = Integer.parseInt(colourNum);
count += 1;
}
assert leatherMeta != null;
leatherMeta.setColor(Color.fromRGB(colorRGB[0], colorRGB[1], colorRGB[2]));
}
s.setItemMeta(leatherMeta);
}
} catch (Exception er) {
//don't colour the armor
plugin.debug(er,p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor")));
}
}
if (itemSection.contains("potion")) {
//if the item is a potion, give it an effect
String[] effectType = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("potion")).split("\\s");
//potion legacy or current
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
if(plugin.legacy.MAJOR_VERSION.equals(MinecraftVersions.v1_8)){
plugin.classicPotion.applyPotionEffect(p, s, effectType);
}else {
plugin.legacyPotion.applyPotionEffect(p, s, effectType);
}
}else{
try {
PotionMeta potionMeta = (PotionMeta)s.getItemMeta();
assert potionMeta != null;
PotionType newData = PotionType.valueOf(effectType[0].toUpperCase());
//set meta
potionMeta.setBasePotionType(newData);
s.setItemMeta(potionMeta);
} catch (Exception er) {
//don't add the effect
plugin.debug(er,p);
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion")));
}
}
}
if(itemSection.contains("potion-color")){
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_11)){
String[] rgb = Objects.requireNonNull(itemSection.getString("potion-color")).split(",");
Color color = Color.fromRGB(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2]));
PotionMeta potionMeta = (PotionMeta)s.getItemMeta();
assert potionMeta != null;
potionMeta.setColor(color);
s.setItemMeta(potionMeta);
}
}
if (itemSection.contains("damage")) {
//change the damage amount (placeholders accepted)
//if the damage is not unbreakable and should be a value
if (plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
try {
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p, itemSection.getString("damage")))));
} catch (Exception e) {
plugin.debug(e, p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
}
} else {
if(itemSection.getString("damage").equalsIgnoreCase("-1")){
//if the player wants the item to be unbreakable. Only works in non legacy versions
ItemMeta unbreak = s.getItemMeta();
unbreak.setUnbreakable(true);
s.setItemMeta(unbreak);
}else {
try {
Damageable itemDamage = (Damageable) s.getItemMeta();
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel, position, p, itemSection.getString("damage")))));
s.setItemMeta((ItemMeta) itemDamage);
} catch (Exception e) {
plugin.debug(e, p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
}
}
}
}
// 1.20 Trim Feature for Player Armor
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && itemSection.contains("trim")){
// trim: <Material> <Pattern>
String trim = itemSection.getString("trim");
String[] trimList = trim.split("\\s");
if(trimList.length == 2){
String trimMaterialString = trimList[0].toLowerCase();
String trimPatternString = trimList[1].toLowerCase();
// Check if Material and Pattern are valid and the itemstack is an armor piece
if(isTrimMaterial(trimMaterialString) && isTrimPattern(trimPatternString) && isArmor(s)){
// Getting the correct Pattern and Material - Seems to be experimental this way
// Material and Pattern don't have a valueOf-function to get them the easier way.
TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(Objects.requireNonNull(NamespacedKey.fromString("minecraft:" + trimMaterialString)));
TrimPattern trimPattern = Registry.TRIM_PATTERN.get(Objects.requireNonNull(NamespacedKey.fromString("minecraft:" + trimPatternString)));
ArmorMeta armorMeta = (ArmorMeta) s.getItemMeta();
armorMeta.setTrim(new ArmorTrim(trimMaterial, trimPattern));
s.setItemMeta(armorMeta);
}
}
}
if (itemSection.contains("stack")) {
//change the stack amount (placeholders accepted)
s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p,itemSection.getString("stack")))));
}
//do the items commands throughout the refresh
//check that the panel is already open and not running commands when opening
if (itemSection.contains("refresh-commands") && plugin.openPanels.hasPanelOpen(p.getName(), panel.getName(), position)) {
try {
plugin.commandRunner.runCommands(panel,position,p,itemSection.getStringList("refresh-commands"), null);
}catch(Exception ex){
plugin.debug(ex,p);
}
}
} catch (IllegalArgumentException | NullPointerException var33) {
plugin.debug(var33,p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material")));
return null;
}
s = plugin.setName(panel,s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours, hideAttributes);
return s;
}
//do custom-item items, they have an additional hasSection requirement
public ItemStack makeCustomItemFromConfig(Panel panel,PanelPosition position, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String section = plugin.has.hasSection(panel,position,itemSection,p);
if(!section.equals("")){
itemSection = itemSection.getConfigurationSection(section.substring(1));
}
return plugin.itemCreate.makeItemFromConfig(panel,position,itemSection, p, placeholders, colours, addNBT);
}
@SuppressWarnings("deprecation")
public YamlConfiguration generatePanelFile(String panelName, Inventory inv, YamlConfiguration file){
ItemStack cont;
for(int i = 0; inv.getSize() > i; i++){
cont = inv.getItem(i);
//repeat through all the items in the editor
try{
//make the item here
if(cont == null){
//remove if items have been removed
if(file.contains("panels." + panelName + ".item." + i)){
//if the material doesn't equal air (don't delete air materials in the editor)
if(!file.getString("panels." + panelName + ".item." + i + ".material").equalsIgnoreCase("AIR")) {
file.set("panels." + panelName + ".item." + i, null);
continue;
}
}
}
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if (cont.getDurability() != 0 && !cont.getType().toString().equals("SKULL_ITEM")) {
file.set("panels." + panelName + ".item." + i + ".ID", cont.getDurability());
}
}
if(file.contains("panels." + panelName + ".item." + i + ".material")){
if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") || Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")){
if(!plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
}
}else{
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
}
}else{
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
}
if(plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
if(!Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") && !Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")) {
file.set("panels." + panelName + ".item." + i + ".material", plugin.getHeads.playerHeadString());
}
}
try {
BannerMeta bannerMeta = (BannerMeta) cont.getItemMeta();
List<String> dyePattern = new ArrayList<>();
for(Pattern pattern : bannerMeta.getPatterns()) { //sublist to skip first value
dyePattern.add(pattern.getColor() + "," + pattern.getPattern());
}
file.set("panels." + panelName + ".item." + i + ".banner", dyePattern);
}catch(Exception ignore){
//not a banner
file.set("panels." + panelName + ".item." + i + ".banner", null);
}
try {
//potion legacy PotionData or current PotionType
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
if(plugin.legacyPotion.retrievePotionData(cont) != null) {
file.set("panels." + panelName + ".item." + i + ".potion", plugin.legacyPotion.retrievePotionData(cont));
}
}else{
PotionMeta potionMeta = (PotionMeta) cont.getItemMeta();
assert potionMeta != null;
String potionType = potionMeta.getBasePotionType().toString(); // Gets the potion type as a string rather than bukkit type
file.set("panels." + panelName + ".item." + i + ".potion", potionType);
}
}catch(Exception ignore){
//not a banner
file.set("panels." + panelName + ".item." + i + ".potion", null);
}
file.set("panels." + panelName + ".item." + i + ".stack", cont.getAmount());
if(!cont.getEnchantments().isEmpty()){
Map<Enchantment, Integer> enchantments = cont.getEnchantments();
List<String> newEnchantments = new ArrayList<>();
for(Enchantment enchantment : enchantments.keySet()){
newEnchantments.add(enchantment.getKey().getKey() + " " + enchantments.get(enchantment));
}
file.set("panels." + panelName + ".item." + i + ".enchanted", newEnchantments);
}
file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore());
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_14)){
file.set("panels." + panelName + ".item." + i + ".customdata", Objects.requireNonNull(cont.getItemMeta()).getCustomModelData());
}
}catch(Exception n){
//skip over an item that spits an error
}
}
return file;
}
/*
The ItemStack 'one' will be used, if it doesn't have a lore for example, it won't check to see if the other does have one
The isIdentical() function will check for the following
Material, Name, Lore, Enchanted, Potion
*/
@SuppressWarnings("deprecation")
public boolean isIdentical(ItemStack one, ItemStack two, Boolean nbtCheck){
//check material
if (one.getType() != two.getType()) {
return false;
}
if(one.hasItemMeta() != two.hasItemMeta()){
return false;
}
//check for name
try {
if (!one.getItemMeta().getDisplayName().equals(two.getItemMeta().getDisplayName())) {
if(one.getItemMeta().hasDisplayName()) {
return false;
}
}
}catch(Exception ignore){}
//check for ID 1.12.2 and below
try {
if (plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12) &&
(one.getDurability() != two.getDurability())) {
return false;
}
}catch(Exception ignore){}
//check for lore
try {
if (!one.getItemMeta().getLore().equals(two.getItemMeta().getLore())) {
if(one.getItemMeta().hasLore()) {
return false;
}
}
}catch(Exception ignore){}
//check for custom model data
try {
if (plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_14)){
if (one.getItemMeta().getCustomModelData() != (two.getItemMeta().getCustomModelData())) {
if(one.getItemMeta().hasCustomModelData()) {
return false;
}
}
}
}catch(Exception ignore){}
//check for nbt
if(nbtCheck) {
try {
if (!plugin.nbt.hasSameNBT(one, two)) {
return false;
}
} catch (Exception ignore) {}
}
//check for damage
try {
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if(one.getDurability() != two.getDurability()) {
return false;
}
}else {
Damageable tempOne = (Damageable) one.getItemMeta();
Damageable tempTwo = (Damageable) two.getItemMeta();
if(tempOne.getDamage() != tempTwo.getDamage()){
return false;
}
}
} catch (Exception ignore) {}
//check for potions
try {
//choose between legacy PotionData (pre 1.20.5) or PotionType
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
String potionOne = plugin.legacyPotion.retrievePotionData(one);
String potionTwo = plugin.legacyPotion.retrievePotionData(two);
if(!potionOne.equals(potionTwo)){
return false;
}
}else{
//post 1.20.5 compare
PotionMeta meta1 = (PotionMeta) one.getItemMeta();
PotionMeta meta2 = (PotionMeta) two.getItemMeta();
if (meta1.getBasePotionType().toString().compareTo(meta2.getBasePotionType().toString()) != 0){
return false;
}
}
}catch(Exception ignore){}
//check for enchantments
if(one.getEnchantments() == two.getEnchantments()){
if(!one.getEnchantments().isEmpty()) {
return false;
}
}
return true;
}
private boolean isTrimMaterial(String material){
List<String> availableMaterial = Arrays.asList("AMETHYST",
"COPPER", "DIAMOND", "EMERALD", "GOLD", "IRON","LAPIS", "NETHERITE", "QUARTZ", "REDSTONE");
return availableMaterial.contains(material.toUpperCase());
}
private boolean isTrimPattern(String pattern){
List<String> availablePattern = Arrays.asList("COAST",
"DUNE", "EYE", "HOST", "RAISER", "RIB","SENTRY", "SHAPER", "SILENCE", "SNOUT", "SPIRE", "TIDE","VEX", "WARD", "WAYFINDER", "WILD");
return availablePattern.contains(pattern.toUpperCase());
}
private boolean isArmor(ItemStack stack){
return EnchantmentTarget.ARMOR.includes(stack);
}
}

View File

@ -0,0 +1,60 @@
package me.rockyhawk.commandpanels.classresources;
import me.rockyhawk.commandpanels.CommandPanels;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.util.List;
import java.util.stream.Collectors;
public class MiniMessageUtils {
CommandPanels plugin;
public MiniMessageUtils(CommandPanels pl) {
this.plugin = pl;
}
/*
MiniMessage is used here as an alternative to the standard Minecraft colour codes &
As MiniMessage does not accept legacy colour codes at any point, which is
a possibility when using Minecraft colour codes, running a try/catch allows for
MiniMessage to be used anywhere and ignored when legacy colour codes are found.
*/
public String doMiniMessageLegacy(String string) {
MiniMessage miniMessage = MiniMessage.miniMessage();
try {
Component component = miniMessage.deserialize(string);
return LegacyComponentSerializer.builder()
.character('&')
.hexColors()
.build()
.serialize(component);
}catch (Exception e){
return string;
}
}
public List<String> doMiniMessageLegacy(List<String> strings) {
return strings.stream()
.map(this::doMiniMessageLegacy)
.collect(Collectors.toList());
}
public Component doMiniMessage(String string) {
LegacyComponentSerializer legacyComponentSerializer = LegacyComponentSerializer.builder().hexColors().character('&').build();
Component component = legacyComponentSerializer.deserialize(string.replace('§', '&'));
return MiniMessage.miniMessage().deserialize(MiniMessage.miniMessage().serialize(component.decoration(TextDecoration.ITALIC, false))
.replace("\\<", "<").replace("\\", "").replace("\n", "<br>")).decoration(TextDecoration.ITALIC, false);
}
public List<Component> doMiniMessage(List<String> strings) {
return strings.stream()
.map(this::doMiniMessage)
.collect(Collectors.toList());
}
}

View File

@ -0,0 +1,34 @@
package me.rockyhawk.commandpanels.classresources.customheads;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.classresources.customheads.methods.CustomHeadGameProfile;
import me.rockyhawk.commandpanels.classresources.customheads.methods.CustomHeadPlayerProfile;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import org.bukkit.inventory.ItemStack;
public class GetCustomHeads {
CustomHeadGameProfile gameProfileHeadClass;
CustomHeadPlayerProfile playerProfileHeadClass;
CommandPanels plugin;
public GetCustomHeads(CommandPanels pl) {
this.plugin = pl;
gameProfileHeadClass = new CustomHeadGameProfile(pl);
playerProfileHeadClass = new CustomHeadPlayerProfile();
}
public ItemStack getCustomHead(String base64){
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18)){
return playerProfileHeadClass.getCustomHead(base64);
}else{
return gameProfileHeadClass.getCustomHead(base64);
}
}
public ItemStack getPlayerHead(String playerName){
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_21)){
return playerProfileHeadClass.getPlayerHead(playerName);
}else{
return gameProfileHeadClass.getPlayerHead(playerName);
}
}
}

View File

@ -0,0 +1,17 @@
package me.rockyhawk.commandpanels.classresources.customheads;
import org.bukkit.inventory.ItemStack;
public class SavedCustomHead {
public String base64;
public ItemStack headItem;
public boolean isValid; // true if the head was successfully fetched, false otherwise
public long lastAttempt; // timestamp of the last attempt
public SavedCustomHead(ItemStack head, String base64value, boolean isValidAttempt) {
base64 = base64value;
headItem = head;
isValid = isValidAttempt;
lastAttempt = System.currentTimeMillis();
}
}

View File

@ -0,0 +1,185 @@
package me.rockyhawk.commandpanels.classresources.customheads.methods;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.classresources.customheads.SavedCustomHead;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.*;
public class CustomHeadGameProfile {
CommandPanels plugin;
public CustomHeadGameProfile(CommandPanels pl) {
this.plugin = pl;
}
public HashMap<String, SavedCustomHead> savedCustomHeads = new HashMap<>();
//getting the head from a Player Name
public ItemStack getPlayerHead(String name) {
byte id = 0;
if (plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
id = 3;
}
//get texture if already cached
if (savedCustomHeads.containsKey(name)) {
if (!savedCustomHeads.get(name).isValid && (System.currentTimeMillis() - savedCustomHeads.get(name).lastAttempt) < 60000) {
// If the last attempt was less than 60 seconds ago and was invalid, return null or a default item
return new ItemStack(Material.valueOf(plugin.getHeads.playerHeadString()));
}
if(savedCustomHeads.get(name).isValid) {
return savedCustomHeads.get(name).headItem; // Return cached item if valid
}
}
//create ItemStack
ItemStack itemStack = new ItemStack(Material.matchMaterial(plugin.getHeads.playerHeadString()), 1, id);
//Run fallback code, if API call fails, use legacy setOwner
SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
meta.setOwner(name);
itemStack.setItemMeta(meta);
// Fetch and cache the texture asynchronously
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
if(plugin.debug.consoleDebug){
plugin.getServer().getConsoleSender().sendMessage(plugin.tex.colour(plugin.tag +
ChatColor.WHITE +
"Download & Cache Head Texture for " + name));
}
// Fetch the player UUID from the Mojang API
URL uuidUrl = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
URLConnection uuidConnection = uuidUrl.openConnection();
uuidConnection.setConnectTimeout(2000); // Set connection timeout to 2 seconds
uuidConnection.setReadTimeout(2000); // Set read timeout to 2 seconds
//Json is simple and structured so a hard code solution will avoid the need for a library
String uuidReader = new Scanner(uuidConnection.getInputStream(),
StandardCharsets.UTF_8.name()).useDelimiter("\\A").next();
String uuid = uuidReader.split("\"id\" : \"")[1].split("\"")[0];
// Fetch the skin texture from the Mojang API using the player UUID
URL texturesUrl = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid);
URLConnection texturesConnection = texturesUrl.openConnection();
texturesConnection.setConnectTimeout(2000); // Set connection timeout to 2 seconds
texturesConnection.setReadTimeout(2000); // Set read timeout to 2 seconds
//Json is simple and structured so a hard code solution will avoid the need for a library
String valueReader = new Scanner(texturesConnection.getInputStream(),
StandardCharsets.UTF_8.name()).useDelimiter("\\A").next();
String value = valueReader.split("\"value\" : \"")[1].split("\"")[0];
// Once the API call is finished, update the ItemStack on the main thread
Bukkit.getScheduler().runTask(plugin, () -> {
itemStack.setItemMeta(getCustomHead(name, value).getItemMeta());
savedCustomHeads.put(name, new SavedCustomHead(itemStack, value, true));
});
} catch (Exception ignore) {
Bukkit.getScheduler().runTask(plugin, () -> {
//do not overwrite a valid cached head
if(savedCustomHeads.containsKey(name) && savedCustomHeads.get(name).isValid){
return;
}
savedCustomHeads.put(name, new SavedCustomHead(null, null, false)); // Mark as invalid
});
}
});
return itemStack;
}
//will also use cached heads feature to get heads if player name is provided
public ItemStack getCustomHead(String playerName, String b64stringtexture) {
//check for any saved heads
if(savedCustomHeads.containsKey(playerName)) {
if (savedCustomHeads.get(playerName).base64 != null) {
return savedCustomHeads.get(playerName).headItem;
}
savedCustomHeads.get(playerName).isValid = false;
}
//clear cached textures list until length limit is reached
Iterator<Map.Entry<String, SavedCustomHead>> iterator = savedCustomHeads.entrySet().iterator();
while (savedCustomHeads.size() > 2000 && iterator.hasNext()) {
iterator.next(); // Move to next entry
iterator.remove(); // Remove the entry
}
//if saved head is not found from player name, get head manually
return getCustomHead(b64stringtexture);
}
//used to get heads from Base64 Textures
@SuppressWarnings("deprecation")
public ItemStack getCustomHead(String b64stringtexture) {
//get head from base64
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
PropertyMap propertyMap = profile.getProperties();
if (propertyMap == null) {
throw new IllegalStateException("Profile doesn't contain a property map");
} else {
propertyMap.put("textures", new Property("textures", b64stringtexture));
byte id = 0;
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)){
id = 3;
}
ItemStack head = new ItemStack(Material.matchMaterial(plugin.getHeads.playerHeadString()), 1,id);
ItemMeta headMeta = head.getItemMeta();
assert headMeta != null;
Field profileField;
Method setProfileMethod = null;
try {
// Attempt to access the 'profile' field directly
// Also writes to 'serializedProfile' field as one cannot be null while the other is not
// This block is mainly for 1.20.2+ versions
profileField = headMeta.getClass().getDeclaredField("profile");
Field serializedProfileField = headMeta.getClass().getDeclaredField("serializedProfile");
profileField.setAccessible(true);
serializedProfileField.setAccessible(true);
profileField.set(headMeta, profile);
serializedProfileField.set(headMeta, profile); // Assuming serializedProfile is of the same type
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
try {
// This block covers versions that have a 'setProfile' method instead of direct field access
// Likely for versions prior to 1.20.2
setProfileMethod = headMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
} catch (NoSuchMethodException ignore) {}
} catch (SecurityException ignored) {}
try {
if (setProfileMethod == null) {
// Attempt to access the 'profile' field directly
// This block is a generic fallback for versions lacking the 'setProfile' method
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} else {
// Use the 'setProfile' method if it was found
setProfileMethod.setAccessible(true);
setProfileMethod.invoke(headMeta, profile);
}
} catch (Exception e1) {
plugin.debug(e1,null);
}
head.setItemMeta(headMeta);
return head;
}
}
}

View File

@ -0,0 +1,118 @@
package me.rockyhawk.commandpanels.classresources.customheads.methods;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.profile.PlayerProfile;
import org.bukkit.profile.PlayerTextures;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
public class CustomHeadPlayerProfile {
//cached itemstacks stored for access
public HashMap<String, ItemStack> savedCustomHeads = new HashMap<>();
//Using the PlayerProfile API for getting custom heads
public ItemStack getCustomHead(String base64Texture) {
//check for any saved heads
if(savedCustomHeads.containsKey(base64Texture)) {
return savedCustomHeads.get(base64Texture);
}
//clear cached textures list until length limit is reached
Iterator<Map.Entry<String, ItemStack>> iterator = savedCustomHeads.entrySet().iterator();
while (savedCustomHeads.size() > 2000 && iterator.hasNext()) {
iterator.next(); // Move to next entry
iterator.remove(); // Remove the entry
}
// Create a new player head ItemStack
ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
// Create a new PlayerProfile
UUID uuid = UUID.randomUUID(); // Unique ID for the profile
PlayerProfile profile = Bukkit.createPlayerProfile(uuid);
// Decode the base64 texture and extract the texture URL
String decodedTexture = extractSkinUrlFromBase64(base64Texture);
// Set the skin URL using PlayerTextures
PlayerTextures textures = profile.getTextures();
try {
// Using a URL object for the texture
textures.setSkin(new URL(decodedTexture));
} catch (MalformedURLException ignore) {} // Base64 has no URL, ignore
// Apply the textures to the profile
profile.setTextures(textures);
// Apply the PlayerProfile to the SkullMeta
skullMeta.setOwnerProfile(profile);
// Set the modified SkullMeta back to the ItemStack
skull.setItemMeta(skullMeta);
savedCustomHeads.put(base64Texture, skull);
return skull;
}
// New method to get a player head by player name
public ItemStack getPlayerHead(String playerName) {
//check for any saved heads
if(savedCustomHeads.containsKey(playerName)) {
return savedCustomHeads.get(playerName);
}
//clear cached textures list until length limit is reached
Iterator<Map.Entry<String, ItemStack>> iterator = savedCustomHeads.entrySet().iterator();
while (savedCustomHeads.size() > 2000 && iterator.hasNext()) {
iterator.next(); // Move to next entry
iterator.remove(); // Remove the entry
}
// Create a new player head ItemStack
ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
// Get the OfflinePlayer object for the provided player name
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
// Create a PlayerProfile from the player's UUID
UUID playerUUID = offlinePlayer.getUniqueId();
PlayerProfile profile = Bukkit.createPlayerProfile(playerUUID);
// Apply the PlayerProfile to the SkullMeta
skullMeta.setOwnerProfile(profile);
// Set the modified SkullMeta back to the ItemStack
skull.setItemMeta(skullMeta);
savedCustomHeads.put(playerName, skull);
return skull;
}
// Helper method to extract the skin URL from the base64 texture
private String extractSkinUrlFromBase64(String base64Texture) {
// Decode the base64 string
byte[] decodedBytes = Base64.getDecoder().decode(base64Texture);
String decodedString = new String(decodedBytes);
// Parse the decoded string as JSON
JsonObject jsonObject = JsonParser.parseString(decodedString).getAsJsonObject();
// Navigate to "textures" -> "SKIN" -> "url"
JsonObject textures = jsonObject.getAsJsonObject("textures");
JsonObject skin = textures.getAsJsonObject("SKIN");
// Return the URL if it exists
return skin.has("url") ? skin.get("url").getAsString() : null;
}
}

View File

@ -0,0 +1,52 @@
package me.rockyhawk.commandpanels.classresources.item_fall;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.PanelClosedEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
public class ItemFallManager implements Listener {
CommandPanels plugin;
public ItemFallManager(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void panelCloseItemsDrop(PanelClosedEvent e){
new BukkitRunnable(){
@Override
public void run(){
for(String item : e.getPanel().getConfig().getConfigurationSection("item").getKeys(false)){
if(e.getPanel().getConfig().isSet("item." + item + ".itemType")){
//either the panel will drop the item or it will return to the inventory, no option to do both obviously
if(e.getPanel().getConfig().getStringList("item." + item + ".itemType").contains("dropItem")){
ItemStack stack = e.getPlayer().getOpenInventory().getTopInventory().getItem(Integer.parseInt(item));
if(stack == null || stack.getType() == Material.AIR){
continue;
}
//trigger event and check for cancel
PanelItemDropEvent dropEvent = new PanelItemDropEvent(e.getPlayer(),e.getPanel(),stack);
Bukkit.getPluginManager().callEvent(dropEvent);
if(dropEvent.isCancelled()){
continue;
}
e.getPlayer().getWorld().dropItem(e.getPlayer().getLocation(),stack);
}else if(e.getPanel().getConfig().getStringList("item." + item + ".itemType").contains("returnItem")){
//Remove item is listed just because website is not updated yet.
ItemStack stack = e.getPlayer().getOpenInventory().getTopInventory().getItem(Integer.parseInt(item));
if(stack == null || stack.getType() == Material.AIR){
continue;
}
plugin.inventorySaver.addItem(e.getPlayer(),stack);
}
}
}
}
}.run();
}
}

View File

@ -0,0 +1,51 @@
package me.rockyhawk.commandpanels.classresources.item_fall;
import me.rockyhawk.commandpanels.api.Panel;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
public class PanelItemDropEvent extends Event implements Cancellable {
private boolean isCancelled;
private final Player p;
private final Panel panel;
private final ItemStack item;
public boolean isCancelled() {
return this.isCancelled;
}
public void setCancelled(boolean isCancelled) {
this.isCancelled = isCancelled;
}
public PanelItemDropEvent(Player player, Panel panel, ItemStack drop) {
this.p = player;
this.panel = panel;
this.item = drop;
}
public Player getPlayer(){
return this.p;
}
public ItemStack getItem(){
return this.item;
}
public Panel getPanel(){
return this.panel;
}
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -0,0 +1,135 @@
package me.rockyhawk.commandpanels.classresources.placeholders;
import me.clip.placeholderapi.PlaceholderAPI;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.List;
public class CreateText {
CommandPanels plugin;
public CreateText(CommandPanels pl) {
this.plugin = pl;
}
//CommandPanels send message function with all placeholders
public void sendMessage(Panel panel,PanelPosition position, Player p, String message){
if(!message.equals("")) {
p.sendMessage(placeholders(panel,position, p,plugin.tag + message));
}
}
//CommandPanels send message function
public void sendMessage(Player p, String message){
if(!message.equals("")) {
p.sendMessage(colour(plugin.tag + message));
}
}
//CommandPanels send message function without the tag
public void sendString(Panel panel,PanelPosition position, Player p, String message){
if(!message.equals("")) {
p.sendMessage(placeholders(panel,position, p,message));
}
}
//CommandPanels send message function without the tag
public void sendString(Player p, String message){
if(!message.equals("")) {
p.sendMessage(colour(message));
}
}
//papi except if it is a String List
public List<String> placeholdersNoColour(Panel panel,PanelPosition position, Player p, List<String> setpapi) {
try {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, attachPlaceholders(panel,position, p, temp));
tempInt += 1;
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
return setpapi;
}
//papi except if it is a String List
public List<String> placeholdersList(Panel panel,PanelPosition position, Player p, List<String> setpapi, boolean placeholder) {
try {
if(placeholder) {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, attachPlaceholders(panel,position, p, temp));
tempInt += 1;
}
}
}catch(Exception ignore){}
int tempInt = 0;
//change colour
for(String temp : setpapi){
try {
setpapi.set(tempInt,
plugin.hex.translateHexColorCodes(
ChatColor.translateAlternateColorCodes('&', temp)));
}catch(NullPointerException ignore){}
tempInt += 1;
}
return setpapi;
}
//regular string papi, but only colours so Player doesn't need to be there
public String colour(String setpapi) {
try {
if(plugin.miniMessage != null){
setpapi = plugin.miniMessage.doMiniMessageLegacy(setpapi);
}
setpapi = ChatColor.translateAlternateColorCodes('&', setpapi);
setpapi = plugin.hex.translateHexColorCodes(setpapi);
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//string papi with no colours
public String placeholdersNoColour(Panel panel, PanelPosition position, Player p, String setpapi) {
try {
setpapi = attachPlaceholders(panel,position, p,setpapi);
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//regular string papi
public String placeholders(Panel panel, PanelPosition position, Player p, String setpapi) {
try {
setpapi = attachPlaceholders(panel,position, p,setpapi);
if(plugin.miniMessage != null){
setpapi = plugin.miniMessage.doMiniMessageLegacy(setpapi);
}
setpapi = ChatColor.translateAlternateColorCodes('&', setpapi);
setpapi = plugin.hex.translateHexColorCodes(setpapi);
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
public String attachPlaceholders(Panel panel, PanelPosition position, Player p, String input){
//do all the placeholders in order to fill into text
input = plugin.placeholders.setPlaceholders(panel,position, p, input, false);
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
input = PlaceholderAPI.setPlaceholders(offp, input);
}
input = plugin.placeholders.setPlaceholders(panel,position, p, input, true);
return input;
}
}

View File

@ -0,0 +1,50 @@
package me.rockyhawk.commandpanels.classresources.placeholders;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HexColours {
CommandPanels plugin;
public HexColours(CommandPanels pl) {
this.plugin = pl;
}
public String translateHexColorCodes(String message) {
//add all the different HEX combinations, in order to ensure they do not cancel each other out
message = doTranslation(message,formatRegex("hexcodes.start_tag"),formatRegex("hexcodes.end_tag"));
return message;
}
//used to translate hex colours into ChatColors
private String doTranslation(String message, String startTag, String endTag) {
final Pattern hexPattern = Pattern.compile(startTag + "([A-Fa-f0-9]{6})" + endTag);
Matcher matcher = hexPattern.matcher(message);
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
while (matcher.find()) {
String group = matcher.group(1);
matcher.appendReplacement(buffer, ChatColor.COLOR_CHAR + "x"
+ ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1)
+ ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3)
+ ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5)
);
}
return matcher.appendTail(buffer).toString();
}
//automatically format regex to escape special characters
private String formatRegex(String path){
String inputString = plugin.config.getString(path);
final String[] metaCharacters = {"\\","^","$","{","}","[","]","(",")",".","*","+","?","|","<",">","-","&","%"};
for (String metaCharacter : metaCharacters) {
assert inputString != null;
if (inputString.contains(metaCharacter)) {
inputString = inputString.replace(metaCharacter, "\\" + metaCharacter);
}
}
return inputString;
}
}

View File

@ -0,0 +1,15 @@
package me.rockyhawk.commandpanels.classresources.placeholders;
import java.util.HashMap;
public class PanelPlaceholders {
public HashMap<String,String> keys;
public void addPlaceholder(String placeholder, String argument){
keys.put(placeholder,argument);
}
public PanelPlaceholders(){
keys = new HashMap<>();
}
}

View File

@ -0,0 +1,477 @@
package me.rockyhawk.commandpanels.classresources.placeholders;
import com.earth2me.essentials.Essentials;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.PotionMeta;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.*;
public class Placeholders {
CommandPanels plugin;
public Placeholders(CommandPanels pl) {
this.plugin = pl;
}
public String setPlaceholders(Panel panel,PanelPosition position, Player p, String str, boolean primary){
String[] HOLDERS = getPlaceholderEnds(panel,primary);
while (str.contains(HOLDERS[0] + "cp-")) {
try {
int start = str.indexOf(HOLDERS[0] + "cp-");
int end = str.indexOf(HOLDERS[1], str.indexOf(HOLDERS[0] + "cp-") + 1);
String identifier = str.substring(start, end).replace(HOLDERS[0] + "cp-", "").replace(HOLDERS[1], "");
String value;
try {
value = cpPlaceholders(panel,position,p,identifier);
} catch (NullPointerException er) {
value = "";
}
str = str.replace(str.substring(start, end) + HOLDERS[1], value);
}catch(Exception ex){
plugin.debug(ex,p);
break;
}
}
return str;
}
//returns primary then secondary {[start,end],[start,end]}
public String[] getPlaceholderEnds(Panel panel, boolean primary){
List<String[]> values = new ArrayList<>();
values.add(new String[]{plugin.config.getString("placeholders.primary.start"),plugin.config.getString("placeholders.primary.end")});
values.add(new String[]{plugin.config.getString("placeholders.secondary.start"),plugin.config.getString("placeholders.secondary.end")});
if(panel != null) {
if (panel.getConfig().isSet("placeholders")) {
if (panel.getConfig().isSet("placeholders.primary")) {
values.set(0, new String[]{panel.getConfig().getString("placeholders.primary.start"), panel.getConfig().getString("placeholders.primary.end")});
}
if (panel.getConfig().isSet("placeholders.secondary")) {
values.set(1, new String[]{panel.getConfig().getString("placeholders.secondary.start"), panel.getConfig().getString("placeholders.secondary.end")});
}
}
}
if(primary){
return values.get(0);
}else{
return values.get(1);
}
}
//this requires the placeholder to already be identified
@SuppressWarnings("deprecation")
public String cpPlaceholders(Panel panel, PanelPosition position, Player p, String identifier){
//replace nodes with PlaceHolders
switch(identifier){
case("player-displayname"): {
return p.getDisplayName();
}
case("player-name"): {
return p.getName();
}
case("player-world"): {
return p.getWorld().getName();
}
case("player-x"): {
return String.valueOf(Math.round(p.getLocation().getX()));
}
case("player-y"): {
return String.valueOf(Math.round(p.getLocation().getY()));
}
case("player-z"): {
return String.valueOf(Math.round(p.getLocation().getZ()));
}
case("online-players"): {
return Integer.toString(Bukkit.getServer().getOnlinePlayers().size());
}
case("online-players-visible"): {
//will not include players that are vanished
int count = 0;
for(Player temp : Bukkit.getOnlinePlayers()) {
if(!isPlayerVanished(temp)) {
count++;
}
}
return Integer.toString(count);
}
case("panel-position"): {
return position.toString();
}
case("tag"): {
return plugin.tex.colour(plugin.tag);
}
}
//set custom placeholders to their values
if(panel != null) {
for (String placeholder : panel.placeholders.keys.keySet()) {
if(identifier.equals(placeholder)) {
try {
return panel.placeholders.keys.get(placeholder);
} catch (Exception ex) {
plugin.debug(ex, p);
break;
}
}
}
}
//placeholder to check for server availability %cp-server-IP:PORT%
if(identifier.startsWith("server-")) {
String ip_port = identifier.replace("server-", "");
Socket s = new Socket();
try {
s.connect(new InetSocketAddress(ip_port.split(":")[0], (int)Double.parseDouble(ip_port.split(":")[1])), plugin.config.getInt("config.server-ping-timeout"));
s.close();
return "true";
}catch (IOException ex){
return "false";
}
}
//placeholder to check if an item has NBT %cp-nbt-slot:type:key%
if (identifier.startsWith("nbt-")) {
try {
String slot_key = identifier.replace("nbt-", "");
Object value;
value = plugin.nbt.getNBT(
p.getOpenInventory().getTopInventory().getItem(
(int) Double.parseDouble(slot_key.split(":")[0])
),
slot_key.split(":")[2],
slot_key.split(":")[1]
);
// Convert any object type to a string, handle null explicitly if desired
return value == null ? "empty" : String.valueOf(value);
} catch (Exception ex) {
plugin.debug(ex, p);
return ""; // Consider returning "error" or some other indicative string
}
}
// Placeholder to check if an item has POTION data %cp-potion-slot%
if (identifier.startsWith("potion-")) {
try {
String slot_key = identifier.replace("potion-", "");
int slotIndex = (int) Double.parseDouble(slot_key);
// Get the item in the specified slot
ItemStack item = p.getOpenInventory().getTopInventory().getItem(slotIndex);
// Check if the item is not null and has potion meta
if (item != null && item.hasItemMeta() && item.getItemMeta() instanceof PotionMeta) {
//choose between legacy PotionData (pre 1.20.5) or PotionType
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
//Returns the value like this <Type>:<Extended>:<Upgraded> Example SLOWNESS:true:false
return plugin.legacyPotion.retrievePotionData(item).replaceAll("\\s",":");
}else{
//post 1.20.5 compare just return PotionType
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
return potionMeta.getBasePotionType().toString();
}
} else {
return "empty"; // Item is either null or doesn't have potion meta
}
} catch (Exception ex) {
plugin.debug(ex, p);
return ""; // Handle exceptions as needed
}
}
//DO placeholders for detection of other items in a panel
//get material value from slot in current open inventory (panel)
if(identifier.startsWith("material-")) {
try {
String matNumber = identifier.replace("material-", "");
String material;
try {
material = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber)).getType().toString();
if (plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
//add the ID to the end if it is legacy (eg, material:id)
material = material + ":" + p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber)).getData().getData();
}
} catch (NullPointerException er) {
material = "AIR";
}
return material;
} catch (Exception ex) {
plugin.debug(ex,p);
return "";
}
}
//get name value from slot in current open inventory (panel)
if(identifier.startsWith("name-")) {
try {
String nameNumber = identifier.replace("name-", "");
String name;
try {
ItemStack item = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(nameNumber));
name = item.getType().toString().replace("_"," ");
if(item.hasItemMeta()){
if(item.getItemMeta().hasDisplayName()){
name = item.getItemMeta().getDisplayName();
}
}
} catch (NullPointerException er) {
name = "";
}
return name;
} catch (Exception ex) {
plugin.debug(ex,p);
return "";
}
}
//get lore value from slot in current open inventory (panel)
if(identifier.startsWith("lore-")) {
try {
String loreNumber = identifier.replace("lore-", "");
String lore = "";
try {
ItemStack item = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(loreNumber));
if(item.hasItemMeta()){
if(item.getItemMeta().hasLore()){
List<String> ListLore = item.getItemMeta().getLore();
for(String list : ListLore){
lore = lore + list + "\n";
}
}
}
} catch (NullPointerException er) {
lore = "";
}
return lore;
} catch (Exception ex) {
plugin.debug(ex,p);
return "";
}
}
//get stack amount from slot in current open inventory (panel)
if(identifier.startsWith("stack-")) {
try {
String matNumber = identifier.replace("stack-", "");
int amount;
try {
amount = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber)).getAmount();
} catch (NullPointerException er) {
amount = 0;
}
return String.valueOf(amount);
}catch(Exception ex){
plugin.debug(ex,p);
return "";
}
}
//get stack amount from slot in current open inventory (panel)
if(identifier.startsWith("modeldata-")) {
try {
String matNumber = identifier.replace("modeldata-", "");
int modelData;
try {
modelData = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber)).getItemMeta().getCustomModelData();
} catch (NullPointerException er) {
modelData = 0;
}
return String.valueOf(modelData);
}catch(Exception ex){
plugin.debug(ex,p);
return "";
}
}
//is an item damaged
if(identifier.startsWith("damaged-")) {
try {
String matNumber = identifier.replace("damaged-", "");
boolean damaged = false;
ItemStack itm = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber));
try {
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)){
if(itm.getType().getMaxDurability() != 0) {
damaged = (itm.getType().getMaxDurability() - itm.getDurability()) < itm.getType().getMaxDurability();
}
}else {
Damageable itemDamage = (Damageable) itm.getItemMeta();
damaged = itemDamage.hasDamage();
}
} catch (NullPointerException er) {
damaged = false;
}
return String.valueOf(damaged);
}catch(Exception ex){
plugin.debug(ex,p);
return "";
}
}
//is an item identical, uses custom-items (custom item, slot)
if(identifier.startsWith("identical-")) {
try {
String matLocSlot = identifier.replace("identical-", "");
String matLoc = matLocSlot.split(",")[0];
int matSlot = (int)Double.parseDouble(matLocSlot.split(",")[1]);
boolean isIdentical = false;
ItemStack itm = p.getOpenInventory().getTopInventory().getItem(matSlot);
if(itm == null){
//continue if material is null
return "false";
}
try {
//if it is a regular custom item
ItemStack confItm = plugin.itemCreate.makeItemFromConfig(panel,position,panel.getConfig().getConfigurationSection("custom-item." + matLoc),p,true,true, false);
if(plugin.itemCreate.isIdentical(confItm,itm, Objects.requireNonNull(panel.getConfig().getConfigurationSection("custom-item." + matLoc)).contains("nbt"))){
isIdentical = true;
}
//if custom item is an mmo item (1.14+ for the API)
String customItemMaterial = panel.getConfig().getString("custom-item." + matLoc + ".material");
if (plugin.getServer().getPluginManager().isPluginEnabled("MMOItems") && customItemMaterial.startsWith("mmo=")) {
String mmoType = customItemMaterial.split("\\s")[1];
String mmoID = customItemMaterial.split("\\s")[2];
if (plugin.isMMOItem(itm,mmoType,mmoID) && itm.getAmount() <= confItm.getAmount()) {
isIdentical = true;
}
}
} catch (NullPointerException er) {
isIdentical = false;
}
return String.valueOf(isIdentical);
}catch(Exception ex){
plugin.debug(ex,p);
return "";
}
}
//does %cp-random-MIN,MAX%
if(identifier.startsWith("random-")) {
try {
String min_max = identifier.replace("random-", "");
int min = (int)Double.parseDouble(min_max.split(",")[0]);
int max = (int)Double.parseDouble(min_max.split(",")[1]);
return String.valueOf(plugin.getRandomNumberInRange(min, max));
}catch (Exception ex){
plugin.debug(ex,p);
return "";
}
}
//returns value of stored data
if(identifier.startsWith("data-")) {
try {
String dataPoint = identifier.replace("data-", "");
//get data from other user
if(dataPoint.contains(",")){
String dataName = dataPoint.split(",")[0];
String playerName = dataPoint.split(",")[1];
return plugin.panelData.getUserData(plugin.panelDataPlayers.getOffline(playerName),dataName);
}else{
return plugin.panelData.getUserData(p.getUniqueId(),dataPoint);
}
}catch (Exception ex){
plugin.debug(ex,p);
return "";
}
}
//returns if a player is found
if(identifier.startsWith("uuid-")) {
try {
String dataPoint = identifier.replace("uuid-", "");
//get data from other user
if(plugin.panelDataPlayers.getOffline(dataPoint) == null){
return "unknown";
}
return plugin.panelDataPlayers.getOffline(dataPoint).toString();
}catch (Exception ex){
plugin.debug(ex,p);
return "";
}
}
//edits data via placeholder execution (will return empty output)
if(identifier.startsWith("setdata-")) {
try {
String point_value = identifier.replace("setdata-", "");
String command = "set-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandRunner.runCommand(panel,position,p, command);
return "";
}catch (Exception ex){
plugin.debug(ex,p);
return "";
}
}
//math data via placeholder execution (will return empty output)
if(identifier.startsWith("mathdata-")) {
try {
String point_value = identifier.replace("mathdata-", "");
String command = "math-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandRunner.runCommand(panel,position,p,command);
return "";
}catch (Exception ex){
plugin.debug(ex,p);
return "";
}
}
//checks for players online
if(identifier.startsWith("player-online-")) {
try {
String playerLocation = identifier.replace("player-online-", "");
if (identifier.endsWith("-visible")){
//for players that are visible only
//remove -visible from the end of playerLocation
playerLocation = playerLocation.replace("-visible", "");
List<Player> playerList = new ArrayList<>();
for(Player temp : Bukkit.getOnlinePlayers()) {
if(!isPlayerVanished(temp)) {
playerList.add(temp);
}
}
if(playerList.size() >= Integer.parseInt(playerLocation)){
return playerList.get(Integer.parseInt(playerLocation)-1).getName();
}
} else {
//for every player whether they are visible or not
if(Bukkit.getOnlinePlayers().toArray().length >= Integer.parseInt(playerLocation)){
return ((Player)Bukkit.getOnlinePlayers().toArray()[Integer.parseInt(playerLocation)-1]).getName();
}
}
//player is not found
return plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline")));
}catch (Exception ex){
plugin.debug(ex,p);
return "";
}
}
try {
if (plugin.econ != null) {
if(identifier.equals("player-balance")) {
return String.valueOf(Math.round(plugin.econ.getBalance(p)));
}
}
} catch (Exception place) {
//skip
}
//end nodes with PlaceHolders
return "";
}
public boolean isPlayerVanished(Player player) {
//check if EssentialsX exists
if(!Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
return false;
}
//check if player is vanished using essentials
Essentials essentials = (Essentials)Bukkit.getPluginManager().getPlugin("Essentials");
return essentials.getUser(player).isVanished();
}
}

View File

@ -0,0 +1,47 @@
package me.rockyhawk.commandpanels.classresources.placeholders.expansion;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class CpPlaceholderExpansion extends PlaceholderExpansion {
private final CommandPanels plugin;
public CpPlaceholderExpansion(CommandPanels plugin) {
this.plugin = plugin;
}
@Override
public String getAuthor() {
return "RockyHawk";
}
@Override
public String getIdentifier() {
return "commandpanels";
}
@Override
public String getVersion() {
return "1.0.0";
}
@Override
public boolean persist() {
return true; // This is required or else PlaceholderAPI will unregister the Expansion on reload
}
/*
external use only, not to be used for example inside a panel
usage: %commandpanels_<placeholder>%
so for example %cp-data-test% instead you would do %commandpanels_data-test%
*/
@Override
public String onRequest(OfflinePlayer player, @NotNull String identifier) {
return plugin.placeholders.cpPlaceholders(null, PanelPosition.Top, (Player)player, identifier);
}
}

View File

@ -0,0 +1,44 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.scheduler.BukkitRunnable;
public class CommandPanelImport implements CommandExecutor {
CommandPanels plugin;
public CommandPanelImport(CommandPanels pl) {
this.plugin = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.hasPermission("commandpanel.import")) {
if(!plugin.config.getString("config.enable-import-command").equalsIgnoreCase("true")){
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.disabled")));
return true;
}
if (args.length == 2) {
//import command
new BukkitRunnable() {
@Override
public void run() {
plugin.downloader.downloadPanel(sender, args[1], args[0]);
plugin.reloadPanelFiles();
plugin.hotbar.reloadHotbarSlots();
}
}.run();
return true;
}
} else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return true;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpi <file name> <url>"));
return true;
}
}

View File

@ -0,0 +1,114 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
public class Commandpanel implements CommandExecutor {
CommandPanels plugin;
public Commandpanel(CommandPanels pl) {
this.plugin = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
//below is going to go through the files and find the right one
Panel panel = null;
if (args.length != 0) { //check to make sure the person hasn't just left it empty
for (Panel tempPanel : plugin.panelList) {
if (tempPanel.getName().equals(args[0])) {
panel = tempPanel;
break;
}
}
} else {
plugin.helpMessage(sender);
return true;
}
if (panel == null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel")));
return true;
}
boolean disableCommand = false;
if (panel.getConfig().contains("panelType")) {
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
//do not allow command with noCommand, console is an exception
disableCommand = true;
}
}
//below will start the command, once it got the right file and panel
if (!(sender instanceof Player)) {
//do console command
if (args.length == 2) {
if (!args[1].equals("item")) {
if (args[1].equalsIgnoreCase("all")) {
for (Player player : Bukkit.getOnlinePlayers())
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
} else
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
} else {
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player|all]"));
}
return true;
} else if (args.length == 3) {
if (args[1].equals("item")) {
if (args[2].equalsIgnoreCase("all")) {
// if the argument is all open the panel for all of the players
for (Player player : Bukkit.getOnlinePlayers())
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
} else
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(), true);
} else {
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player|all]"));
}
return true;
} else {
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command directed to a Player!"));
return true;
}
} else {
//get player
Player p = (Player) sender;
//do player command
if (args.length == 1) {
if (!disableCommand) {
plugin.openVoids.openCommandPanel(sender, p, panel.copy(), PanelPosition.Top, false);
}
return true;
} else if (args.length == 2) {
if (args[1].equals("item")) {
plugin.openVoids.giveHotbarItem(sender, p, panel.copy(), false);
} else {
if (!disableCommand) {
if (args[1].equalsIgnoreCase("all")) {
// if the argument is all open the panel for all of the players
for (Player player : Bukkit.getOnlinePlayers())
plugin.openVoids.openCommandPanel(sender, player, panel.copy(), PanelPosition.Top, true);
} else
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
}
}
return true;
} else if (args.length == 3) {
if (args[2].equalsIgnoreCase("all")) {
// if the argument is all open the panel for all of the players
for (Player player : Bukkit.getOnlinePlayers())
plugin.openVoids.giveHotbarItem(sender, player, panel.copy(), true);
} else
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(), true);
return true;
}
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player|all:item] [player|all]"));
return true;
}
}

View File

@ -0,0 +1,128 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.util.Arrays;
public class Commandpanelsdata implements CommandExecutor {
CommandPanels plugin;
public Commandpanelsdata(CommandPanels pl) {
this.plugin = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.hasPermission("commandpanel.data")) {
boolean sendPlayerMessage = true;
//check to make sure args isn't empty first
//if the first argument is -s it will not send a message to the sender
if(args.length != 0) {
if (args[0].equalsIgnoreCase("-s")) {
args = Arrays.copyOfRange(args, 1, args.length);
sendPlayerMessage = false;
}
}
int count = 0;
if (args.length == 2) {
//for the clear command
if (args[0].equals("clear")) {
if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("online")) {
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
if (args[1].equalsIgnoreCase("online") && !player.isOnline()) continue;
plugin.panelData.clearData(plugin.panelDataPlayers.getOffline(player.getName()));
count++;
}
} else
plugin.panelData.clearData(plugin.panelDataPlayers.getOffline(args[1]));
if (sendPlayerMessage) {
sender.sendMessage(plugin.tex.colour(plugin.tag
+ ChatColor.GREEN + "Cleared all data for "
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
}
return true;
}
} else if (args.length == 3) {
//for the remove command
if (args[0].equals("remove")) {
if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("online")) {
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
if (args[1].equalsIgnoreCase("online") && !player.isOnline()) continue;
plugin.panelData.delUserData(plugin.panelDataPlayers.getOffline(player.getName()), args[2]);
count++;
}
} else
plugin.panelData.delUserData(plugin.panelDataPlayers.getOffline(args[1]), args[2]);
if (sendPlayerMessage) {
sender.sendMessage(plugin.tex.colour(plugin.tag
+ ChatColor.GREEN + "Removed "
+ ChatColor.WHITE + args[2]
+ ChatColor.GREEN + " from "
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
}
return true;
} else if (args[0].equals("get")) {
//for the get command
sender.sendMessage(plugin.tex.colour(plugin.tag
+ ChatColor.GREEN + "Value of data is "
+ ChatColor.WHITE + plugin.panelData.getUserData(plugin.panelDataPlayers.getOffline(args[1]), args[2])));
return true;
}
} else if (args.length == 4) {
if (args[0].equals("set")) {
//for set command
if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("online")) {
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
if (args[1].equalsIgnoreCase("online") && !player.isOnline()) continue;
plugin.panelData.setUserData(plugin.panelDataPlayers.getOffline(player.getName()), args[2], args[3], true);
count++;
}
} else {
plugin.panelData.setUserData(plugin.panelDataPlayers.getOffline(args[1]), args[2], args[3], true);
}
if (sendPlayerMessage) {
sender.sendMessage(plugin.tex.colour(plugin.tag
+ ChatColor.GREEN + "Set "
+ ChatColor.WHITE + args[2]
+ ChatColor.GREEN + " to "
+ ChatColor.WHITE + args[3]
+ ChatColor.GREEN + " for "
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
}
} else {
//for add command
if (args[1].equalsIgnoreCase("all") || args[1].equalsIgnoreCase("online")) {
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
if (args[1].equalsIgnoreCase("online") && !player.isOnline()) continue;
plugin.panelData.setUserData(plugin.panelDataPlayers.getOffline(player.getName()), args[2], args[3], false);
count++;
}
} else
plugin.panelData.setUserData(plugin.panelDataPlayers.getOffline(args[1]), args[2], args[3], false);
if (sendPlayerMessage) {
sender.sendMessage(plugin.tex.colour(plugin.tag
+ ChatColor.GREEN + "Set "
+ ChatColor.WHITE + args[2]
+ ChatColor.GREEN + " to "
+ ChatColor.WHITE + args[3])
+ ChatColor.GREEN + " for "
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")
+ " if it did not exist already");
}
}
return true;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpdata <set:add:get:remove:clear> <player|all|online> <data> [value]"));
} else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return true;
}
}

View File

@ -0,0 +1,41 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandpanelsdebug implements CommandExecutor {
CommandPanels plugin;
public Commandpanelsdebug(CommandPanels pl) { this.plugin = pl; }
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.hasPermission("commandpanel.debug")) {
if (args.length == 0) {
//command /cpd
if(!(sender instanceof Player)) {
plugin.debug.consoleDebug = !plugin.debug.consoleDebug;
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Global Debug Mode: " + plugin.debug.consoleDebug));
return true;
}
Player p = (Player)sender;
if(plugin.debug.isEnabled(p)){
plugin.debug.debugSet.remove(p);
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Disabled!"));
}else{
plugin.debug.debugSet.add(p);
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Enabled!"));
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpd"));
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return true;
}
}

View File

@ -0,0 +1,61 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import java.util.ArrayList;
public class Commandpanelslist implements CommandExecutor {
CommandPanels plugin;
public Commandpanelslist(CommandPanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("cpl") || label.equalsIgnoreCase("commandpanellist") || label.equalsIgnoreCase("cpanell")) {
if (sender.hasPermission("commandpanel.list")) {
//command /cpl
//check to make sure the panels isn't empty
try {
if (plugin.panelList == null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "No panels found!"));
return true;
}
}catch(Exception b){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "No panels found!"));
return true;
}
ArrayList<Panel> panels = new ArrayList<>(plugin.panelList);
int page = 1;
int skip = 0;
if(args.length == 1){
try {
page = Integer.parseInt(args[0]);
skip = page*8-8;
}catch (Exception e){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Inaccessible Page"));
}
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")"));
for (int f = skip; panels.size() > f && skip+8 > f; f++) {
sender.sendMessage(ChatColor.DARK_GREEN + panels.get(f).getFile().getAbsolutePath().replace(plugin.panelsf.getAbsolutePath(),"") + ChatColor.GREEN + " " + panels.get(f).getName());
if(panels.size()-1 == f){
return true;
}
}
sender.sendMessage(ChatColor.AQUA + "Type /cpl " + (page+1) + " to read next page");
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return true;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpl"));
return true;
}
}

View File

@ -0,0 +1,114 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Commandpanelsreload implements CommandExecutor {
CommandPanels plugin;
public Commandpanelsreload(CommandPanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("cpr") || label.equalsIgnoreCase("commandpanelreload") || label.equalsIgnoreCase("cpanelr")) {
if (sender.hasPermission("commandpanel.reload")) {
//close all the panels
for(String name : plugin.openPanels.openPanels.keySet()){
plugin.openPanels.closePanelForLoader(name, PanelPosition.Top);
try {
Bukkit.getPlayer(name).closeInventory();
}catch (Exception ignore){}
}
plugin.reloadPanelFiles();
plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml"));
plugin.blockConfig = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "blocks.yml"));
//load all known player UUIDs for data
plugin.panelDataPlayers.reloadAllPlayers();
//check for duplicates
plugin.checkDuplicatePanel(sender);
//reloadHotbarSlots
plugin.hotbar.reloadHotbarSlots();
//reload tag
plugin.tag = plugin.tex.colour(plugin.config.getString("config.format.tag"));
//add custom commands to commands.yml
if(plugin.config.getString("config.auto-register-commands").equalsIgnoreCase("true")) {
registerCommands();
}
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.reload")));
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return true;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpr"));
return true;
}
//this will require a server restart for new commands
public void registerCommands(){
File commandsLoc = new File("commands.yml");
YamlConfiguration cmdCF;
try {
cmdCF = YamlConfiguration.loadConfiguration(commandsLoc);
}catch(Exception e){
//could not access the commands.yml file
plugin.debug(e,null);
return;
}
//remove old commandpanels commands
for(String existingCommands : cmdCF.getConfigurationSection("aliases").getKeys(false)){
try {
if (cmdCF.getStringList("aliases." + existingCommands).get(0).equals("commandpanel")) {
cmdCF.set("aliases." + existingCommands, null);
}
}catch(Exception ignore){}
}
//make the command 'commandpanels' to identify it
ArrayList<String> temp = new ArrayList<>();
temp.add("commandpanel");
for (Panel panel : plugin.panelList) {
if(panel.getConfig().contains("panelType")){
if(panel.getConfig().getStringList("panelType").contains("nocommandregister")){
continue;
}
}
if(panel.getConfig().contains("commands")){
List<String> panelCommands = panel.getConfig().getStringList("commands");
for(String command : panelCommands){
cmdCF.set("aliases." + command.split("\\s")[0],temp);
}
}
}
try {
cmdCF.save(commandsLoc);
} catch (IOException var10) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not register custom commands!");
}
}
}

View File

@ -0,0 +1,72 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
public class Commandpanelsupdate implements CommandExecutor {
CommandPanels plugin;
public Commandpanelsupdate(CommandPanels pl) { this.plugin = pl; }
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("cpu") || label.equalsIgnoreCase("commandpanelupdate") || label.equalsIgnoreCase("cpanelu")) {
if (sender.hasPermission("commandpanel.refresh")) {
//command /cpu (uses .refresh permission node)
// /cpu <Playername> <Position/ALL>
String name;
Player targetPlayer;
try {
name = args[0];
targetPlayer = Bukkit.getPlayer(name);
}catch (Exception e){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Player was not found."));
return true;
}
assert targetPlayer != null;
PanelPosition pp;
if(args[1].equalsIgnoreCase("all")){
for(PanelPosition papo : PanelPosition.values()){
if(plugin.openPanels.hasPanelOpen(name, papo)) {
plugin.createGUI.openGui(plugin.openPanels.getOpenPanel(name, papo), targetPlayer, papo, PanelOpenType.Refresh, 0);
}
}
} else {
try {
pp = PanelPosition.valueOf(args[1]);
}catch (Exception e){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Panel position not found."));
return true;
}
if(plugin.openPanels.hasPanelOpen(name, pp)) {
plugin.createGUI.openGui(plugin.openPanels.getOpenPanel(name, pp), targetPlayer, pp, PanelOpenType.Refresh, 0);
}
}
if(plugin.inventorySaver.hasNormalInventory(targetPlayer)){
plugin.hotbar.updateHotbarItems(targetPlayer);
}
//Successfully refreshed panel for targetPlayer.getName()
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Successfully refreshed panel for " + targetPlayer.getName() + "."));
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return true;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpu <Playername> <Position/ALL>"));
return true;
}
}

View File

@ -0,0 +1,50 @@
package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
public class Commandpanelversion implements CommandExecutor {
CommandPanels plugin;
public Commandpanelversion(CommandPanels pl) { this.plugin = pl; }
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("cpv") || label.equalsIgnoreCase("commandpanelversion") || label.equalsIgnoreCase("cpanelv")) {
if(args.length == 0) {
if (sender.hasPermission("commandpanel.version")) {
//version command
String latestVersion = plugin.updater.getLatestVersion(false);
sender.sendMessage(plugin.tex.colour(plugin.tag));
sender.sendMessage(ChatColor.GREEN + "This Version " + ChatColor.GRAY + plugin.getDescription().getVersion());
sender.sendMessage(ChatColor.GREEN + "Latest Version " + ChatColor.GRAY + latestVersion);
sender.sendMessage(ChatColor.GRAY + "-------------------");
sender.sendMessage(ChatColor.GREEN + "Developer " + ChatColor.GRAY + "RockyHawk");
sender.sendMessage(ChatColor.GREEN + "Command " + ChatColor.GRAY + "/cp");
} else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
}else if(args.length == 1){
if (sender.hasPermission("commandpanel.update")) {
if (args[0].equals("cancel")) {
plugin.updater.downloadVersionManually = null;
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Will not download a new version on restart."));
} else {
plugin.updater.downloadVersionManually = args[0];
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server restart."));
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpv [update:latest:cancel]"));
}
return true;
}
return true;
}
}

View File

@ -0,0 +1,151 @@
package me.rockyhawk.commandpanels.commandtags;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.commandtags.paywalls.*;
import me.rockyhawk.commandpanels.commandtags.paywalls.itempaywall.ItemPaywall;
import me.rockyhawk.commandpanels.commandtags.tags.other.DataTags;
import me.rockyhawk.commandpanels.commandtags.tags.other.PlaceholderTags;
import me.rockyhawk.commandpanels.commandtags.tags.other.SpecialTags;
import me.rockyhawk.commandpanels.commandtags.tags.standard.BasicTags;
import me.rockyhawk.commandpanels.commandtags.tags.standard.BungeeTags;
import me.rockyhawk.commandpanels.commandtags.tags.standard.ItemTags;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.*;
public class CommandRunner {
CommandPanels plugin;
public CommandRunner(CommandPanels pl) {
this.plugin = pl;
}
//with the click type included, use null for no click type check
public void runCommands(Panel panel, PanelPosition position, Player p, List<String> commands, ClickType click) {
for (String command : commands) {
if(click != null) {
command = plugin.commandRunner.hasCorrectClick(command, click);
if (command.equals("")) {
//click type is wrong
continue;
}
}
//do paywall check
PaywallEvent paywallEvent = new PaywallEvent(plugin, panel, position, p, command);
Bukkit.getPluginManager().callEvent(paywallEvent);
if (paywallEvent.PAYWALL_OUTPUT == PaywallOutput.Blocked) {
break;
}
//not a paywall, run as command
if (paywallEvent.PAYWALL_OUTPUT == PaywallOutput.NotApplicable) {
plugin.commandRunner.runCommand(panel, position, p, command);
}
}
}
public void runCommand(Panel panel, PanelPosition position, Player p, String commandRAW) {
CommandTagEvent tags = new CommandTagEvent(plugin, panel, position, p, commandRAW);
Bukkit.getPluginManager().callEvent(tags);
if (!tags.commandTagUsed) {
Bukkit.dispatchCommand(p, plugin.tex.attachPlaceholders(panel, position, p, commandRAW.trim()));
}
}
public boolean runMultiPaywall(Panel panel, PanelPosition position, Player p, List<String> paywalls, List<String> commands, ClickType click) {
boolean allPaywallsValid = true;
// New list combining paywalls and commands
List<String> allCommands = new ArrayList<>(paywalls);
allCommands.addAll(commands);
for (String command : allCommands) {
// Trigger the event but do not remove the payment from the player
PaywallEvent paywallEvent = new PaywallEvent(plugin, panel, position, p, command);
paywallEvent.doDelete = false;
Bukkit.getPluginManager().callEvent(paywallEvent);
if (paywallEvent.PAYWALL_OUTPUT == PaywallOutput.Blocked) {
allPaywallsValid = false; // Set flag to false if any paywall is blocked
break; // Exit the loop if any command is blocked by the paywall
}
}
// Execute all commands if all paywalls are valid
if (allPaywallsValid) {
plugin.commandRunner.runCommands(panel, position, p, allCommands, click);
}
// Return output as boolean for usage if applicable
return allPaywallsValid;
}
//do this on startup to load listeners
public void registerBuiltInTags() {
plugin.getServer().getPluginManager().registerEvents(new Paywall(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new TokenPaywall(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new ItemPaywall(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new Hasperm(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new XpPaywall(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new DataPaywall(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new DataTags(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new PlaceholderTags(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new SpecialTags(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new BasicTags(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new BungeeTags(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new ItemTags(plugin), plugin);
}
public String hasCorrectClick(String command, ClickType click) {
try {
switch (command.split("\\s")[0]) {
case "right=": {
//if commands is for right-clicking, remove the 'right=' and continue
command = command.replace("right= ", "");
if (click != ClickType.RIGHT) {
return "";
}
break;
}
case "rightshift=": {
command = command.replace("rightshift= ", "");
if (click != ClickType.SHIFT_RIGHT) {
return "";
}
break;
}
case "left=": {
command = command.replace("left= ", "");
if (click != ClickType.LEFT) {
return "";
}
break;
}
case "leftshift=": {
command = command.replace("leftshift= ", "");
if (click != ClickType.SHIFT_LEFT) {
return "";
}
break;
}
case "middle=": {
command = command.replace("middle= ", "");
if (click != ClickType.MIDDLE) {
return "";
}
break;
}
}
return command;
} catch (Exception ex) {
return "";
//skip if you can't do this
}
}
}

Some files were not shown because too many files have changed in this diff Show More